From 9fa18058ad780c9d38a415781540f14e30a4efb5 Mon Sep 17 00:00:00 2001 From: jaseg Date: Wed, 4 Jan 2017 12:46:17 +0100 Subject: [PATCH] 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 --- mpv.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mpv.py b/mpv.py index c74e737..acf7913 100644 --- a/mpv.py +++ b/mpv.py @@ -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()