You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
uv add rejects pytorch from its index when on macΒ #5182
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:
This one is pretty tricky... Basically, 2.3.1+cpu includes Windows and Linux wheels, but not macOS wheels. Separately, 2.3.1 (without the local version) has macOS wheels. We choose 2.3.1+cpu because we don't evaluate platform compatibility during a universal install. But then we don't end up including macOS wheels.
One path forward: if the user selects 2.3.1, always choose the non-local version. That at least gives users some more control.
I don't know what other options we have. Try to sniff platform compatibility on the wheel tags, at least for macOS / Windows / Linux?
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 pytorch/pytorch#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 python-poetry/poetry#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!
Uhm as an FYI: today I tried uv add torch on M3 mac and it correctly installed the version w/o CUDA (which was brought me to use uv add --extra-index-url="https://download.pytorch.org/whl/cpu" -- torch in the first place).
I'm seeing a similar error when trying to install the Pantsbuild libraries via uv add or uv pip install. I'm on a MacOS 14.7.1 ARM machine. Full error message below.
margaretblack test-project % uv add https://github.com/pantsbuild/pants/releases/download/release_2.23.1/pantsbuild.pants-2.23.1-cp39-cp39-macosx_11_0_arm64.whl
Resolved 25 packages in 2.49s
error: distribution `pantsbuild-pants==2.23.1 @ direct+https://github.com/pantsbuild/pants/releases/download/release_2.23.1/pantsbuild.pants-2.23.1-cp39-cp39-macosx_11_0_arm64.whl` can't be installed because the binary distribution is incompatible with the current platform
margaretblack test-project % uv add https://github.com/pantsbuild/pants/archive/refs/tags/release_2.23.1.tar.gz
error: Failed to parse metadata from built wheel
Caused by: Metadata field Name not found
margaretblack test-project % uv add https://github.com/pantsbuild/pants/archive/refs/tags/release_2.23.1.zip
error: Failed to parse metadata from built wheel
Caused by: Metadata field Name not found
margaretblack test-project % uv pip install git+https://github.com/pantsbuild/pants.git@release_2.23.0
Updated https://github.com/pantsbuild/pants.git (6fad8c66e)
error: Failed to parse metadata from built wheel
Caused by: Metadata field Name not found
Are you sure that you're using Python 3.9? Does uv add --python 3.9 https://github.com/pantsbuild/pants/releases/download/release_2.23.1/pantsbuild.pants-2.23.1-cp39-cp39-macosx_11_0_arm64.whl fail in the same way?
As for those other failures, I'm not quite sure what to do with them -- it seems like that's not a properly structured Python package...? Running python -m build in those source directories creates invalid wheels.
Are you sure that you're using Python 3.9? Does uv add --python 3.9 https://github.com/pantsbuild/pants/releases/download/release_2.23.1/pantsbuild.pants-2.23.1-cp39-cp39-macosx_11_0_arm64.whl fail in the same way?
As for those other failures, I'm not quite sure what to do with them -- it seems like that's not a properly structured Python package...? Running python -m build in those source directories creates invalid wheels.
Running uv add --python 3.9 https://github.com/pantsbuild/pants/releases/download/release_2.23.1/pantsbuild.pants-2.23.1-cp39-cp39-macosx_11_0_arm64.whl resolved this issue! Thank you so much for the quick response @charliermarsh!
Activity
charliermarsh commentedon Jul 18, 2024
This is already resolved on main but not released.
charliermarsh commentedon Jul 18, 2024
Sorry, misread the last part of the error.
charliermarsh commentedon Jul 18, 2024
Can you include the
uv.lockthat is generated?charliermarsh commentedon Jul 19, 2024
This one is pretty tricky... Basically,
2.3.1+cpuincludes Windows and Linux wheels, but not macOS wheels. Separately,2.3.1(without the local version) has macOS wheels. We choose2.3.1+cpubecause we don't evaluate platform compatibility during a universal install. But then we don't end up including macOS wheels.One path forward: if the user selects
2.3.1, always choose the non-local version. That at least gives users some more control.I don't know what other options we have. Try to sniff platform compatibility on the wheel tags, at least for macOS / Windows / Linux?
charliermarsh commentedon Jul 19, 2024
\cc @konstin
charliermarsh commentedon Jul 19, 2024
I'd suggest using a direct URL for now while we figure out how to support this @baggiponte.
charliermarsh commentedon Jul 19, 2024
I've confirmed that Poetry has the same problem. It also chooses:
And then
poetry installfails afterpoetry locksucceeds.baggiponte commentedon Jul 19, 2024
Ops, sorry for the delay. Here it is (sorry for the .txt format, github does not support it).
uv.lock.txt
i.e. from pypi, right?
Thank you very much for the prompt support!
dimbleby commentedon Jul 19, 2024
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 pytorch/pytorch#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 python-poetry/poetry#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!
baggiponte commentedon Aug 3, 2024
Uhm as an FYI: today I tried
uv add torchon M3 mac and it correctly installed the version w/o CUDA (which was brought me to useuv add --extra-index-url="https://download.pytorch.org/whl/cpu" -- torchin the first place).dimbleby commentedon Sep 19, 2024
pytorch/pytorch#136275
charliermarsh commentedon Dec 20, 2024
Fixed by #10046.
meliz19 commentedon Jan 22, 2025
I'm seeing a similar error when trying to install the Pantsbuild libraries via
uv addoruv pip install. I'm on a MacOS 14.7.1 ARM machine. Full error message below.charliermarsh commentedon Jan 22, 2025
Are you sure that you're using Python 3.9? Does
uv add --python 3.9 https://github.com/pantsbuild/pants/releases/download/release_2.23.1/pantsbuild.pants-2.23.1-cp39-cp39-macosx_11_0_arm64.whlfail in the same way?As for those other failures, I'm not quite sure what to do with them -- it seems like that's not a properly structured Python package...? Running
python -m buildin those source directories creates invalid wheels.meliz19 commentedon Jan 22, 2025
Running
uv add --python 3.9 https://github.com/pantsbuild/pants/releases/download/release_2.23.1/pantsbuild.pants-2.23.1-cp39-cp39-macosx_11_0_arm64.whlresolved this issue! Thank you so much for the quick response @charliermarsh!charliermarsh commentedon Jan 22, 2025
No prob!
charliermarsh commentedon Mar 21, 2025
You need to declare macOS x86 as a required environment: https://docs.astral.sh/uv/concepts/resolution/#required-environments (itβs actually the example we use in the docs, so you can copy the configuration at the bottom there)
Mathemmagician commentedon Apr 10, 2025
Just wanted to spell out the Intel x86_64 macOS solution that worked for me
uv sync