Use CPU-only PyTorch index to speed up dev installation#2857
Use CPU-only PyTorch index to speed up dev installation#2857adamtheturtle merged 1 commit intomainfrom
Conversation
torch and torchvision are transitive dependencies of vws-python-mock. By default uv resolves them from PyPI, which provides CUDA-enabled wheels on Linux (~916 MB for torch). Redirecting to the pytorch CPU-only index reduces torch to ~189 MB — a 727 MB saving per cold-cache install. Following: https://vws-python.github.io/vws-python-mock/installation.html#faster-installation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| [tool.uv] | ||
| sources.torch = { index = "pytorch-cpu" } | ||
| sources.torchvision = { index = "pytorch-cpu" } |
There was a problem hiding this comment.
PyTorch source redirect breaks macOS dev installation
Medium Severity
The sources.torch and sources.torchvision unconditionally redirect resolution to the pytorch-cpu index (download.pytorch.org/whl/cpu), which only hosts Linux and Windows wheels — not macOS. Since uv does not fall back to PyPI when a wheel is missing from an explicit index, dependency resolution will fail for any macOS developer. The project classifies as supporting Operating System :: POSIX (which includes macOS). Adding platform markers (e.g., marker = "sys_platform != 'darwin'") to the source entries would restrict the redirect to platforms where CPU-only wheels exist.


Summary
vws-python-mock(a dev dependency) transitively requirestorchandtorchvisionuvresolves these from PyPI which provides CUDA-enabled wheels on Linux (~916 MB fortorchalone)torchandtorchvisionto the CPU-only PyTorch indexDoes it actually make installation faster?
Yes — tested empirically:
torch(Linux, cp313)torchvision(Linux, cp313)~733 MB total reduction per cold-cache install on Linux CI runners.
Implementation notes
[tool.uv.sources]only applies to direct dependencies (not transitive ones), sotorchandtorchvisionmust be listed explicitly inoptional-dependencies.devfor the source override to take effect. Adeptryignore is added since these packages are not directly imported in thevws-pythonsource code.🤖 Generated with Claude Code
Note
Low Risk
Only adjusts development dependency resolution and linting configuration; no runtime or production code paths are affected.
Overview
Speeds up dev installs by ensuring
uvresolvestorch/torchvisionfrom the CPU-only PyTorch wheel index instead of large default Linux CUDA wheels.This makes
torchandtorchvisionexplicitdevdependencies (even though they’re transitive viavws-python-mock) and configures[tool.uv]source/index overrides to point tohttps://download.pytorch.org/whl/cpu.deptryis updated to ignoreDEP002for these packages since they aren’t imported directly.Written by Cursor Bugbot for commit a828118. This will update automatically on new commits. Configure here.