diff --git a/.dagger/src/voicestudio/main.py b/.dagger/src/voicestudio/main.py index 780ebd3e6..d4795cbfc 100644 --- a/.dagger/src/voicestudio/main.py +++ b/.dagger/src/voicestudio/main.py @@ -106,7 +106,7 @@ class Voicestudio: .with_env_variable("UV_HTTP_RETRIES", "5") .with_directory( "/app", - source.filter(include=["pyproject.toml", "uv.lock", "scripts/uv-sync-retry.sh", ".python-version"]), + source.filter(include=["pyproject.toml", "uv.lock", "scripts/uv-sync-retry.sh", ".python-version", "vendor/wheels/**"]), ) .with_exec(sync + ["--no-install-project"]) .with_directory("/app", source) diff --git a/.gitattributes b/.gitattributes index 865612b39..5437b6bfe 100644 --- a/.gitattributes +++ b/.gitattributes @@ -27,3 +27,6 @@ mobile/android/core/designsystem/src/main/kotlin/com/voicestudio/mobile/designsy # Pinned upstream MP3 encoder; provenance and checksums are reviewed separately. mobile/ios/VoiceStudioKit/Sources/VSNative/Lame/** text eol=lf linguist-vendored mobile/native/ios/patches/*.patch text eol=lf + +# Vendored wheels are hash-pinned in uv.lock: never rewrite line endings. +*.whl binary diff --git a/.github/workflows/install-smoke.yml b/.github/workflows/install-smoke.yml index 0e98db60b..403289b70 100644 --- a/.github/workflows/install-smoke.yml +++ b/.github/workflows/install-smoke.yml @@ -18,6 +18,7 @@ on: - 'bun.lock' - 'uv.lock' - 'pyproject.toml' + - 'vendor/wheels/**' - 'config/**' - 'store/**' - 'electron/package.json' @@ -55,6 +56,7 @@ on: - 'bun.lock' - 'uv.lock' - 'pyproject.toml' + - 'vendor/wheels/**' - 'config/**' - 'store/**' - 'electron/package.json' diff --git a/changelog.d/4268.fixed.md b/changelog.d/4268.fixed.md new file mode 100644 index 000000000..9c2b6b248 --- /dev/null +++ b/changelog.d/4268.fixed.md @@ -0,0 +1 @@ +First-run setup on Windows no longer fails building docopt, antlr4 and dora-search from source (#4268) diff --git a/deploy/Dockerfile b/deploy/Dockerfile index ccad65b11..b093b9563 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -107,6 +107,8 @@ RUN python3 -m pip install --no-cache-dir uv # Copy python packaging specs (README.md required by hatchling metadata) COPY pyproject.toml uv.lock README.md ./ +# [tool.uv.sources] points source-only deps at these wheels (#4253). +COPY vendor/wheels/ ./vendor/wheels/ COPY deploy/torch-constraints.txt ./deploy/torch-constraints.txt COPY deploy/uv-overrides.txt ./deploy/uv-overrides.txt COPY deploy/security-constraints.txt deploy/security_floors.py ./deploy/ diff --git a/electron/electron-builder.config.mjs b/electron/electron-builder.config.mjs index d0aa3da1e..54064681b 100644 --- a/electron/electron-builder.config.mjs +++ b/electron/electron-builder.config.mjs @@ -203,6 +203,8 @@ export default { }, { from: '../pyproject.toml', to: 'pyproject.toml' }, { from: '../uv.lock', to: 'uv.lock' }, + // Wheels for packages PyPI ships only as source; uv.lock points at them (#4253). + { from: '../vendor/wheels', to: 'vendor/wheels', filter: ['*.whl', 'LICENSE-*.txt'] }, { from: '../scripts/windows-rocm-recipe.json', to: 'scripts/windows-rocm-recipe.json' }, { from: '../scripts/smoke_windows_rocm.py', to: 'scripts/smoke_windows_rocm.py' }, { from: '../README.md', to: 'README.md' }, diff --git a/electron/src/main/runtime-legacy-cuda.test.ts b/electron/src/main/runtime-legacy-cuda.test.ts index 5a6de6a29..289d9cecd 100644 --- a/electron/src/main/runtime-legacy-cuda.test.ts +++ b/electron/src/main/runtime-legacy-cuda.test.ts @@ -132,6 +132,7 @@ async function fixture() { await mkdir(join(bundle, 'frontend', 'dist'), { recursive: true }); await mkdir(join(bundle, 'omnivoice')); await mkdir(join(bundle, 'scripts')); + await mkdir(join(bundle, 'vendor', 'wheels'), { recursive: true }); for (const file of [ 'pyproject.toml', 'README.md', @@ -142,6 +143,7 @@ async function fixture() { 'omnivoice/__init__.py', 'scripts/windows-rocm-recipe.json', 'scripts/smoke_windows_rocm.py', + 'vendor/wheels/docopt-0.6.2-py2.py3-none-any.whl', ]) { await writeFile(join(bundle, file), file); } diff --git a/electron/src/main/runtime-project.test.ts b/electron/src/main/runtime-project.test.ts index 3354b3b28..8a7d6554d 100644 --- a/electron/src/main/runtime-project.test.ts +++ b/electron/src/main/runtime-project.test.ts @@ -85,6 +85,7 @@ async function fixture() { await mkdir(join(bundle, 'frontend', 'dist'), { recursive: true }); await mkdir(join(bundle, 'omnivoice')); await mkdir(join(bundle, 'scripts')); + await mkdir(join(bundle, 'vendor', 'wheels'), { recursive: true }); for (const file of [ 'pyproject.toml', 'uv.lock', @@ -96,6 +97,7 @@ async function fixture() { 'omnivoice/__init__.py', 'scripts/windows-rocm-recipe.json', 'scripts/smoke_windows_rocm.py', + 'vendor/wheels/docopt-0.6.2-py2.py3-none-any.whl', ]) { await writeFile(join(bundle, file), file); } diff --git a/electron/src/main/runtime-project.ts b/electron/src/main/runtime-project.ts index 72cf9a41d..032eedfa4 100644 --- a/electron/src/main/runtime-project.ts +++ b/electron/src/main/runtime-project.ts @@ -68,6 +68,7 @@ const SOURCES = [ 'omnivoice', 'pyproject.toml', 'uv.lock', + 'vendor/wheels', 'scripts/windows-rocm-recipe.json', 'scripts/smoke_windows_rocm.py', 'README.md', diff --git a/electron/src/main/runtime-torch-variant.test.ts b/electron/src/main/runtime-torch-variant.test.ts index bc1d1152a..980ecfc93 100644 --- a/electron/src/main/runtime-torch-variant.test.ts +++ b/electron/src/main/runtime-torch-variant.test.ts @@ -58,6 +58,7 @@ async function fixture() { await mkdir(join(bundle, 'frontend', 'dist'), { recursive: true }); await mkdir(join(bundle, 'omnivoice')); await mkdir(join(bundle, 'scripts')); + await mkdir(join(bundle, 'vendor', 'wheels'), { recursive: true }); for (const file of [ 'pyproject.toml', 'README.md', @@ -68,6 +69,7 @@ async function fixture() { 'omnivoice/__init__.py', 'scripts/windows-rocm-recipe.json', 'scripts/smoke_windows_rocm.py', + 'vendor/wheels/docopt-0.6.2-py2.py3-none-any.whl', ]) { await writeFile(join(bundle, file), file); } diff --git a/electron/src/main/runtime-windows-rocm.fixture.ts b/electron/src/main/runtime-windows-rocm.fixture.ts index e93e3749d..a2433fdf7 100644 --- a/electron/src/main/runtime-windows-rocm.fixture.ts +++ b/electron/src/main/runtime-windows-rocm.fixture.ts @@ -65,13 +65,14 @@ export async function fixture() { roots.push(root); const bundle = join(root, 'bundle'), project = join(root, 'runtime'); - for (const name of ['backend', 'config', 'omnivoice', 'scripts']) + for (const name of ['backend', 'config', 'omnivoice', 'scripts', 'vendor/wheels']) await mkdir(join(bundle, name), { recursive: true }); for (const name of ['pyproject.toml', 'README.md', 'LICENSE']) await writeFile(join(bundle, name), name); await writeFile(join(bundle, 'uv.lock'), 'name = "nvidia-cudnn-cu12"\nname = "nvidia-ml-py"\n'); await writeFile(join(bundle, 'scripts/windows-rocm-recipe.json'), recipe); await writeFile(join(bundle, 'scripts/smoke_windows_rocm.py'), '# local smoke'); + await writeFile(join(bundle, 'vendor/wheels/docopt-0.6.2-py2.py3-none-any.whl'), 'wheel'); return { bundle, project }; } export async function interpreter(project: string) { diff --git a/flake.nix b/flake.nix index a4d3682fe..10a0e6aca 100644 --- a/flake.nix +++ b/flake.nix @@ -877,6 +877,10 @@ install -Dm644 pyproject.toml "$resources/pyproject.toml" install -Dm644 uv.lock "$resources/uv.lock" + # uv.lock points source-only deps at these wheels (#4253). + mkdir -p "$resources/vendor/wheels" + install -m644 vendor/wheels/*.whl "$resources/vendor/wheels/" + install -m644 vendor/wheels/LICENSE-*.txt "$resources/vendor/wheels/" install -Dm644 README.md "$resources/README.md" install -Dm644 LICENSE "$resources/LICENSE" install -Dm644 LICENSE-NOTICE.md "$resources/LICENSE-NOTICE.md" @@ -1136,6 +1140,7 @@ frontend/dist/index.html \ pyproject.toml \ uv.lock \ + vendor/wheels \ README.md \ LICENSE \ LICENSE-NOTICE.md \ diff --git a/pyproject.toml b/pyproject.toml index bdb72cb14..217871b1c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -97,6 +97,12 @@ dependencies = [ # mlx-whisper/mlx-audio (depends on mlx — no wheels elsewhere). "parakeet-mlx>=0.5.2 ; sys_platform == 'darwin' and platform_machine == 'arm64'", "demucs>=4.0.1", + # Source-only on PyPI (no wheel) and pulled in transitively. Declared here + # so [tool.uv.sources] can point them at vendor/wheels/ (#4253): building an + # sdist during first-run setup crashes setuptools on some Windows hosts. + "docopt==0.6.2", + "antlr4-python3-runtime==4.9.3", + "dora-search==0.1.12", "yt-dlp>=2026.7.4", # >=1.16: alembic.ini relies on path_separator=os (new in 1.16.0), which # older alembic silently ignores and then colon-splits C:\ paths / @@ -270,6 +276,11 @@ Documentation = "https://github.com/debpalash/VoiceStudio/tree/main/docs" "Upstream TTS Model" = "https://github.com/k2-fsa/OmniVoice" [tool.uv.sources] +# Wheels built from the PyPI sdists (pure Python, unmodified) so setup never +# compiles on a user's machine (#4253). tests/test_lock_wheel_only.py guards it. +docopt = { path = "vendor/wheels/docopt-0.6.2-py2.py3-none-any.whl" } +antlr4-python3-runtime = { path = "vendor/wheels/antlr4_python3_runtime-4.9.3-py3-none-any.whl" } +dora-search = { path = "vendor/wheels/dora_search-0.1.12-py3-none-any.whl" } # Keep both compute variants in the lockfile. Source and packaged setup select # CPU when no NVIDIA driver is detected; plain `uv sync` preserves the CUDA default. # macOS keeps the PyPI build (including MPS) regardless of the selected group. diff --git a/scripts/build_vendored_wheels.py b/scripts/build_vendored_wheels.py new file mode 100644 index 000000000..fb68d034a --- /dev/null +++ b/scripts/build_vendored_wheels.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 +"""Rebuild, or verify, the wheels vendored under ``vendor/wheels/`` (#4253). + +Each wheel is built from the PyPI sdist recorded in ``vendor/wheels/SOURCES.json`` +(URL plus sha256, copied from the former ``uv.lock`` entry) with the build +backend pinned in ``vendor/wheels/build-constraints.txt``. + + uv run python scripts/build_vendored_wheels.py # rebuild all wheels + uv run python scripts/build_vendored_wheels.py --verify # rebuild to a temp dir and + # compare every file's content + +After a rebuild run ``uv lock`` so the wheel hashes in ``uv.lock`` follow. +Downloads only the sdist URLs listed in SOURCES.json (the URLs ``uv.lock`` used +to pin); nothing else. +""" + +from __future__ import annotations + +import argparse +import hashlib +import json +import subprocess +import sys +import tarfile +import tempfile +import urllib.request +import zipfile +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +WHEELS = ROOT / "vendor" / "wheels" +SOURCES = WHEELS / "SOURCES.json" +CONSTRAINTS = WHEELS / "build-constraints.txt" + + +def _build(entry: dict, work: Path, out: Path) -> Path: + sdist = work / entry["sdist_url"].rsplit("/", 1)[1] + with urllib.request.urlopen(entry["sdist_url"], timeout=60) as response: # noqa: S310 - pinned https URL + data = response.read() + digest = hashlib.sha256(data).hexdigest() + if digest != entry["sdist_sha256"]: + raise SystemExit(f"{entry['name']}: sdist sha256 {digest} != pinned {entry['sdist_sha256']}") + sdist.write_bytes(data) + src = work / entry["name"] + with tarfile.open(sdist) as tar: + tar.extractall(src, filter="data") + (project,) = [p for p in src.iterdir() if p.is_dir()] + subprocess.run( + ["uv", "build", "--wheel", "--out-dir", str(out), "--build-constraints", str(CONSTRAINTS), str(project)], + check=True, + ) + (wheel,) = out.glob(f"{entry['name'].replace('-', '_')}-{entry['version']}-*.whl") + return wheel + + +def _contents(path: Path) -> dict[str, bytes]: + with zipfile.ZipFile(path) as z: + return {n: z.read(n) for n in z.namelist() if not n.endswith("/RECORD")} + + +def main() -> int: + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument("--verify", action="store_true", help="compare to the committed wheels, change nothing") + args = parser.parse_args() + entries = json.loads(SOURCES.read_text(encoding="utf-8"))["wheels"] + bad = 0 + for entry in entries: + with tempfile.TemporaryDirectory() as tmp: + work, out = Path(tmp, "work"), Path(tmp, "out") + work.mkdir() + built = _build(entry, work, out) + target = WHEELS / entry["wheel"] + if args.verify: + same = _contents(built) == _contents(target) + print(f"{entry['name']}: {'identical contents' if same else 'DIFFERS'}") + bad += not same + else: + if built.name != entry["wheel"]: + raise SystemExit(f"built {built.name}, SOURCES.json expects {entry['wheel']}") + target.write_bytes(built.read_bytes()) + print(f"wrote {target.relative_to(ROOT)}") + return 1 if bad else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_cpu_install.py b/tests/test_cpu_install.py index 3b0007dc6..14799d732 100644 --- a/tests/test_cpu_install.py +++ b/tests/test_cpu_install.py @@ -29,10 +29,14 @@ def _frozen_requirements(group, tmp_path): args, cwd=ROOT, text=True, capture_output=True, check=True, timeout=30, env={**os.environ, "UV_CACHE_DIR": str(tmp_path / "uv"), "UV_OFFLINE": "1"}, ) - return [ - Requirement(line) for line in result.stdout.splitlines() + lines = [ + line.strip() for line in result.stdout.splitlines() if line.strip() and not line.lstrip().startswith(("#", "-")) ] + # Vendored wheels (#4253) export as paths, not name-based requirements. + vendored = [line for line in lines if line.startswith("./vendor/wheels/")] + assert all(line.endswith(".whl") for line in vendored), vendored + return [Requirement(line) for line in lines if line not in vendored] @pytest.mark.parametrize("python_version", ["3.11", "3.12"]) diff --git a/tests/test_lock_wheel_only.py b/tests/test_lock_wheel_only.py new file mode 100644 index 000000000..fcb1ae256 --- /dev/null +++ b/tests/test_lock_wheel_only.py @@ -0,0 +1,140 @@ +"""First-run setup must never compile an sdist on a user's machine (#4253). + +`uv sync` builds any locked package that ships no wheel. On some Windows hosts +the build crashes setuptools (`Failed to build docopt==0.6.2`), which blocks +the runtime install and the backend never starts. Every package reachable from +the default install on Windows, macOS and Linux must therefore lock to a wheel. +Source-only PyPI packages are vendored as wheels under `vendor/wheels/` and +pointed at from `[tool.uv.sources]`. +""" + +from __future__ import annotations + +import tomllib +from pathlib import Path + +from packaging.markers import Marker +from packaging.utils import parse_wheel_filename +from urllib.parse import unquote + +ROOT = Path(__file__).resolve().parent.parent + +# Intel macOS runs the UI against a remote backend (README, docs/install/macos.md); +# its demucs 4.0.1 pin is never installed on Windows, Linux or Apple Silicon. +_ALLOWED_SDIST_ONLY: dict[tuple[str, str], str] = { + ("demucs", "4.0.1"): "Intel-Mac-only resolution; no Windows/Linux install", +} +# Packages with wheels everywhere except one platform: (name, version, sys_platform, machine). +_ALLOWED_PLATFORM_SDIST: dict[tuple[str, str, str, str], str] = { + ("sphn", "0.2.1", "linux", "aarch64"): ( + "upstream publishes no Linux ARM64 wheel; Linux ARM64 is a source-only target, " + "not a packaged installer" + ), +} + +_PLATFORMS = [ + {"sys_platform": "win32", "platform_machine": "AMD64", "os_name": "nt", "platform_system": "Windows"}, + {"sys_platform": "win32", "platform_machine": "ARM64", "os_name": "nt", "platform_system": "Windows"}, + {"sys_platform": "linux", "platform_machine": "x86_64", "os_name": "posix", "platform_system": "Linux"}, + {"sys_platform": "linux", "platform_machine": "aarch64", "os_name": "posix", "platform_system": "Linux"}, + {"sys_platform": "darwin", "platform_machine": "arm64", "os_name": "posix", "platform_system": "Darwin"}, +] +_PYTHONS = ["3.11", "3.12"] +_EXTRAS = ["group-9-omnivoice-cuda", "group-9-omnivoice-cpu"] + + +def _lock() -> dict: + return tomllib.loads((ROOT / "uv.lock").read_text(encoding="utf-8")) + + +def _reachable(lock: dict, env: dict[str, str], extra: str) -> set[tuple[str, str]]: + pkgs: dict[str, list[dict]] = {} + for p in lock["package"]: + pkgs.setdefault(p["name"], []).append(p) + root = next(p for p in lock["package"] if "editable" in p["source"] or "virtual" in p["source"]) + seen: set[tuple[str, str, str]] = set() + stack: list[tuple[dict, tuple[str, ...]]] = [(root, ())] + while stack: + pkg, extras = stack.pop() + deps = list(pkg.get("dependencies", [])) + # A dependency requested with extras also pulls that package's optional deps. + for name in extras: + deps += pkg.get("optional-dependencies", {}).get(name, []) + for dep in deps: + marker = dep.get("marker") + if marker and not Marker(marker).evaluate({**env, "extra": extra}): + continue + wanted = tuple(sorted(dep.get("extra", []))) + for cand in pkgs.get(dep["name"], []): + if "version" in dep and cand.get("version") != dep["version"]: + continue + key = (cand["name"], cand.get("version", ""), ",".join(wanted)) + if key not in seen: + seen.add(key) + stack.append((cand, wanted)) + return {(name, version) for name, version, _ in seen} + + +def _platform_tag_matches(tag: str, env: dict[str, str]) -> bool: + if tag == "any": + return True + system, machine = env["sys_platform"], env["platform_machine"] + if system == "win32": + # Windows ARM64 runs the x64 runtime under emulation when no ARM64 wheel exists. + return tag == "win_amd64" or (machine == "ARM64" and tag == "win_arm64") + if system == "darwin": + return tag.startswith("macosx_") and tag.endswith(("_arm64", "_universal2")) + arch = "x86_64" if machine == "x86_64" else "aarch64" + return tag.startswith(("manylinux", "musllinux", "linux_")) and tag.endswith(arch) + + +def _interpreter_tag_matches(interpreter: str, abi: str, py: str) -> bool: + nodot = py.replace(".", "") + if interpreter in {"py3", f"py{nodot}"}: + return True + if interpreter == f"cp{nodot}": + return True + # abi3 wheels built for an older CPython still load on newer ones. + return abi == "abi3" and interpreter.startswith("cp3") and int(interpreter[3:]) <= int(nodot[1:]) + + +def _has_wheel_for(pkg: dict, env: dict[str, str], py: str) -> bool: + for wheel in pkg.get("wheels", []): + name = unquote((wheel.get("url") or wheel.get("path") or wheel.get("filename") or "").rsplit("/", 1)[-1]) + try: + *_, tags = parse_wheel_filename(name) + except Exception: + continue + if any(_platform_tag_matches(t.platform, env) and _interpreter_tag_matches(t.interpreter, t.abi, py) + for t in tags): + return True + return False + + +def test_default_install_never_builds_an_sdist() -> None: + lock = _lock() + by_key = {(p["name"], p.get("version", "")): p for p in lock["package"]} + offenders: set[tuple[str, str]] = set() + for env in _PLATFORMS: + for py in _PYTHONS: + full = {**env, "python_version": py, "python_full_version": f"{py}.0", "implementation_name": "cpython"} + for extra in _EXTRAS: + for key in _reachable(lock, full, extra): + p = by_key[key] + platform_key = (*key, env["sys_platform"], env["platform_machine"]) + if (not _has_wheel_for(p, env, py) and key not in _ALLOWED_SDIST_ONLY + and platform_key not in _ALLOWED_PLATFORM_SDIST): + offenders.add(key) + assert not offenders, ( + f"locked without a wheel, so first-run setup would compile them: {sorted(offenders)}. " + "Vendor a wheel under vendor/wheels/ and add it to [tool.uv.sources] (#4253)." + ) + + +def test_vendored_wheels_are_shipped_with_the_app() -> None: + config = (ROOT / "electron" / "electron-builder.config.mjs").read_text(encoding="utf-8") + assert "vendor/wheels" in config, "packaged setup resolves path wheels relative to the bundled uv.lock" + for p in _lock()["package"]: + src = p["source"].get("path") + if src: + assert (ROOT / src).is_file(), f"{p['name']} points at missing {src}" diff --git a/tests/test_vendored_wheels.py b/tests/test_vendored_wheels.py new file mode 100644 index 000000000..eb01460ec --- /dev/null +++ b/tests/test_vendored_wheels.py @@ -0,0 +1,88 @@ +"""Vendored wheels (#4253) are verifiable offline. + +Contents versus the upstream sdist are checked by +`scripts/build_vendored_wheels.py --verify` (needs network). Here, with no +network: the wheel is the one uv.lock pins, its RECORD is consistent, it holds +only pure-Python/data files and the scripts the sdist declares, and its +METADATA names the locked package and version. +""" + +from __future__ import annotations + +import base64 +import csv +import hashlib +import io +import json +import tomllib +import zipfile +from email import message_from_string +from pathlib import Path + +import pytest + +ROOT = Path(__file__).resolve().parent.parent +WHEELS = ROOT / "vendor" / "wheels" +ENTRIES = json.loads((WHEELS / "SOURCES.json").read_text(encoding="utf-8"))["wheels"] +LOCK = tomllib.loads((ROOT / "uv.lock").read_text(encoding="utf-8")) + +_ALLOWED_SUFFIXES = {".py", ".yaml", ".typed", ".txt", ""} +_FORBIDDEN_SUFFIXES = {".so", ".pyd", ".dll", ".dylib", ".exe", ".pth", ".pyc", ".bat", ".cmd"} +# `.data/scripts/*` is only what the sdist's setup.py declares (antlr4's `pygrun`). +_DECLARED_SCRIPTS = {"antlr4-python3-runtime": {"antlr4_python3_runtime-4.9.3.data/scripts/pygrun"}} +# antlr4-python3-runtime 4.9.3's sdist ships no licence file (BSD-3-Clause in its METADATA). +_NO_UPSTREAM_LICENCE = {"antlr4-python3-runtime"} + + +def _locked(name: str) -> dict: + (pkg,) = [p for p in LOCK["package"] if p["name"] == name and "path" in p["source"]] + return pkg + + +def test_every_path_wheel_in_the_lock_is_recorded() -> None: + locked = {p["name"] for p in LOCK["package"] if "path" in p["source"]} + assert locked == {e["name"] for e in ENTRIES} + assert {p.name for p in WHEELS.glob("*.whl")} == {e["wheel"] for e in ENTRIES} + for e in ENTRIES: + assert e["sdist_url"].startswith("https://files.pythonhosted.org/") + assert len(e["sdist_sha256"]) == 64 + + +@pytest.mark.parametrize("entry", ENTRIES, ids=lambda e: e["name"]) +def test_wheel_is_the_locked_pure_python_wheel(entry: dict) -> None: + path = WHEELS / entry["wheel"] + pkg = _locked(entry["name"]) + assert pkg["version"] == entry["version"] + assert pkg["source"]["path"] == f"vendor/wheels/{entry['wheel']}" + assert [w["hash"] for w in pkg["wheels"]] == ["sha256:" + hashlib.sha256(path.read_bytes()).hexdigest()] + + with zipfile.ZipFile(path) as z: + names = [n for n in z.namelist() if not n.endswith("/")] + info = next(n for n in names if n.endswith(".dist-info/METADATA")) + meta = message_from_string(z.read(info).decode("utf-8")) + assert meta["Name"].lower().replace("_", "-") == entry["name"] + assert meta["Version"] == entry["version"] + assert "py3-none-any" in path.name or "py2.py3-none-any" in path.name + assert "Root-Is-Purelib: true" in z.read(next(n for n in names if n.endswith(".dist-info/WHEEL"))).decode() + + record_name = next(n for n in names if n.endswith(".dist-info/RECORD")) + record = {r[0]: r for r in csv.reader(io.StringIO(z.read(record_name).decode("utf-8"))) if r} + assert set(record) == set(names), "RECORD must list exactly the wheel's files" + for n in names: + if n == record_name: + continue + algo, _, digest = record[n][1].partition("=") + raw = hashlib.new(algo, z.read(n)).digest() + assert base64.urlsafe_b64encode(raw).rstrip(b"=").decode() == digest, n + assert int(record[n][2]) == len(z.read(n)), n + + for n in names: + suffix = Path(n).suffix + assert suffix not in _FORBIDDEN_SUFFIXES, f"native or startup code in {n}" + if n in _DECLARED_SCRIPTS.get(entry["name"], set()): + assert z.read(n).startswith(b"#!"), n + continue + assert ".data/" not in n, f"undeclared install-time file {n}" + assert suffix in _ALLOWED_SUFFIXES or ".dist-info/" in n, n + if entry["name"] not in _NO_UPSTREAM_LICENCE: + assert any(".dist-info/" in n and "LICENSE" in n for n in names), "keep the licence in dist-info" diff --git a/uv.lock b/uv.lock index ca76cb50b..b9966ea6a 100644 --- a/uv.lock +++ b/uv.lock @@ -359,8 +359,13 @@ wheels = [ [[package]] name = "antlr4-python3-runtime" version = "4.9.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/3e/38/7859ff46355f76f8d19459005ca000b6e7012f2f1ca597746cbcd1fbfe5e/antlr4-python3-runtime-4.9.3.tar.gz", hash = "sha256:f224469b4168294902bb1efa80a8bf7855f24c99aef99cbefc1bcd3cce77881b", size = 117034, upload-time = "2021-11-06T17:52:23.524Z" } +source = { path = "vendor/wheels/antlr4_python3_runtime-4.9.3-py3-none-any.whl" } +wheels = [ + { filename = "antlr4_python3_runtime-4.9.3-py3-none-any.whl", hash = "sha256:f3b63308b04ce4dbe4eb03da3a51cb731f22cc47031a31eddec1773ce36dccd5" }, +] + +[package.metadata] +requires-dist = [{ name = "typing", marker = "python_full_version < '3.5'" }] [[package]] name = "anyio" @@ -1509,21 +1514,46 @@ wheels = [ [[package]] name = "docopt" version = "0.6.2" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz", hash = "sha256:49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491", size = 25901, upload-time = "2014-06-16T11:18:57.406Z" } +source = { path = "vendor/wheels/docopt-0.6.2-py2.py3-none-any.whl" } +wheels = [ + { filename = "docopt-0.6.2-py2.py3-none-any.whl", hash = "sha256:93c7ad5474f8ff436b3a73b1d4e30e7c5307653afc15c373e3db0187a27a5c39" }, +] [[package]] name = "dora-search" version = "0.1.12" -source = { registry = "https://pypi.org/simple" } +source = { path = "vendor/wheels/dora_search-0.1.12-py3-none-any.whl" } dependencies = [ - { name = "omegaconf", marker = "(platform_machine == 'x86_64' and sys_platform == 'darwin') or (platform_machine != 'x86_64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform != 'darwin' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, - { name = "retrying", marker = "(platform_machine == 'x86_64' and sys_platform == 'darwin') or (platform_machine != 'x86_64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform != 'darwin' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, - { name = "submitit", marker = "(platform_machine == 'x86_64' and sys_platform == 'darwin') or (platform_machine != 'x86_64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform != 'darwin' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, - { name = "torch", version = "2.10.0", source = { registry = "https://pypi.org/simple" }, marker = "(platform_machine == 'x86_64' and sys_platform == 'darwin') or (platform_machine != 'x86_64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform != 'darwin' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, - { name = "treetable", marker = "(platform_machine == 'x86_64' and sys_platform == 'darwin') or (platform_machine != 'x86_64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform != 'darwin' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, + { name = "omegaconf" }, + { name = "retrying" }, + { name = "submitit" }, + { name = "torch", version = "2.10.0", source = { registry = "https://pypi.org/simple" }, marker = "(platform_machine == 'aarch64' and sys_platform == 'linux') or (platform_machine == 'arm64' and sys_platform == 'linux') or (sys_platform != 'linux' and sys_platform != 'win32') or (sys_platform == 'linux' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform == 'linux' and extra != 'group-9-omnivoice-cpu' and extra != 'group-9-omnivoice-cuda') or (sys_platform == 'win32' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform == 'win32' and extra != 'group-9-omnivoice-cpu' and extra != 'group-9-omnivoice-cuda')" }, + { name = "torch", version = "2.10.0+cpu", source = { registry = "https://download.pytorch.org/whl/cpu" }, marker = "(platform_machine != 'aarch64' and platform_machine != 'arm64' and sys_platform == 'linux' and extra == 'group-9-omnivoice-cpu') or (platform_machine == 'aarch64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (platform_machine == 'arm64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform == 'win32' and extra == 'group-9-omnivoice-cpu') or (sys_platform != 'linux' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, + { name = "torch", version = "2.10.0+cu128", source = { registry = "https://download.pytorch.org/whl/cu128" }, marker = "(platform_machine != 'aarch64' and platform_machine != 'arm64' and sys_platform == 'linux' and extra == 'group-9-omnivoice-cuda') or (platform_machine == 'aarch64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (platform_machine == 'arm64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform == 'win32' and extra == 'group-9-omnivoice-cuda') or (sys_platform != 'linux' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, + { name = "treetable" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/d5/9d/9a13947db237375486c0690f4741dd2b7e1eee20e0ffcb55dbd1b21cc600/dora_search-0.1.12.tar.gz", hash = "sha256:2956fd2c4c7e4b9a4830e83f0d4cf961be45cfba1a2f0570281e91d15ac516fb", size = 87111, upload-time = "2023-05-23T14:36:24.743Z" } +wheels = [ + { filename = "dora_search-0.1.12-py3-none-any.whl", hash = "sha256:303b6abca752dff7c75b4ecb82beced03fe4b77a1e838cd0c299ac66e18a4453" }, +] + +[package.metadata] +requires-dist = [ + { name = "coverage", marker = "extra == 'dev'" }, + { name = "flake8", marker = "extra == 'dev'" }, + { name = "hiplot", marker = "extra == 'dev'" }, + { name = "hydra-colorlog", marker = "extra == 'dev'" }, + { name = "hydra-core", marker = "extra == 'dev'" }, + { name = "mypy", marker = "extra == 'dev'" }, + { name = "omegaconf" }, + { name = "pdoc3", marker = "extra == 'dev'" }, + { name = "pytest", marker = "extra == 'dev'" }, + { name = "pytorch-lightning", marker = "extra == 'dev'" }, + { name = "retrying" }, + { name = "submitit" }, + { name = "torch" }, + { name = "treetable" }, +] +provides-extras = ["dev"] [[package]] name = "einops" @@ -4042,6 +4072,7 @@ source = { editable = "." } dependencies = [ { name = "accelerate" }, { name = "alembic" }, + { name = "antlr4-python3-runtime" }, { name = "argostranslate" }, { name = "audioop-lts", marker = "python_full_version >= '3.13' or (extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, { name = "audioseal" }, @@ -4049,6 +4080,8 @@ dependencies = [ { name = "cryptography" }, { name = "demucs", version = "4.0.1", source = { registry = "https://pypi.org/simple" }, marker = "(platform_machine == 'x86_64' and sys_platform == 'darwin') or (platform_machine != 'x86_64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform != 'darwin' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, { name = "demucs", version = "4.1.0", source = { registry = "https://pypi.org/simple" }, marker = "platform_machine != 'x86_64' or sys_platform != 'darwin' or (extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, + { name = "docopt" }, + { name = "dora-search" }, { name = "en-core-web-sm" }, { name = "fastapi" }, { name = "faster-whisper" }, @@ -4154,12 +4187,15 @@ dev = [ requires-dist = [ { name = "accelerate" }, { name = "alembic", specifier = ">=1.16" }, + { name = "antlr4-python3-runtime", path = "vendor/wheels/antlr4_python3_runtime-4.9.3-py3-none-any.whl" }, { name = "argostranslate", specifier = ">=1.9.0" }, { name = "audioop-lts", marker = "python_full_version >= '3.13'" }, { name = "audioseal", specifier = ">=0.1.3" }, { name = "boto3", specifier = ">=1.40" }, { name = "cryptography", specifier = ">=41" }, { name = "demucs", specifier = ">=4.0.1" }, + { name = "docopt", path = "vendor/wheels/docopt-0.6.2-py2.py3-none-any.whl" }, + { name = "dora-search", path = "vendor/wheels/dora_search-0.1.12-py3-none-any.whl" }, { name = "en-core-web-sm", url = "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl" }, { name = "fastapi", specifier = "<0.137" }, { name = "faster-whisper", specifier = ">=1.0.0" }, @@ -6794,8 +6830,8 @@ name = "submitit" version = "1.5.4" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "cloudpickle", marker = "(platform_machine == 'x86_64' and sys_platform == 'darwin') or (platform_machine != 'x86_64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform != 'darwin' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, - { name = "typing-extensions", marker = "(platform_machine == 'x86_64' and sys_platform == 'darwin') or (platform_machine != 'x86_64' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda') or (sys_platform != 'darwin' and extra == 'group-9-omnivoice-cpu' and extra == 'group-9-omnivoice-cuda')" }, + { name = "cloudpickle" }, + { name = "typing-extensions" }, ] sdist = { url = "https://files.pythonhosted.org/packages/47/86/497018fb3b74e71bef45df82762b176e6b3d159f29941c20d2f141ec4096/submitit-1.5.4.tar.gz", hash = "sha256:7100848bd1cdda79c7196e54ee830793ae75fd7adde0c5bef738d72360a07508", size = 81538, upload-time = "2025-12-17T19:20:03.396Z" } wheels = [ diff --git a/vendor/wheels/LICENSE-antlr4-python3-runtime.txt b/vendor/wheels/LICENSE-antlr4-python3-runtime.txt new file mode 100644 index 000000000..08ce6d286 --- /dev/null +++ b/vendor/wheels/LICENSE-antlr4-python3-runtime.txt @@ -0,0 +1,27 @@ +[The "BSD 3-clause license"] +Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither name of copyright holders nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/wheels/README.md b/vendor/wheels/README.md new file mode 100644 index 000000000..cee238c20 --- /dev/null +++ b/vendor/wheels/README.md @@ -0,0 +1,33 @@ +# Vendored wheels + +Pure-Python packages that PyPI publishes only as source tarballs. `uv sync` +would compile them during first-run setup, and that build crashes setuptools on +some Windows hosts (#4253), so `[tool.uv.sources]` in `pyproject.toml` points +them here and `uv.lock` pins each wheel's sha256. + +| Package | Licence | +|---|---| +| docopt 0.6.2 | MIT (`LICENSE-MIT` kept in the wheel's dist-info) | +| dora-search 0.1.12 | MIT (`LICENSE` kept in dist-info) | +| antlr4-python3-runtime 4.9.3 | BSD-3-Clause; the upstream sdist ships no licence file, so the ANTLR project notice is kept in `LICENSE-antlr4-python3-runtime.txt` | + +Each wheel is the unmodified sdist built with the pinned backend in +`build-constraints.txt`. `SOURCES.json` records every sdist URL and sha256 +(the values `uv.lock` pinned before vendoring). + +## Regenerate or verify + +``` +uv run python scripts/build_vendored_wheels.py --verify # rebuild, compare every file's content +uv run python scripts/build_vendored_wheels.py # rebuild the committed wheels +uv lock --refresh # re-pin the new wheel hashes +``` + +The script downloads only the sdist URLs in `SOURCES.json` and checks their +sha256 first. `tests/test_vendored_wheels.py` runs offline in CI: wheel hash +equals `uv.lock`, RECORD is consistent, only `.py`/data/metadata files plus the +sdist's declared script, no native code or `.pth`. + +To add a package: put its sdist URL and sha256 in `SOURCES.json`, declare it in +`pyproject.toml` with a `[tool.uv.sources]` path entry, build, then `uv lock`. +`tests/test_lock_wheel_only.py` fails when a default-install package has no wheel. diff --git a/vendor/wheels/SOURCES.json b/vendor/wheels/SOURCES.json new file mode 100644 index 000000000..cf8a8f2f7 --- /dev/null +++ b/vendor/wheels/SOURCES.json @@ -0,0 +1,25 @@ +{ + "wheels": [ + { + "name": "docopt", + "version": "0.6.2", + "wheel": "docopt-0.6.2-py2.py3-none-any.whl", + "sdist_url": "https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz", + "sdist_sha256": "49b3a825280bd66b3aa83585ef59c4a8c82f2c8a522dbe754a8bc8d08c85c491" + }, + { + "name": "antlr4-python3-runtime", + "version": "4.9.3", + "wheel": "antlr4_python3_runtime-4.9.3-py3-none-any.whl", + "sdist_url": "https://files.pythonhosted.org/packages/3e/38/7859ff46355f76f8d19459005ca000b6e7012f2f1ca597746cbcd1fbfe5e/antlr4-python3-runtime-4.9.3.tar.gz", + "sdist_sha256": "f224469b4168294902bb1efa80a8bf7855f24c99aef99cbefc1bcd3cce77881b" + }, + { + "name": "dora-search", + "version": "0.1.12", + "wheel": "dora_search-0.1.12-py3-none-any.whl", + "sdist_url": "https://files.pythonhosted.org/packages/d5/9d/9a13947db237375486c0690f4741dd2b7e1eee20e0ffcb55dbd1b21cc600/dora_search-0.1.12.tar.gz", + "sdist_sha256": "2956fd2c4c7e4b9a4830e83f0d4cf961be45cfba1a2f0570281e91d15ac516fb" + } + ] +} diff --git a/vendor/wheels/antlr4_python3_runtime-4.9.3-py3-none-any.whl b/vendor/wheels/antlr4_python3_runtime-4.9.3-py3-none-any.whl new file mode 100644 index 000000000..5cdd813a8 Binary files /dev/null and b/vendor/wheels/antlr4_python3_runtime-4.9.3-py3-none-any.whl differ diff --git a/vendor/wheels/build-constraints.txt b/vendor/wheels/build-constraints.txt new file mode 100644 index 000000000..87da6ad4f --- /dev/null +++ b/vendor/wheels/build-constraints.txt @@ -0,0 +1,2 @@ +setuptools==75.6.0 +wheel==0.45.1 diff --git a/vendor/wheels/docopt-0.6.2-py2.py3-none-any.whl b/vendor/wheels/docopt-0.6.2-py2.py3-none-any.whl new file mode 100644 index 000000000..d3217cba3 Binary files /dev/null and b/vendor/wheels/docopt-0.6.2-py2.py3-none-any.whl differ diff --git a/vendor/wheels/dora_search-0.1.12-py3-none-any.whl b/vendor/wheels/dora_search-0.1.12-py3-none-any.whl new file mode 100644 index 000000000..6d7ddd5a8 Binary files /dev/null and b/vendor/wheels/dora_search-0.1.12-py3-none-any.whl differ