Skip to content

fix(pypi): allow disabling Simple API downloader with index_url = "" - #4376

Open
pganssle-google wants to merge 1 commit into
bazel-contrib:mainfrom
pganssle-google:fix-pip-default-empty-index-url
Open

pganssle-google wants to merge 1 commit into
bazel-contrib:mainfrom
pganssle-google:fix-pip-default-empty-index-url

Conversation

@pganssle-google

Copy link
Copy Markdown

In rules_python 2.0.0, the Simple API downloader was enabled by default
by falling back to https://pypi.org/simple in build_config. While
hub_builder.bzl retains the fallback to pip when default_index_url
is empty, pip.default(index_url = "") could not be used to trigger it
because _configure ignores falsy attribute values (and attr.string()
defaults to "" when omitted).

Set the default of pip.default.index_url to
"https://pypi.org/simple" on the tag attribute and record any
non-default value (including "") in build_config. Also apply
envsubst to self._config.index_url in hub_builder.bzl so an
environment variable that expands to "" disables the Simple API
downloader in the same way as pip.parse.experimental_index_url.

In rules_python 2.0.0, the Simple API downloader was enabled by default
by falling back to `https://pypi.org/simple` in `build_config`. While
`hub_builder.bzl` retains the fallback to `pip` when `default_index_url`
is empty, `pip.default(index_url = "")` could not be used to trigger it
because `_configure` ignores falsy attribute values (and `attr.string()`
defaults to `""` when omitted).

Set the default of `pip.default.index_url` to
`"https://pypi.org/simple"` on the tag attribute and record any
non-default value (including `""`) in `build_config`. Also apply
`envsubst` to `self._config.index_url` in `hub_builder.bzl` so an
environment variable that expands to `""` disables the Simple API
downloader in the same way as `pip.parse.experimental_index_url`.
@pganssle-google

Copy link
Copy Markdown
Author

AI Disclosure: This PR was drafted with an AI coding assistant under human direction (semi-autonomous). Review comments and follow-up changes on this PR will be handled or reviewed by @pganssle-google before posting.

This is an automatically generated agent comment.

@@ -0,0 +1,2 @@
(pypi) Fixed {obj}`pip.default` so setting `index_url = ""` disables the Simple

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not sure if this is considered a fix or a behavioral change, let me know.

@aignas

aignas commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

In this particular case, we have spent a lot of effort to ensure that this works in most scenarios. What would be the use case for disabling this? Which version are you observing problems with? What are they?

This branch has not been deployed

No deployments
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