Skip to content

build: switch back to unsafe-best-match for easy torch install#674

Merged
gsprochette merged 1 commit into
mainfrom
build/switch-back-to-unsafe-best-match-for-easy-torch-install
Jun 9, 2026
Merged

build: switch back to unsafe-best-match for easy torch install#674
gsprochette merged 1 commit into
mainfrom
build/switch-back-to-unsafe-best-match-for-easy-torch-install

Conversation

@gsprochette

Copy link
Copy Markdown
Collaborator

Description

This PR re-introduces the "unsafe-best-match" index resolution strategy that was replaced by "first-index" in #613

The reason for this is that torch used to ship some packages on its index. With first-index, uv only see those outdated versions, the first-index, and doesn't look on pypi for newer versions, leading to an unresolvable environment.

The reason for moving away in the first place was to avoid pinging the pythonanywhere index on every public package. However, this was already accomplished by the line "explicit = true" in the same PR. With explicit=true, the python-anywhere index is only checked when explicitely stated, as in stable-fast-pruna = { index = "pruna_internal", extra = "stable-fast-extraindex" }.

With the change in this PR, we should be able to run uv pip install -e .[dev] torch==2.12 torchvision --extra-index-url https://download.pytorch.org/whl/cu126 (currently fails), without pinging the python-anywhere index on every package causing the HTTP errors.

Related Issue

Fixes #(issue number)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactor (no functional change)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

running uv pip install -e .[dev] torch==2.12 torchvision --extra-index-url https://download.pytorch.org/whl/cu126 currently fails, but passes after this change.

For full setup and testing instructions, see the Contributing Guide.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code, especially for agent-assisted changes
  • I updated the documentation where necessary

Thanks for contributing to Pruna! We're excited to review your work.

New to contributing? Check out our Contributing Guide for everything you need to get started.

Note:

  • Draft PRs or PRs without a clear and detailed overview may be delayed.
  • Please mark your PR as Ready for Review and ensure the sections above are filled out.
  • Contributions that are entirely AI-generated without meaningful human review are discouraged.

@gsprochette gsprochette requested a review from begumcig June 6, 2026 16:03

@begumcig begumcig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought the reason we switched to first-index was to prioritize PyPI when installing packages. With unsafe-best-match, we were searching the entire PythonAnywhere index, which was causing issues.

Now, my understanding is that explicit = true already prevents uv from looking at those custom indexes unless a package is explicitly assigned to them. Also, first-index makes index lookup greedy, which is not necessarily what we want. Is that correct? If that's the case APPROVED

@begumcig begumcig self-requested a review June 8, 2026 14:34

@begumcig begumcig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

forgot to approve

@gsprochette

Copy link
Copy Markdown
Collaborator Author

This is exactly correct ! Here's a recap:

  • index strategy:
    • unsafe-best-match: search every index for any version, starting with the default pypi. This is also the one that reproduces pip's behavior.
    • first-index: same, but whenever at least one version is found, don't bother looking in the remaining indices
  • explicit: if true, this index is a candidate only when explicitely stated with explicit = true, in which case it will be the only candidate.

@gsprochette gsprochette merged commit 8c01ab7 into main Jun 9, 2026
9 checks passed
@gsprochette gsprochette deleted the build/switch-back-to-unsafe-best-match-for-easy-torch-install branch June 9, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants