Skip to content

Conditional [tool.uv.sources] causes platform-specific transitive dependencies to be dropped for default (non-extra) resolution #17732

@randomze

Description

@randomze

Summary

When using [tool.uv.sources] with conditional index overrides (via extra), packages resolved from the default index (PyPI) for the non-extra case lose their platform_machine-gated
transitive dependencies.

Reproduction

Minimal pyproject.toml that works:

[project]
name = "test-torch"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = ["torch>=2.0"]
uv lock && grep "nvidia-cudnn" uv.lock
# Output: name = "nvidia-cudnn-cu12"

Adding conditional sources breaks it:

[project]
name = "test-torch"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = ["torch>=2.0"]

[project.optional-dependencies]
cu13 = ["torch>=2.0"]
cpu  = ["torch>=2.0"]

[tool.uv]
conflicts = [
  [{ extra = "cu13" }, { extra = "cpu" }],
]

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

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

[tool.uv.sources]
torch = [
  { index = "pytorch-cu130", extra = "cu13" },
  { index = "pytorch-cpu", extra = "cpu" },
]
uv lock && grep "nvidia-cudnn-cu12" uv.lock
# Output:

Expected behavior

When no extra is specified, torch should resolve from PyPI (the default), and its transitive dependencies with platform_machine == 'x86_64' and sys_platform == 'linux' markers (like
nvidia-cudnn-cu12) should be included in the lockfile.

Actual behavior

The lockfile only contains nvidia-cudnn-cu13 (for the cu13 extra). The default PyPI torch resolution is missing all nvidia-*-cu12 dependencies that have platform_machine markers.

Impact

Running uv sync (without extras) installs torch from PyPI, but the CUDA runtime dependencies are missing:

ImportError: libcudnn.so.9: cannot open shared object file: No such file or directory

Platform

Ubuntu 22.04 x86_64

Version

uv 0.9.27

Python version

Python 3.13.11

Metadata

Metadata

Assignees

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