vlc/python | branch: master | Odin Hørthe Omdal <[email protected]> | Sat 
Sep  5 19:50:56 2015 +0200| [699c364e7e6218f599f1587351e567213f2c011c] | 
committer: Olivier Aubert

Fix setup.py to fall back to generated file

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.

Signed-off-by: Olivier Aubert <[email protected]>

> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=699c364e7e6218f599f1587351e567213f2c011c
---

 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.
 """
       )

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to