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 <noreply@anthropic.com>

* fix agnos

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Adeeb Shihadeh
2026-02-28 15:00:47 -08:00
committed by GitHub
parent 0faafa1d91
commit b606044763
3 changed files with 10 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ classifiers = [
] ]
dependencies = [ dependencies = [
"libusb1", "libusb1",
"libusb-package",
"opendbc @ git+https://github.com/commaai/opendbc.git@master#egg=opendbc", "opendbc @ git+https://github.com/commaai/opendbc.git@master#egg=opendbc",
# runtime dependency on comma four # runtime dependency on comma four

View File

@@ -6,6 +6,7 @@ import usb1
import struct import struct
import hashlib import hashlib
import binascii import binascii
import ctypes
from functools import wraps, partial from functools import wraps, partial
from itertools import accumulate from itertools import accumulate
@@ -18,6 +19,14 @@ from .spi import PandaSpiHandle, PandaSpiException, PandaProtocolMismatch
from .usb import PandaUsbHandle from .usb import PandaUsbHandle
from .utils import logger 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' __version__ = '0.0.10'
CANPACKET_HEAD_SIZE = 0x6 CANPACKET_HEAD_SIZE = 0x6

View File

@@ -18,7 +18,6 @@ elif [[ $PLATFORM == "Linux" ]]; then
sudo apt-get install -y --no-install-recommends \ sudo apt-get install -y --no-install-recommends \
curl ca-certificates gcc git \ curl ca-certificates gcc git \
libusb-1.0-0 \
python3-dev python3-dev
else else
echo "WARNING: unsupported platform. skipping apt/brew install." echo "WARNING: unsupported platform. skipping apt/brew install."