Skip to content

Requirements contain conflicting indexes for package torch error when using extra markers in both the project and a dependency #9942

@reuben

Description

@reuben

I have the following setup in a monorepo:

  • projects/lib -> helper library which wraps PyTorch, with two extras torch-v1 and torch-v2
  • projects/app -> app which uses the lib and also PyTorch directly, with the same two extras torch-v1 and torch-v2

I tried to set up both projects with the markers, and the app -> lib dependency is also only encoded in the optional dependencies of app. E.g. in app/pyproject.toml:

[project.optional-dependencies]
torch-v1 = [
    "torch==1.12.1",
    "torchaudio==0.12.1",
    "lib[torch-v1]",
]
torch-v2 = [
    "torch~=2.3.1",
    "torchaudio~=2.3.1",
    "lib[torch-v2]",
]
[tool.uv]
conflicts = [
    [
      { extra = "torch-v1" },
      { extra = "torch-v2" },
    ],
]

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

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

[tool.uv.sources]
lib = { path = "../lib", editable = true }
torch = [
  { index = "pytorch-cu113", extra = "torch-v1", marker = "platform_system != 'Darwin'"},
  { index = "pytorch-cu121", extra = "torch-v2", marker = "platform_system != 'Darwin'"},
]
torchaudio = [
  { index = "pytorch-cu113", extra = "torch-v1", marker = "platform_system != 'Darwin'"},
  { index = "pytorch-cu121", extra = "torch-v2", marker = "platform_system != 'Darwin'"},
]

lib/pyproject.toml looks identical except for the lib dependency.

When I then try to sync app, I get:

$ uv sync --extra torch-v1
error: Requirements contain conflicting indexes for package `torch` in split `platform_system != 'Darwin'`:
- https://download.pytorch.org/whl/cu113/
- https://download.pytorch.org/whl/cu121/

I've uploaded a repro here: https://github.com/reuben/uv-pytorch-dep-bug-repro

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions