uv: `uv add` rejects pytorch from its index when on mac
I am trying to use uv to add torch to my project’s dependencies, but it fails. I am on macOS14.4.1 (ARM).
Here is a minimal repro.
[project]
name = "test"
version = "0.1.0"
requires-python = ">=3.10"
Then run:
uv python pin 3.10
uv add --extra-index-url="https://download.pytorch.org/whl/cpu" -- torch
Error:
warning: `uv add` is experimental and may change without warning.
Using Python 3.10.14 interpreter at: /Users/luca/Library/Application Support/uv/python/cpython-3.10.14-macos-aarch64-none/install/bin/python3
Creating virtualenv at: .venv
Resolved 13 packages in 1.69s
error: distribution torch==2.3.1+cpu @ registry+https://download.pytorch.org/whl/cpu can't be installed because it doesn't have a source distribution or wheel for the current platform
If I use uv pip install then everything works smoothly:
uv pip install --extra-index-url="https://download.pytorch.org/whl/cpu" -- torch
Resolved 9 packages in 1.73s
Installed 9 packages in 369ms
+ filelock==3.13.1
+ fsspec==2024.2.0
+ jinja2==3.1.3
+ markupsafe==2.1.5
+ mpmath==1.3.0
+ networkx==3.2.1
+ sympy==1.12
+ torch==2.3.1
+ typing-extensions==4.9.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 20 (13 by maintainers)
FWIW over in poetry I have mostly come to think that this is a torch problem and not a poetry problem at all. (And therefore also not a uv problem).
Specifically I reckon that https://github.com/pytorch/pytorch/issues/110004 is the right request to make, and the right place to make it. “Closing as implemented” seems not correct, perhaps someone would like to try again.
More generally… pytorch does lots of unusual things with its multiple indexes and playing games with local version identifiers and suchlike. If you want a taste of the sort of fun uv is likely to have trying to accommodate all of this - and if you have plenty of time to spare - then see https://github.com/python-poetry/poetry/issues/6409.
If uv - either deliberately or accidentally - were to make choices that somehow made sense of all of that, then there are plenty of folk in that thread who would likely be pleased to see it!
I’ve confirmed that Poetry has the same problem. It also chooses:
And then
poetry installfails afterpoetry locksucceeds.Just wanted to spell out the Intel x86_64 macOS solution that worked for me
uv sync