You've already forked macports-ports
mirror of
https://github.com/macports/macports-ports.git
synced 2026-07-12 18:20:25 -07:00
44 lines
1.1 KiB
Diff
44 lines
1.1 KiB
Diff
--- hid/__init__.py.orig 2022-12-15 21:22:07.000000000 +0600
|
|
+++ hid/__init__.py 2022-12-15 21:49:43.000000000 +0600
|
|
@@ -1,12 +1,13 @@
|
|
import os
|
|
import ctypes
|
|
+from ctypes import util
|
|
import atexit
|
|
|
|
__all__ = ['HIDException', 'DeviceInfo', 'Device', 'enumerate']
|
|
|
|
|
|
hidapi = None
|
|
-library_paths = (
|
|
+library_names = (
|
|
'libhidapi-hidraw.so',
|
|
'libhidapi-hidraw.so.0',
|
|
'libhidapi-libusb.so',
|
|
@@ -15,18 +16,20 @@
|
|
'libhidapi-iohidmanager.so.0',
|
|
'libhidapi.dylib',
|
|
'hidapi.dll',
|
|
- 'libhidapi-0.dll'
|
|
+ 'libhidapi-0.dll',
|
|
)
|
|
|
|
-for lib in library_paths:
|
|
+for libname in library_names:
|
|
try:
|
|
- hidapi = ctypes.cdll.LoadLibrary(lib)
|
|
- break
|
|
+ libpath = util.find_library(libname)
|
|
+ if libpath:
|
|
+ hidapi = ctypes.cdll.LoadLibrary(libpath)
|
|
+ break
|
|
except OSError:
|
|
pass
|
|
else:
|
|
error = "Unable to load any of the following libraries:{}"\
|
|
- .format(' '.join(library_paths))
|
|
+ .format(' '.join(library_names))
|
|
raise ImportError(error)
|
|
|
|
|