Skip to content

Allow default index for conflicting groups (torch cpu/cuda) #10360

@sglbl

Description

@sglbl

Suggestion, not a bug: Allow default index for conflicting groups (torch cpu/cuda)

# This template toml file works with pytorch cpu and gpu versions @sglbl
# using 'uv sync --extra cpu' or 'uv sync --extra gpu' command
[project]
name = "digit-classification"
version = "0.1.0"
description = "Digit classification project"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
    "gradio==5.6.0",
    "matplotlib==3.9.2",
    "numpy==2.1.3",
    "opencv-python>=4.10.0.84",
    "transformers>=4.46.3",
]

[dependency-groups]
dev = [
    "jupyter>=1.1.1",
    "pytest>=8.3.3",
]

[project.optional-dependencies]
cpu = [
  "torch>=2.5.1",
]
gpu = [
  "torch>=2.5.1",
]

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

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

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

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

[tool.pytest.ini_options]
pythonpath = "."
filterwarnings = ["ignore::DeprecationWarning", "ignore::FutureWarning"]

Is there a way to set a default extra so that it installs pytorch gpu/cuda version without adding extra flag?
(something like putting the flag set-default = true under one of the [[tool.uv.index]])

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-designNeeds discussion, investigation, or design

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions