From b6060447631f9815c4c1d9ce7d61c103ed9edfcc Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 28 Feb 2026 15:00:47 -0800 Subject: [PATCH] install libusb from pip (#2351) * install libusb from pip Use libusb-package to bundle libusb as a Python dependency instead of requiring it as a system package. This simplifies setup on all platforms. Co-Authored-By: Claude Opus 4.6 * fix agnos --------- Co-authored-by: Claude Opus 4.6 --- pyproject.toml | 1 + python/__init__.py | 9 +++++++++ setup.sh | 1 - 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7a8914458..9882f7cec 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 4ede7517d..248d98bbd 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 1cb6260d7..13308a5bd 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."