uv icon indicating copy to clipboard operation
uv copied to clipboard

Can't install torch_scatter wheel from index on OSX

Open dionhaefner opened this issue 1 year ago • 6 comments

It seems impossible to install torch_scatter CPU wheels using uv on OSX. I'm following the official installation instructions which require --find-links to be passed.

pyproject.toml:

[project]
name = "foo"
requires-python = ">=3.10"
dependencies = [
    "torch",
    "torch_scatter",
]
version = "0.1.0"

[tool.uv.sources]
torch = [{ index = "pytorch-cpu", marker = "platform_system != 'Darwin'" }]


[tool.uv]
find-links = [
    "https://data.pyg.org/whl/torch-2.5.1+cpu.html",
]

[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true

Results in this error:

$ uv venv
$ uv sync
⠙ Resolving dependencies...                                                                          
warning: Missing version constraint (e.g., a lower bound) for `torch-scatter`
Resolved 13 packages in 2.52s
error: Distribution `torch-scatter==2.1.2+pt25cpu @ registry+https://data.pyg.org/whl/torch-2.5.1+cpu.html` can't be installed because it doesn't have a source distribution or wheel for the current platform

It seems that uv is picking up torch-scatter==2.1.2+pt25cpu instead of the (compatible) torch-scatter==2.1.2 wheel. pip-based installation works:

$ uv pip install torch_scatter -f https://data.pyg.org/whl/torch-2.5.1+cpu.html
# all good

I'm really looking for any pyproject.toml here that doesn't lead to uv sync choking on OSX.

dionhaefner avatar Dec 04 '24 19:12 dionhaefner

I think you need to do: "torch_scatter===2.1.2" instead of "torch_scatter".

charliermarsh avatar Dec 06 '24 00:12 charliermarsh

Same outcome:

error: Distribution `torch-scatter==2.1.2+pt25cpu @ registry+https://data.pyg.org/whl/torch-2.5.1+cpu.html` can't be installed because it doesn't have a source distribution or wheel for the current platform

It looks like uv is treating 2.1.2 and 2.1.2+pt25cpu as the same version and finds the latter first, which fails.

dionhaefner avatar Dec 06 '24 09:12 dionhaefner

There are three equals signs in my version. 2.1.2+pt25cpu is a valid version if you request torch_scatter==2.1.2 -- that's how the spec works. If you want 2.1.2 but not 2.1.2+pt25cpu, you need torch_scatter===2.1.2.

charliermarsh avatar Dec 17 '24 20:12 charliermarsh

(This is a consequence of PyTorch using the spec differently than it was intended, for details on the standards, see https://packaging.python.org/en/latest/specifications/version-specifiers/#local-version-identifiers)

zanieb avatar Dec 17 '24 20:12 zanieb

@zanieb - this would also be fixed by my “incomplete wheels” PR…

charliermarsh avatar Dec 17 '24 20:12 charliermarsh

After #9928, this would just be:

[project]
name = "foo"
requires-python = ">=3.10"
dependencies = [
    "torch",
    "torch_scatter",
]
version = "0.1.0"

[tool.uv.sources]
torch = [{ index = "pytorch-cpu" }]


[tool.uv]
find-links = [
    "https://data.pyg.org/whl/torch-2.5.1+cpu.html",
]

[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true

charliermarsh avatar Dec 17 '24 21:12 charliermarsh

Fixed by https://github.com/astral-sh/uv/pull/10046.

charliermarsh avatar Dec 20 '24 19:12 charliermarsh