Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 717
fix(pypi): skip index lookups when all package overrides are specified#3710
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
Merged
aignas
merged 1 commit into
bazel-contrib:main
from
aignas:aignas.fix.experimental_index_url_overrides_no_index_callApr 16, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -43,8 +43,7 @@ def simpleapi_download( | ||
| attr: Contains the parameters for the download. They are grouped into a | ||
| struct for better clarity. It must have attributes: | ||
| * index_url: str, the index, or if `extra_index_urls` are passed, the default index. | ||
| * index_url_overrides: dict[str, str], the index overrides for | ||
| separate packages. | ||
| * index_url_overrides: dict[str, str], the index overrides for separate packages. | ||
| * extra_index_urls: Will be looked at in the order they are defined and the first match | ||
| wins. This is similar to what uv does, see | ||
| https://docs.astral.sh/uv/concepts/indexes/#searching-across-multiple-indexes. | ||
| @@ -132,16 +131,22 @@ def simpleapi_download( | ||
| return contents | ||
| def _get_dist_urls(ctx, *, default_index, index_urls, index_url_overrides, sources, read_simpleapi, attr, block, _fail = fail, **kwargs): | ||
| if index_url_overrides: | ||
| # Let's not call the index at all and just assume that all of the overrides have been | ||
| # specified. | ||
| return { | ||
| pkg: _normalize_url("{}/{}/".format( | ||
| index_url_overrides.get(pkg, default_index), | ||
| pkg.replace("_", "-"), # Use the official normalization for URLs | ||
| )) | ||
| for pkg in sources | ||
| } | ||
aignas marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| downloads = {} | ||
| results = {} | ||
| # Ensure the value is not frozen | ||
| index_urls = [] + (index_urls or []) | ||
| for extra in index_url_overrides.values(): | ||
| if extra not in index_urls: | ||
| index_urls.append(extra) | ||
| index_urls = index_urls or [] | ||
| if default_index not in index_urls: | ||
| index_urls.append(default_index) | ||
| @@ -174,10 +179,6 @@ def _get_dist_urls(ctx, *, default_index, index_urls, index_url_overrides, sourc | ||
| # and in the outer function process merging of the results. | ||
| continue | ||
| if index_url_overrides.get(pkg, index_url) != index_url: | ||
| # we should not use this index for the package | ||
| continue | ||
| found = result.output.get(pkg) | ||
| if not found: | ||
| continue | ||
45 changes: 45 additions & 0 deletions
45 tests/pypi/simpleapi_download/simpleapi_download_tests.bzl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.