diff options
author | jaseg <git@jaseg.net> | 2017-01-04 12:46:17 +0100 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2017-01-04 12:46:17 +0100 |
commit | 9fa18058ad780c9d38a415781540f14e30a4efb5 (patch) | |
tree | e5e238804a1cfd8fd2c08e9fabbd92bcdae774a7 | |
parent | eb8b6a05d75a5abb55205f9859ce6f4223735946 (diff) | |
download | python-mpv-9fa18058ad780c9d38a415781540f14e30a4efb5.tar.gz python-mpv-9fa18058ad780c9d38a415781540f14e30a4efb5.tar.bz2 python-mpv-9fa18058ad780c9d38a415781540f14e30a4efb5.zip |
Make so/DLL loading more robust
* Print a proper error message if shared object not found on unix
* Abide by local conventions and look for DLL in script's directory on windows
-rw-r--r-- | mpv.py | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -13,7 +13,7 @@ import traceback # vim: ts=4 sw=4 et if os.name == 'nt': - backend = CDLL(ctypes.util.find_library('mpv-1.dll')) + backend = CDLL('mpv-1.dll') fs_enc = 'utf-8' else: import locale @@ -22,7 +22,13 @@ else: # still better than segfaulting, we are setting LC_NUMERIC to "C". locale.setlocale(locale.LC_NUMERIC, 'C') - backend = CDLL(ctypes.util.find_library('mpv')) + sofile = ctypes.util.find_library('mpv') + if sofile is None: + raise OSError("Cannot find libmpv in the usual places. Depending on your distro, you may try installing an " + "mpv-devel or mpv-libs package. If you have libmpv around but this script can't find it, maybe consult " + "the documentation for ctypes.util.find_library which this script uses to look up the library " + "filename.") + backend = CDLL(sofile) fs_enc = sys.getfilesystemencoding() |