Skip to content

Duplicate packages with conflicting extras #11133

@ElliottKasoar

Description

@ElliottKasoar

Summary

We have three dependencies, which all require PyTorch:

  • mace-torch, which requires torch>=1.12 in their tagged release
  • chgnet, which requires torch>=2.4.1 in their tagged release
  • matgl (labelled m3nget), which requires any torch in their tagged release, but in most cases we need to require torch<=2.2.1 (and "dgl==2.1")

A (relatively) minimal pyproject.toml for this, with the conflict between chgnet and m3gnet specified:

[project]
name = "test"
version = "0.0.1"
requires-python = ">=3.10"
dependencies = [
    "mace-torch==0.3.9",
]

[project.optional-dependencies]
chgnet = [
    "chgnet == 0.4.0",
]

m3gnet = [
    "matgl == 1.1.3",
    "torch == 2.2.1",
    "torchdata == 0.7.1",
]

[tool.uv]
constraint-dependencies = [
    "dgl==2.1",
    "torch<2.6",
]
conflicts = [
    [
      { extra = "chgnet" },
      { extra = "m3gnet" },
    ],
]

However, if I run uv sync -p 312 with this, followed by uv pip list, two versions of torch are installed:

torch                2.2.1
torch                2.5.1

Strangely, we swap out matgl for alignn (which only explicitly depends on torch>=2.0.0 in their tagged release):

[project]
name = "test"
version = "0.0.1"
requires-python = ">=3.10"
dependencies = [
    "mace-torch==0.3.9",
]

[project.optional-dependencies]
chgnet = [
    "chgnet == 0.4.0",
]

alignn = [
    "alignn == 2024.5.27",
    "torch == 2.2.1",
    "torchdata == 0.7.1",
]

[tool.uv]
constraint-dependencies = [
    "dgl==2.1",
    "torch<2.6",
]
conflicts = [
    [
      { extra = "chgnet" },
      { extra = "alignn" },
    ],
]

then, when running uv sync -p 312, only torch 2.5.1 is installed.

May be related to #10985.

Platform

macOS 15.2 arm64

Version

0.5.26

Python version

3.12.8

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