Repository navigation
fix(pypi): allow disabling Simple API downloader with index_url = "" - #4376
pganssle-google wants to merge 1 commit into
Conversation
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`.
|
AI Disclosure: This PR was drafted with an AI coding assistant under human direction ( This is an automatically generated agent comment. |
| @@ -0,0 +1,2 @@ | |||
| (pypi) Fixed {obj}`pip.default` so setting `index_url = ""` disables the Simple | |||
There was a problem hiding this comment.
Not sure if this is considered a fix or a behavioral change, let me know.
|
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? |
Our use case is that we have a somewhat complicated build that has to pull from multiple indices: PyTorch's CPU-only builds, our own nightly build index and the standard PyPI build. What motivated this change originally was that this was failing when we tried to update to the latest That said, if we actually had needed to disable the Simple API downloader (and it seems that the pip downloader is not being removed, so some use cases for this are actually acknowledged), this does seem like a bug. My AI's original instinct here was to pass
Needless to say, I was not pleased with this. Seems to me like it should either be explicitly impossible to disable SimpleAPI in |
|
So the best way to "disable the Simple API" is to use a "uv.lock" file that has all of the URLs. If the And we should probably fix the part where passing "/" works to disable the Simple API calls :D. You can disable it for certain packages with |

In rules_python 2.0.0, the Simple API downloader was enabled by default by falling back to
https://pypi.org/simpleinbuild_config. Whilehub_builder.bzlretains the fallback topipwhendefault_index_urlis empty,pip.default(index_url = "")could not be used to trigger it because_configureignores falsy attribute values (andattr.string()defaults to""when omitted).Set the default of
pip.default.index_urlto"https://pypi.org/simple"on the tag attribute and record any non-default value (including"") inbuild_config. Also applyenvsubsttoself._config.index_urlinhub_builder.bzlso an environment variable that expands to""disables the Simple API downloader in the same way aspip.parse.experimental_index_url.