Skip to content

Commit

Permalink
Hooks: hook-usb: Resolve library name reported by usb.backend.
Browse files Browse the repository at this point in the history
hook-usb.py "asks" pyusb which library to pack by inspecting
usb.backend. This only results in a library name (e.g libusb-1.0.so.0),
which is sufficient for ctypes to load the library, but not enough for
pyinstaller to find the file and pack it. This commit solves this problem
by using _resolveCtypesImports to figure out the full path to the file
pyusb loads.

Fixes #2633
  • Loading branch information
themadinventor authored and htgoebel committed Feb 25, 2018
1 parent d4798a9 commit 4218c19
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion PyInstaller/hooks/hook-usb.py
Expand Up @@ -40,7 +40,9 @@
binaries = []
for usblib in [getattr(usb.backend, be)._lib for be in backends]:
if usblib is not None:
binaries = [(usblib._name, '')]
binaries = _resolveCtypesImports([os.path.basename(usblib._name)])
assert len(binaries[0]) == 3
binaries = [(binaries[0][1], '')]

except (ValueError, usb.core.USBError) as exc:
logger.warning("%s", exc)
Expand Down

0 comments on commit 4218c19

Please sign in to comment.