Open sharmuz opened 1 week ago
In reality, it should be quite rare to see win32
for platform_system
, as it's not difficult to replace win32
with Windows
in its judgment.
https://docs.python.org/3.10/library/platform.html#platform.system https://docs.astral.sh/uv/concepts/dependencies/#dependency-specifiers-pep-508
To generate more precise results, I recommend using Linux
, Windows
, or Darwin
as the marker value. Please note that these values are case-sensitive.
The value win32
is associated with the marker sys_platform
.
https://docs.python.org/3.10/library/sys.html#sys.platform
Edit:
I'm unsure if platform_system
is case-sensitive, but using the correct capitalization for the lock file is usually best.
Thanks @FishAlchemist - that did the trick!
Looks like case-sensitivity is important for platform_system. FWIW I originally was using sys_platform instead (hence the win32) but still had issues (can't recall if were same).
Might be worth updating the dependency docs to use platform_system? Just a thought
Anyway here's my working pyproject.toml in case is of use:
[project]
name = "minimal"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = "==3.10.*"
dependencies = [
"torch==1.13.1 ; platform_system == 'Darwin'",
"torch==1.13.1+cpu ; platform_system == 'Windows'",
"torch==1.13.1+cu116 ; platform_system == 'Linux'",
"torchvision==0.14.1 ; platform_system == 'Darwin'",
"torchvision==0.14.1+cpu ; platform_system == 'Windows'",
"torchvision==0.14.1+cu116 ; platform_system == 'Linux'",
]
[tool.uv.sources]
torch = [
{ index = "torch-cpu", marker = "platform_system != 'Linux'" },
{ index = "torch-cuda", marker = "platform_system == 'Linux'" },
]
torchvision = [
{ index = "torch-cpu", marker = "platform_system != 'Linux'" },
{ index = "torch-cuda", marker = "platform_system == 'Linux'" },
]
[[tool.uv.index]]
name = "torch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true
[[tool.uv.index]]
name = "torch-cuda"
url = "https://download.pytorch.org/whl/cu116"
explicit = true
(Btw I'm aware pytorch advise installing from pypi for macos - I just prefer this way)
Sorry to say I'm getting a new issue with this with 0.5.1 :(
uv fails to install the env, saying it cannot find a compatible file for torch==1.13.1+cpu
for my platform (Mac/Darwin).
However, as you can see above it should not be attempting to install that version of torch on Mac. Scanning the lockfile I see that it has indeed erroneously added platform_system == 'Darwin'
to the entry for torch==1.13.1+cpu
instead of torch==1.13.1
.
Downgrading to 0.5.0 did not resolve it. (I must've been mistaken with the ver I wrote at the top).
Changing the tool.uv.sources entry for torch so that index = "torch-cpu"
is only for Windows does resolve it. I.e. Darwin installs from pypi. But before it worked from torch-cpu.
Downgrading to 0.4.28 does resolve it fully - it creates a lockfile consistent with the toml and installs the correct torch packages from pytorch.org for Mac.
@sharmuz Can you provide a pyproject.toml file that can reproduce the issue you're facing? Will this issue occur in version 0.4.29? Since 0.5.0 is a major update, confirming this issue in 0.4.29, the last version in the 0.4.X series, will help narrow down the scope of uv's bug-hunting efforts.
@sharmuz -- You likely need to do torch==1.13.1, !==1.13.1+cpu ; platform_system == 'Darwin'
, or torch===1.13.1 ; platform_system == 'Darwin'
.
1.13.1+cpu
is a valid version for torch==1.13.1
, per the Python standards.
I believe this is a duplicate of https://github.com/astral-sh/uv/issues/9036.
uv version: 0.5.0 OS/platform: macOS Sonoma 14.7.1 (on a MBP 2020 Intel)
Hey folks - YAO pytorch issue :)
I'm attempting to create an env which will install a given
torch
andtorchvision
version from a specified index, depending on whether the OS is darwin/win/linux.I'm going off of the info in #6523 and #8746.
Here's a minimal excerpt of my
pyproject.toml
:uv sync
runs without error but the generateduv.lock
looks off:(equivalent output for torchvision)
I see two problems:
torch==1.13.1+cpu
is marked as for win32 but the binary listed is for linuxtorch==1.13.1
for darwin lists no binary, even though this is definitely present (I've tested with the url supplied directly instead of indexI've tried:
index = "torch-cpu"
as only for win32 (so darwin should use pypi) --> 1) still a probindex = "torch-cpu"
as only for darwin --> 2) still a probAm I missing something? Ideally I'd like
pyproject.toml
to not need any direct url sources and work for mac-x86/mac-arm/win/linux-cuda