Closed
Description
I am attempting to select a cpu build of torch for linux and the regular build of torch for darwin with the following minimal reproducer:
requirements.in
torch==1.13.1+cpu ; platform_system == 'Linux' and sys_platform == 'linux'
torch==1.13.1 ; platform_system == 'Darwin' and sys_platform == 'darwin'
(note: it fails also with just sys_platform or just platform_system; I was trying to force it)
command
uv pip compile requirements.in -o requirements.txt --universal --no-strip-markers --extra-index-url https://download.pytorch.org/whl/cpu --native-tls --verbose
The output file is:
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in -o requirements.txt --universal --no-strip-markers --native-tls
torch==1.13.1+cpu ; (platform_system == 'Darwin' and sys_platform == 'darwin') or (platform_system == 'Linux' and sys_platform == 'linux')
# via -r test.in
typing-extensions==4.9.0 ; (platform_system == 'Darwin' and sys_platform == 'darwin') or (platform_system == 'Linux' and sys_platform == 'linux')
# via torch
This fails to install on darwin because the torch==1.13.1+cpu
is only available for linux. The verbose log output is:
DEBUG uv 0.5.9
DEBUG Starting Python discovery for a default Python
DEBUG Looking for exact match for request a default Python
DEBUG Searching for default Python interpreter in virtual environments, managed installations, or search path
DEBUG Searching for managed installations at `/Users/me/.local/share/uv/python`
DEBUG Found managed installation `cpython-3.10.15-macos-aarch64-none`
DEBUG Found `cpython-3.10.15-macos-aarch64-none` at `/Users/me/.local/share/uv/python/cpython-3.10.15-macos-aarch64-none/bin/python3.10` (managed installations)
DEBUG Using Python 3.10.15 interpreter at /Users/me/.local/share/uv/python/cpython-3.10.15-macos-aarch64-none/bin/python3.10 for builds
DEBUG Using request timeout of 30s
DEBUG Solving with installed Python version: 3.10.15
DEBUG Solving with target Python version: >=3.10.15
DEBUG Pre-fork all marker environments took 0.000s
DEBUG Splitting resolution on root==0a0.dev0 over torch into 3 resolutions with separate markers
DEBUG Adding direct dependency: torch{platform_system == 'Darwin' and sys_platform == 'darwin'}>=1.13.1, <1.13.1+
DEBUG Adding direct dependency: torch{platform_system == 'Linux' and sys_platform == 'linux'}==1.13.1+cpu
DEBUG Solving split (platform_system == 'Linux' and sys_platform == 'linux') (requires-python: RequiresPython { specifiers: VersionSpecifiers([VersionSpecifier { operator: GreaterThanEqual, version: "3.10.15" }]), range: RequiresPythonRange(LowerBound(Included("3.10.15")), UpperBound(Unbounded)) })
DEBUG No cache entry for: https://download.pytorch.org/whl/cpu/torch/
DEBUG Searching for a compatible version of torch{platform_system == 'Linux' and sys_platform == 'linux'} (==1.13.1+cpu)
DEBUG Selecting: torch==1.13.1+cpu [compatible] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Adding transitive dependency for torch==1.13.1+cpu: torch==1.13.1+cpu
DEBUG Adding transitive dependency for torch==1.13.1+cpu: torch{platform_system == 'Linux' and sys_platform == 'linux'}==1.13.1+cpu
DEBUG Searching for a compatible version of torch{platform_system == 'Linux' and sys_platform == 'linux'} (==1.13.1+cpu)
DEBUG Selecting: torch==1.13.1+cpu [compatible] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Found stale response for: https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=11692523b87c45b79ddfb5148b12a713d85235d399915490d94e079521f7e014
DEBUG Sending revalidation request for: https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=11692523b87c45b79ddfb5148b12a713d85235d399915490d94e079521f7e014
DEBUG Found not-modified response for: https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=11692523b87c45b79ddfb5148b12a713d85235d399915490d94e079521f7e014
DEBUG Adding transitive dependency for torch==1.13.1+cpu: typing-extensions*
DEBUG Searching for a compatible version of torch (==1.13.1+cpu)
DEBUG Selecting: torch==1.13.1+cpu [compatible] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Adding transitive dependency for torch==1.13.1+cpu: typing-extensions*
DEBUG No cache entry for: https://download.pytorch.org/whl/cpu/typing-extensions/
DEBUG Searching for a compatible version of typing-extensions (*)
DEBUG Selecting: typing-extensions==4.9.0 [compatible] (typing_extensions-4.9.0-py3-none-any.whl)
DEBUG Found stale response for: https://download.pytorch.org/whl/typing_extensions-4.9.0-py3-none-any.whl#sha256=af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd
DEBUG Sending revalidation request for: https://download.pytorch.org/whl/typing_extensions-4.9.0-py3-none-any.whl#sha256=af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd
DEBUG Found not-modified response for: https://download.pytorch.org/whl/typing_extensions-4.9.0-py3-none-any.whl#sha256=af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd
DEBUG Tried 2 versions: torch 1, typing-extensions 1
DEBUG split `platform_system == 'Linux' and sys_platform == 'linux'` resolution took 0.687s
DEBUG Solving split (platform_system == 'Darwin' and sys_platform == 'darwin') (requires-python: RequiresPython { specifiers: VersionSpecifiers([VersionSpecifier { operator: GreaterThanEqual, version: "3.10.15" }]), range: RequiresPythonRange(LowerBound(Included("3.10.15")), UpperBound(Unbounded)) })
DEBUG Searching for a compatible version of torch{platform_system == 'Darwin' and sys_platform == 'darwin'} (>=1.13.1, <1.13.1+)
DEBUG Selecting: torch==1.13.1+cpu [preference] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Adding transitive dependency for torch==1.13.1+cpu: torch==1.13.1+cpu
DEBUG Adding transitive dependency for torch==1.13.1+cpu: torch{platform_system == 'Darwin' and sys_platform == 'darwin'}==1.13.1+cpu
DEBUG Searching for a compatible version of torch{platform_system == 'Darwin' and sys_platform == 'darwin'} (==1.13.1+cpu)
DEBUG Selecting: torch==1.13.1+cpu [preference] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Adding transitive dependency for torch==1.13.1+cpu: typing-extensions*
DEBUG Searching for a compatible version of torch (==1.13.1+cpu)
DEBUG Selecting: torch==1.13.1+cpu [preference] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
DEBUG Adding transitive dependency for torch==1.13.1+cpu: typing-extensions*
DEBUG Searching for a compatible version of typing-extensions (*)
DEBUG Selecting: typing-extensions==4.9.0 [preference] (typing_extensions-4.9.0-py3-none-any.whl)
DEBUG Tried 4 versions: torch 2, typing-extensions 2
DEBUG split `platform_system == 'Darwin' and sys_platform == 'darwin'` resolution took 0.000s
DEBUG Solving split ((platform_system != 'Darwin' and sys_platform == 'darwin') or (platform_system != 'Linux' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')) (requires-python: RequiresPython { specifiers: VersionSpecifiers([VersionSpecifier { operator: GreaterThanEqual, version: "3.10.15" }]), range: RequiresPythonRange(LowerBound(Included("3.10.15")), UpperBound(Unbounded)) })
DEBUG Tried 4 versions: torch 2, typing-extensions 2
DEBUG split `(platform_system != 'Darwin' and sys_platform == 'darwin') or (platform_system != 'Linux' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')` resolution took 0.000s
INFO Solved your requirements for 3 environments
DEBUG Distinct solution for split (platform_system == 'Linux' and sys_platform == 'linux') with 2 packages
DEBUG Distinct solution for split (platform_system == 'Darwin' and sys_platform == 'darwin') with 2 packages
DEBUG Distinct solution for split ((platform_system != 'Darwin' and sys_platform == 'darwin') or (platform_system != 'Linux' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')) with 0 packages
In particular, I am really confused why this line is occuring:
DEBUG Searching for a compatible version of torch{platform_system == 'Darwin' and sys_platform == 'darwin'} (>=1.13.1, <1.13.1+)
DEBUG Selecting: torch==1.13.1+cpu [preference] (torch-1.13.1+cpu-cp310-cp310-linux_x86_64.whl)
How can it be selecting a linux wheel here?