Merge pull request #104 from google/gbg/fix-windll-load

fix libusb loading on Windows
This commit is contained in:
Gilles Boccon-Gibod
2022-12-20 08:05:57 -08:00
committed by GitHub
+2 -1
View File
@@ -46,8 +46,9 @@ def load_libusb():
when usb1.USBContext is created. when usb1.USBContext is created.
''' '''
if libusb_path := libusb_package.get_library_path(): if libusb_path := libusb_package.get_library_path():
logger.debug(f'loading libusb library at {libusb_path}')
dll_loader = ctypes.WinDLL if platform.system() == 'Windows' else ctypes.CDLL dll_loader = ctypes.WinDLL if platform.system() == 'Windows' else ctypes.CDLL
libusb_dll = dll_loader(libusb_path, use_errno=True, use_last_error=True) libusb_dll = dll_loader(str(libusb_path), use_errno=True, use_last_error=True)
usb1.loadLibrary(libusb_dll) usb1.loadLibrary(libusb_dll)