[vlc-commits] Get directory names from environment
vaksick
git at videolan.org
Tue Sep 6 12:17:17 CEST 2016
vlc/python | branch: master | vaksick <vaksick at gmail.com> | Sun Sep 4 16:13:32 2016 +0200| [506b7f14957d4f585318823441c6af7157bfe8be] | committer: Olivier Aubert
Get directory names from environment
Signed-off-by: Olivier Aubert <contact at olivieraubert.net>
> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=506b7f14957d4f585318823441c6af7157bfe8be
---
generator/header.py | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/generator/header.py b/generator/header.py
index 30f9063..786e801 100755
--- a/generator/header.py
+++ b/generator/header.py
@@ -113,7 +113,8 @@ def find_lib():
except OSError: # may fail
dll = ctypes.CDLL('libvlc.so.5')
elif sys.platform.startswith('win'):
- p = find_library('libvlc.dll')
+ libname = 'libvlc.dll'
+ p = find_library(libname)
if p is None:
try: # some registry settings
# leaner than win32api, win32con
@@ -132,10 +133,14 @@ def find_lib():
except ImportError: # no PyWin32
pass
if plugin_path is None:
- # try some standard locations.
- for p in ('Program Files\\VideoLan\\', 'VideoLan\\',
- 'Program Files\\', ''):
- p = 'C:\\' + p + 'VLC\\libvlc.dll'
+ # try some standard locations.
+ programfiles = os.environ["ProgramFiles"]
+ homedir = os.environ["HOMEDRIVE"]
+ for p in ('{programfiles}\\VideoLan{libname}', '{homedir}:\\VideoLan{libname}',
+ '{programfiles}{libname}', '{homedir}:{libname}'):
+ p = p.format(homedir = homedir,
+ programfiles = programfiles,
+ libname = '\\VLC\\' + libname)
if os.path.exists(p):
plugin_path = os.path.dirname(p)
break
@@ -143,11 +148,11 @@ def find_lib():
p = os.getcwd()
os.chdir(plugin_path)
# if chdir failed, this will raise an exception
- dll = ctypes.CDLL('libvlc.dll')
+ dll = ctypes.CDLL(libname)
# restore cwd after dll has been loaded
os.chdir(p)
else: # may fail
- dll = ctypes.CDLL('libvlc.dll')
+ dll = ctypes.CDLL(libname)
else:
plugin_path = os.path.dirname(p)
dll = ctypes.CDLL(p)
More information about the vlc-commits
mailing list