uv icon indicating copy to clipboard operation
uv copied to clipboard

Filter source dependencies by pattern

Open jzazo opened this issue 6 months ago • 0 comments

Summary

I would like to be able to specify source dependencies by pattern. For example, when I install torch from index-url like cuda, a lot of nvidia-* dependencies if not explicit are installed from pypi if they exist, or not installed at all if they not exist in pypi.

Example

At the moment I need to do the following to force the torch dependencies to be installed along pytorch using the index-url (because they may not exist in pypi for the given cuda driver).

[project]
name = "example-project-uv"
version = "0.0.12"
description = ""
requires-python = "==3.12.*"
readme = "README.md"
dependencies = []

[project.optional-dependencies]
cuda = [
    "torch==2.6.0",
    "nvidia-cublas-cu12",
    "nvidia-cuda-cupti-cu12",
    "nvidia-cuda-nvrtc-cu12",
    "nvidia-cuda-runtime-cu12",
    "nvidia-cudnn-cu12",
    "nvidia-cufft-cu12",
    "nvidia-cufile-cu12",
    "nvidia-curand-cu12",
    "nvidia-cusolver-cu12",
    "nvidia-cusparse-cu12",
    "nvidia-nvjitlink-cu12",
    "nvidia-nvtx-cu12",
    "triton",
]

[tool.uv.sources]
torch = [{ index = "torchcuda", extra = "cuda" }]
nvidia-cublas-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-cuda-cupti-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-cuda-nvrtc-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-cuda-runtime-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-cudnn-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-cufft-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-cufile-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-curand-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-cusolver-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-cusparse-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-nvjitlink-cu12 = { index = "torchcuda", extra = "cuda" }
nvidia-nvtx-cu12 = { index = "torchcuda", extra = "cuda" }
triton = { index = "torchcuda", extra = "cuda" }

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

This could be done as follows:

[project]
name = "example-project-uv"
version = "0.0.12"
description = ""
requires-python = "==3.12.*"
readme = "README.md"
dependencies = []

[project.optional-dependencies]
cuda = ["torch==2.6.0"]

[tool.uv.sources]
torch = [{ index = "torchcuda", extra = "cuda" }]
triton = { index = "torchcuda", extra = "cuda" }
"nvidia-*" = { index = "torchcuda", extra = "cuda" }

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

jzazo avatar May 12 '25 15:05 jzazo