diff --git a/libusb/pyproject.toml b/libusb/pyproject.toml index 608eb9b..efe0b05 100644 --- a/libusb/pyproject.toml +++ b/libusb/pyproject.toml @@ -15,6 +15,6 @@ packages = ["libusb"] libusb = ["*.so", "install/**/*"] [tool.shim] -repo_url = "https://github.com/commaai/dependencies" -tag = "libusb/v1.0.29" +# IQ.Lvbs fork: wheels are vendored under wheels/ in this branch; setup.py extracts +# the platform-matched wheel locally instead of fetching from a release URL. datadir = "install" diff --git a/libusb/setup.py b/libusb/setup.py index 8b58b1c..ccff59d 100644 --- a/libusb/setup.py +++ b/libusb/setup.py @@ -1,11 +1,13 @@ -"""Shim setup.py: downloads pre-built wheels from GitHub Releases at install time.""" +"""Shim setup.py: extracts pre-built wheels vendored under wheels/ at install time. + +IQ.Lvbs fork of commaai/dependencies. Upstream downloads wheels from GitHub +release storage at install time; we vendor the wheel bytes inside the git +branch so the install works against a private gitea repo with no extra auth. +""" import os import platform -import time import zipfile from io import BytesIO -from urllib.error import URLError -from urllib.request import urlopen try: import tomllib @@ -19,13 +21,11 @@ _HERE = os.path.dirname(os.path.abspath(__file__)) with open(os.path.join(_HERE, "pyproject.toml"), "rb") as _f: _cfg = tomllib.load(_f) -REPO_URL = _cfg["tool"]["shim"]["repo_url"] -TAG = _cfg["tool"]["shim"]["tag"] DATADIR = _cfg["tool"]["shim"]["datadir"] VERSION = _cfg["project"]["version"] MODULE = _cfg["project"]["name"].replace("-", "_") -# all top-level packages bundled in this wheel (e.g. acados + casadi). +# all top-level packages bundled in this wheel. # `packages` may be a flat list or a dict with find.include patterns. _pkgs = _cfg.get("tool", {}).get("setuptools", {}).get("packages", [f"{MODULE}*"]) if isinstance(_pkgs, list): @@ -48,37 +48,32 @@ class InstallPrebuilt(build_py): module_dir = os.path.join(_HERE, MODULE) data_dir = os.path.join(module_dir, DATADIR) - if not os.path.exists(os.path.join(data_dir, "bin")): + if not os.path.exists(os.path.join(data_dir, "lib")) and not os.path.exists(os.path.join(data_dir, "bin")): key = (platform.system(), platform.machine()) plat = PLATFORM_MAP.get(key) if plat is None: raise RuntimeError(f"unsupported platform: {key}") - whl_names = [ + candidates = [ f"{MODULE}-{VERSION}-py3-none-{plat}.whl", f"{MODULE}-{VERSION}-py3-none-any.whl", ] - - raw = None - for whl_name in whl_names: - url = f"{REPO_URL}/releases/download/{TAG}/{whl_name}" - print(f"Downloading {url} ...") - for attempt in range(3): - try: - raw = urlopen(url, timeout=60).read() - break - except (URLError, OSError) as e: - if attempt == 2: - if whl_name == whl_names[-1]: - raise - break - wait = 2 ** attempt - print(f"Download failed ({e}), retrying in {wait}s ...") - time.sleep(wait) - if raw is not None: + whl_path = None + wheels_dir = os.path.join(_HERE, "wheels") + for name in candidates: + candidate = os.path.join(wheels_dir, name) + if os.path.exists(candidate): + whl_path = candidate break + if whl_path is None: + raise RuntimeError( + f"vendored wheel not found for platform {key} under {wheels_dir} " + f"(looked for: {', '.join(candidates)})" + ) - print("Extracting wheel ...") + print(f"Extracting vendored wheel {whl_path} ...") + with open(whl_path, "rb") as f: + raw = f.read() with zipfile.ZipFile(BytesIO(raw)) as zf: purelib_data = f"{MODULE}-{VERSION}.data/purelib/" for info in zf.infolist(): diff --git a/libusb/wheels/libusb-1.0.29-py3-none-linux_aarch64.whl b/libusb/wheels/libusb-1.0.29-py3-none-linux_aarch64.whl new file mode 100644 index 0000000..4c89424 Binary files /dev/null and b/libusb/wheels/libusb-1.0.29-py3-none-linux_aarch64.whl differ diff --git a/libusb/wheels/libusb-1.0.29-py3-none-linux_x86_64.whl b/libusb/wheels/libusb-1.0.29-py3-none-linux_x86_64.whl new file mode 100644 index 0000000..fbeb701 Binary files /dev/null and b/libusb/wheels/libusb-1.0.29-py3-none-linux_x86_64.whl differ diff --git a/libusb/wheels/libusb-1.0.29-py3-none-macosx_11_0_arm64.whl b/libusb/wheels/libusb-1.0.29-py3-none-macosx_11_0_arm64.whl new file mode 100644 index 0000000..9d6816a Binary files /dev/null and b/libusb/wheels/libusb-1.0.29-py3-none-macosx_11_0_arm64.whl differ