Allow multiple pinned indexes in tool.uv.sources (#7769)

## Summary

This PR lifts the restriction that a package must come from a single
index. For example, you can now do:

```toml
[project]
name = "project"
version = "0.1.0"
readme = "README.md"
requires-python = ">=3.12"
dependencies = ["jinja2"]

[tool.uv.sources]
jinja2 = [
    { index = "torch-cu118", marker = "sys_platform == 'darwin'"},
    { index = "torch-cu124", marker = "sys_platform != 'darwin'"},
]

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

[[tool.uv.index]]
name = "torch-cu124"
url = "https://download.pytorch.org/whl/cu124"
```

The construction is very similar to the way we handle URLs today: you
can have multiple URLs for a given package, but they must appear in
disjoint forks. So most of the code is just adding that abstraction to
the resolver, following our handling of URLs.

Closes #7761.
This commit is contained in:
Charlie Marsh 2024-10-15 15:58:15 -07:00 committed by GitHub
parent ad24cee7c6
commit 9a76e47888
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 715 additions and 109 deletions

View file

@ -34,6 +34,7 @@ mod error;
mod exclude_newer;
mod exclusions;
mod flat_index;
mod fork_indexes;
mod fork_urls;
mod graph_ops;
mod lock;