1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
diff --git a/usb1/_libusb1.py b/usb1/_libusb1.py
index 42b01e9..36f2d16 100644
--- a/usb1/_libusb1.py
+++ b/usb1/_libusb1.py
@@ -172,64 +172,13 @@ else:
LIBUSB_CALL_FUNCTYPE = CFUNCTYPE
def __getLibrary():
- my_dir = os.path.dirname(__file__)
system = platform.system()
- # If this is a binary wheel, try to use an integrated libusb first.
- # To use the libusb from the Python installation or the OS, install
- # from sdist:
- # > pip install --no-binary :all: libusb1
if system == 'Windows':
dll_loader = ctypes.WinDLL
- libusb_list = [
- os.path.join(my_dir, 'libusb-1.0.dll'),
- 'libusb-1.0.dll',
- ]
- find_library = None
else:
dll_loader = CDLL
- if system == 'Darwin':
- libusb_list = [
- os.path.join(my_dir, 'libusb-1.0.dylib'),
- 'libusb-1.0.dylib',
- # macport standard path
- '/opt/local/lib/libusb-1.0.dylib',
- # fink standard path
- '/sw/lib/libusb-1.0.dylib',
- # homebrew standard path for symlink (Apple M1 Silicon)
- '/opt/homebrew/opt/libusb/lib/libusb-1.0.dylib',
- ]
- find_library = None
- else:
- # .so.0 should be the optimal suffix
- # .so is for BBB, especially if libusb-1.0.so was bundled in some
- # uses of this module.
- libusb_list = [
- os.path.join(my_dir, 'libusb-1.0.so.0'),
- os.path.join(my_dir, 'libusb-1.0.so'),
- 'libusb-1.0.so.0',
- 'libusb-1.0.so',
- ]
- find_library = (
- # libusb.so.2 on FreeBSD: load('libusb.so') would work fine, but...
- # libusb.so.2debian on Debian GNU/kFreeBSD: here it wouldn't work.
- 'usb'
- if 'FreeBSD' in system else
- 'usb-1.0'
- )
- for filename in libusb_list:
- try:
- return dll_loader(filename, use_errno=True, use_last_error=True)
- except OSError:
- pass
- if find_library is not None:
- filename = ctypes.util.find_library(find_library)
- if filename is not None:
- return dll_loader(filename, use_errno=True, use_last_error=True)
- raise OSError(
- errno.ENOENT,
- 'cannot find a suitable libusb-1.0',
- libusb_list,
- )
+
+ return dll_loader("@libusb@", use_errno=True, use_last_error=True)
__load_lock = Lock()
__loaded = False
|