Skip to content

Specifying different dependency versions for different platforms #9515

@merajhashemi

Description

@merajhashemi

Hello,
I've encountered an issue while trying to specify different versions of PyTorch for Intel macOS in my project.
Here is a minimal pyproject.toml that shows the issue:

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "test"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
    "torch>=1.13.1,<2.3; sys_platform == 'darwin' and platform_machine == 'x86_64'",
    "torch>=1.13.1; sys_platform != 'darwin' or platform_machine == 'arm64'",
]

I’m trying to make sure that Intel macOS (darwin_x86_64) uses a specific version of PyTorch as there are no new wheels available for versions 2.3 and above. But the dependency resolver seems to apply this constraint universally when generating the lock file, resulting in version 2.2.2 being installed across all platforms.

Is there a better way to set these conditions, maybe in a tool.uv section? Any tips would be super helpful!


$ uv --version
uv 0.5.5

Related to #8358.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for clarification or support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions