Skip to content

Package dependencies not installed on first uv run --extra with conflicting extras #9622

@eginhard

Description

@eginhard

I can confirm that #9533 is fixed with uv 0.5.6, this is a follow-up for packages with dependencies in conflicting extras:

[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.10.0"
dependencies = []

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

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

[tool.uv.sources]
torch = [
  { index = "pytorch-cpu", extra = "cpu", marker = "platform_system != 'Darwin'" },
  { index = "pytorch-cu118", extra = "cu118" },
]

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

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

To reproduce:

  1. Ensure lock file and venv are not present:
rm .venv/ uv.lock -rdf
  1. On the first run only torch itself is installed:
$ uv run --extra cpu python -c "import torch; print(torch.__version__)"
Using CPython 3.13.0
Creating virtual environment at: .venv
Installed 1 package in 88ms
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import torch; print(torch.__version__)
    ^^^^^^^^^^^^
  File ".../.venv/lib/python3.13/site-packages/torch/__init__.py", line 37, in <module>
    from typing_extensions import ParamSpec as _ParamSpec, TypeGuard as _TypeGuard
ModuleNotFoundError: No module named 'typing_extensions'
  1. The dependencies only get installed on the second run:
$ uv run --extra cpu python -c "import torch; print(torch.__version__)"
Installed 9 packages in 16ms
2.5.1+cpu

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