IQ.Lvbs: vendor libusb wheels in branch; install from local files
Replaces the upstream GitHub-Releases-fetch shim with a local-wheel shim so the package installs cleanly from a private gitea repo over SSH (no HTTPS download / token plumbing required at install time).
This commit is contained in:
@@ -15,6 +15,6 @@ packages = ["libusb"]
|
|||||||
libusb = ["*.so", "install/**/*"]
|
libusb = ["*.so", "install/**/*"]
|
||||||
|
|
||||||
[tool.shim]
|
[tool.shim]
|
||||||
repo_url = "https://github.com/commaai/dependencies"
|
# IQ.Lvbs fork: wheels are vendored under wheels/ in this branch; setup.py extracts
|
||||||
tag = "libusb/v1.0.29"
|
# the platform-matched wheel locally instead of fetching from a release URL.
|
||||||
datadir = "install"
|
datadir = "install"
|
||||||
|
|||||||
@@ -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 os
|
||||||
import platform
|
import platform
|
||||||
import time
|
|
||||||
import zipfile
|
import zipfile
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from urllib.error import URLError
|
|
||||||
from urllib.request import urlopen
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import tomllib
|
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:
|
with open(os.path.join(_HERE, "pyproject.toml"), "rb") as _f:
|
||||||
_cfg = tomllib.load(_f)
|
_cfg = tomllib.load(_f)
|
||||||
|
|
||||||
REPO_URL = _cfg["tool"]["shim"]["repo_url"]
|
|
||||||
TAG = _cfg["tool"]["shim"]["tag"]
|
|
||||||
DATADIR = _cfg["tool"]["shim"]["datadir"]
|
DATADIR = _cfg["tool"]["shim"]["datadir"]
|
||||||
VERSION = _cfg["project"]["version"]
|
VERSION = _cfg["project"]["version"]
|
||||||
MODULE = _cfg["project"]["name"].replace("-", "_")
|
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.
|
# `packages` may be a flat list or a dict with find.include patterns.
|
||||||
_pkgs = _cfg.get("tool", {}).get("setuptools", {}).get("packages", [f"{MODULE}*"])
|
_pkgs = _cfg.get("tool", {}).get("setuptools", {}).get("packages", [f"{MODULE}*"])
|
||||||
if isinstance(_pkgs, list):
|
if isinstance(_pkgs, list):
|
||||||
@@ -48,37 +48,32 @@ class InstallPrebuilt(build_py):
|
|||||||
module_dir = os.path.join(_HERE, MODULE)
|
module_dir = os.path.join(_HERE, MODULE)
|
||||||
data_dir = os.path.join(module_dir, DATADIR)
|
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())
|
key = (platform.system(), platform.machine())
|
||||||
plat = PLATFORM_MAP.get(key)
|
plat = PLATFORM_MAP.get(key)
|
||||||
if plat is None:
|
if plat is None:
|
||||||
raise RuntimeError(f"unsupported platform: {key}")
|
raise RuntimeError(f"unsupported platform: {key}")
|
||||||
|
|
||||||
whl_names = [
|
candidates = [
|
||||||
f"{MODULE}-{VERSION}-py3-none-{plat}.whl",
|
f"{MODULE}-{VERSION}-py3-none-{plat}.whl",
|
||||||
f"{MODULE}-{VERSION}-py3-none-any.whl",
|
f"{MODULE}-{VERSION}-py3-none-any.whl",
|
||||||
]
|
]
|
||||||
|
whl_path = None
|
||||||
raw = None
|
wheels_dir = os.path.join(_HERE, "wheels")
|
||||||
for whl_name in whl_names:
|
for name in candidates:
|
||||||
url = f"{REPO_URL}/releases/download/{TAG}/{whl_name}"
|
candidate = os.path.join(wheels_dir, name)
|
||||||
print(f"Downloading {url} ...")
|
if os.path.exists(candidate):
|
||||||
for attempt in range(3):
|
whl_path = candidate
|
||||||
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:
|
|
||||||
break
|
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:
|
with zipfile.ZipFile(BytesIO(raw)) as zf:
|
||||||
purelib_data = f"{MODULE}-{VERSION}.data/purelib/"
|
purelib_data = f"{MODULE}-{VERSION}.data/purelib/"
|
||||||
for info in zf.infolist():
|
for info in zf.infolist():
|
||||||
|
|||||||
BIN
libusb/wheels/libusb-1.0.29-py3-none-linux_aarch64.whl
Normal file
BIN
libusb/wheels/libusb-1.0.29-py3-none-linux_aarch64.whl
Normal file
Binary file not shown.
BIN
libusb/wheels/libusb-1.0.29-py3-none-linux_x86_64.whl
Normal file
BIN
libusb/wheels/libusb-1.0.29-py3-none-linux_x86_64.whl
Normal file
Binary file not shown.
BIN
libusb/wheels/libusb-1.0.29-py3-none-macosx_11_0_arm64.whl
Normal file
BIN
libusb/wheels/libusb-1.0.29-py3-none-macosx_11_0_arm64.whl
Normal file
Binary file not shown.
Reference in New Issue
Block a user