Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: charlie/index-api
Choose a base branch
from

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Sep 28, 2024

Summary

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

[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.

@charliermarsh charliermarsh added the enhancement New feature or request label Sep 28, 2024
@charliermarsh charliermarsh force-pushed the charlie/index-api-multiple-indexes branch from f2a6d3d to ca30bc3 Compare September 28, 2024 23:29
@charliermarsh charliermarsh marked this pull request as ready for review September 28, 2024 23:29
@charliermarsh charliermarsh force-pushed the charlie/index-api-multiple-indexes branch 5 times, most recently from 051f118 to 31a5e8b Compare September 29, 2024 00:14
| ^
Sources can only include a single index source
Resolved 4 packages in [TIME]
error: found duplicate package `jinja2==3.1.3 @ registry+https://download.pytorch.org/whl/cu118`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one actually fails:

[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["jinja2>=3"]

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

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

(It succeeds if you use explicit = true on the index.)

The issue is that the sys_platform == 'win32' branch uses the torch-cu118 index explicitly, but then the implied sys_platform != 'win32' branch also resolves to that same index.

@charliermarsh charliermarsh force-pushed the charlie/index-api-multiple-indexes branch from 31a5e8b to 495b958 Compare September 29, 2024 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant