Skip to content

Commit 2096d6a

Browse files
committed
Merge pull request #55 from valpogus/fix_lib_load_win_py38
Fix the shared library load for Windows
2 parents 3bf089b + 33a48cc commit 2096d6a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

chromaprint.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import sys
88
import ctypes
9+
import ctypes.util
910

1011
if sys.version_info[0] >= 3:
1112
BUFFER_TYPES = (memoryview, bytearray,)
@@ -31,9 +32,19 @@ def _guess_lib_name():
3132
return ('libchromaprint.so.1', 'libchromaprint.so.0')
3233

3334

35+
def _load_library(name):
36+
if sys.platform == 'win32':
37+
try:
38+
return ctypes.cdll.LoadLibrary(ctypes.util.find_library(name))
39+
except TypeError:
40+
raise OSError()
41+
else:
42+
return ctypes.cdll.LoadLibrary(name)
43+
44+
3445
for name in _guess_lib_name():
3546
try:
36-
_libchromaprint = ctypes.cdll.LoadLibrary(name)
47+
_libchromaprint = _load_library(name)
3748
break
3849
except OSError:
3950
pass

0 commit comments

Comments
 (0)