summaryrefslogtreecommitdiff
path: root/mpv.py
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2019-12-04 00:05:21 +0100
committerjaseg <code@jaseg.net>2019-12-04 09:48:16 +0100
commit63f9b742470c7acc2e847f15610a66f6b5ffdea9 (patch)
treed7721403ab7a7dda140fce298daca8759693b443 /mpv.py
parent3452ac87bc447fe14c30cd5fbddc4fd2f402a675 (diff)
downloadpython-mpv-63f9b742470c7acc2e847f15610a66f6b5ffdea9.tar.gz
python-mpv-63f9b742470c7acc2e847f15610a66f6b5ffdea9.tar.bz2
python-mpv-63f9b742470c7acc2e847f15610a66f6b5ffdea9.zip
Windows: Use cytpes.load_library to look for DLL
Diffstat (limited to 'mpv.py')
-rw-r--r--mpv.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/mpv.py b/mpv.py
index fd77a35..cd8c8ee 100644
--- a/mpv.py
+++ b/mpv.py
@@ -28,10 +28,13 @@ import re
import traceback
if os.name == 'nt':
- try:
- backend = CDLL('mpv-1.dll')
- except FileNotFoundError:
- backend = CDLL(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'mpv-1.dll'))
+ dll = ctypes.util.find_library('mpv-1.dll')
+ if dll is None:
+ raise OSError('Cannot find mpv-1.dll in your system %PATH%. One way to deal with this is to ship mpv-1.dll '
+ 'with your script and put the directory your script is in into %PATH% before "import mpv": '
+ 'os.environ["PATH"] = os.path.dirname(__file__) + os.pathsep + os.environ["PATH"] '
+ 'If mpv-1.dll is located elsewhere, you can add that path to os.environ["PATH"].')
+ backend = CDLL(dll)
fs_enc = 'utf-8'
else:
import locale
@@ -43,7 +46,7 @@ else:
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 "
+ "mpv-devel or mpv-libs package. If you have libmpv around but this script can't find it, consult "
"the documentation for ctypes.util.find_library which this script uses to look up the library "
"filename.")
backend = CDLL(sofile)