[vlc-devel] [PATCH 2/2] Fix setup.py to fall back to generated file

Odin Hørthe Omdal odin.omdal at gmail.com
Sat Sep 5 19:50:56 CEST 2015


When you install python-vlc using pip or a similar package manager, you
won't have access to VLC files so you can't generate a fresh vlc.py.
However, the project itself ships a reasonably updated pre-generated
vlc.py that we can fall back to.
---
 setup.py | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/setup.py b/setup.py
index 5733a41..9013ac8 100644
--- a/setup.py
+++ b/setup.py
@@ -1,19 +1,23 @@
 from distribute_setup import use_setuptools
 use_setuptools()

-from distutils.core import setup
-import sys
+import logging
 import os
-import generate
+import shutil
+from distutils.core import setup

-vlc_include_path = os.path.join("..","..","include","vlc")
-if not os.path.exists(vlc_include_path):
-    raise Exception("This script should be run from a VLC tree.")
+import generate

-files = [ os.path.join(vlc_include_path, filename)
-          for filename in os.listdir(vlc_include_path) ]

-generate.process('vlc.py', files)
+vlc_include_path = os.path.join("..", "..", "include", "vlc")
+if os.path.exists(vlc_include_path):
+    files = [ os.path.join(vlc_include_path, filename)
+              for filename in os.listdir(vlc_include_path) ]
+    generate.process('vlc.py', files)
+else:
+    logging.warning("This script should be run from a VLC tree. "
+                    "Falling back to pre-generated file.")
+    shutil.copy(os.path.join('generated', 'vlc.py'), 'vlc.py')

 setup(name='python-vlc',
       version = '1.1.0',
@@ -29,6 +33,6 @@ setup(name='python-vlc',
 This module provides ctypes-based bindings for the native libvlc API
 (see http://wiki.videolan.org/LibVLC) of the VLC video player.

-It is automatically generated from the include files.
+It is automatically generated from the include files if they are available.
 """
       )
-- 
2.5.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20150905/a14f3958/attachment.html>


More information about the vlc-devel mailing list