diff --git a/pyproject.toml b/pyproject.toml index 7a891445..9882f7ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ classifiers = [ ] dependencies = [ "libusb1", + "libusb-package", "opendbc @ git+https://github.com/commaai/opendbc.git@master#egg=opendbc", # runtime dependency on comma four diff --git a/python/__init__.py b/python/__init__.py index 4ede7517..248d98bb 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -6,6 +6,7 @@ import usb1 import struct import hashlib import binascii +import ctypes from functools import wraps, partial from itertools import accumulate @@ -18,6 +19,14 @@ from .spi import PandaSpiHandle, PandaSpiException, PandaProtocolMismatch from .usb import PandaUsbHandle from .utils import logger +# load libusb from pip package +try: + import libusb_package + usb1._libusb1.loadLibrary(ctypes.CDLL(str(libusb_package.get_library_path()))) +except ImportError: + # TODO: remove this on next AGNOS update + pass + __version__ = '0.0.10' CANPACKET_HEAD_SIZE = 0x6 diff --git a/setup.sh b/setup.sh index 1cb6260d..13308a5b 100755 --- a/setup.sh +++ b/setup.sh @@ -18,7 +18,6 @@ elif [[ $PLATFORM == "Linux" ]]; then sudo apt-get install -y --no-install-recommends \ curl ca-certificates gcc git \ - libusb-1.0-0 \ python3-dev else echo "WARNING: unsupported platform. skipping apt/brew install."