Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uv lock finds incorrect wheels for sys_platform == 'darwin' (pytorch) #10059

Closed
patrickhulce opened this issue Dec 20, 2024 · 2 comments
Closed
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@patrickhulce
Copy link

patrickhulce commented Dec 20, 2024

Background
I'm trying to run the same project on macOS and Ubuntu. For that, I have two sources for pytorch as described in the uv docs. I'm using uv version uv 0.5.11 (c4d0caaee 2024-12-19) on macOS 14.4.1

Steps to Reproduce

uv init
cat > pyproject.toml <<EOF
[project]
name = "testuv"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
  "torch",
]

[tool.uv.sources]
torch = [
    { index = "pytorch-cu118", marker = "sys_platform != 'darwin'" },
    { index = "pytorch-cpu", marker = "sys_platform == 'darwin'" },
]


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

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

What Happens

uv incorrectly resolves the macOS to version 2.5.1+cpu (only available on linux) instead of 2.5.1. When you attempt to uv sync then it fails with this message.

error: Distribution `torch==2.5.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

Specifically, the lock file contains this block.

[[package]]
name = "torch"
version = "2.5.1+cpu"
source = { registry = "https://download.pytorch.org/whl/cpu" }
resolution-markers = [
    "sys_platform == 'darwin'",
]
dependencies = [
    { name = "filelock", marker = "sys_platform == 'darwin'" },
    { name = "fsspec", marker = "sys_platform == 'darwin'" },
    { name = "jinja2", marker = "sys_platform == 'darwin'" },
    { name = "networkx", marker = "sys_platform == 'darwin'" },
    { name = "setuptools", marker = "sys_platform == 'darwin'" },
    { name = "sympy", marker = "sys_platform == 'darwin'" },
    { name = "typing-extensions", marker = "sys_platform == 'darwin'" },
]
wheels = [
    { url = "https://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp312-cp312-linux_x86_64.whl", hash = "sha256:4856f9d6925121d13c2df07aa7580b767f449dfe71ae5acde9c27535d5da4840" },
    { url = "https://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp313-cp313-linux_x86_64.whl", hash = "sha256:5dbbdf83caa90d0bcaa50e4933ca424889133b35226db79000877d4ec5d9ea37" },
]

What Did I Expect to Happen
I expected uv to resolve the version to 2.5.1 and the wheels to

wheels = [
    { url = "https://download.pytorch.org/whl/cpu/torch-2.5.1-cp312-none-macosx_11_0_arm64.whl", hash = "sha256:8c712df61101964eb11910a846514011f0b6f5920c55dbf567bff8a34163d5b1" },
]

Workarounds

If I manually replace the version and wheels properties with the correct values, thenuv sync works as expected.

@charliermarsh charliermarsh added bug Something isn't working duplicate This issue or pull request already exists labels Dec 20, 2024
@charliermarsh
Copy link
Member

This is tracked in #9711. There are a variety of linked issues that are describing the same problem.

@charliermarsh
Copy link
Member

Fixed by #10046.

@charliermarsh charliermarsh self-assigned this Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants