rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

pypi downloads blocked by experimental_downloader_config fail silently

Open keith opened this issue 9 months ago • 4 comments

🐞 bug report

Affected Rule

pip.parse with the bazel downloader enabled

Is this a regression?

not sure

Description

with some config like this:

pip.parse(
    experimental_extra_index_urls = [
        "https://download.pytorch.org/whl/cu121",
    ],
    experimental_index_url = "https://pypi.org/simple",
    experimental_index_url_overrides = {
        "torch": "https://download.pytorch.org/whl/cu121",
        "torchaudio": "https://download.pytorch.org/whl/cu121",
        "torchvision": "https://download.pytorch.org/whl/cu121",
    },
...
)

If your remote downloader config doesn't allow pytorch.org, rules_python can fail with this error:

Error in fail: Failed to download metadata for ["torch", "torchaudio", "torchvision"] for from urls: ["https://pypi.org/simple", "https://download.pytorch.org/whl/rocm6.2"]

Instead of the normal:

Error in download: java.io.IOException: Configured URL rewriter blocked all URLs: [https://download.pytorch.org/whl/rocm6.2/torch/]

I believe this is because of allow_fail = True https://github.com/bazelbuild/rules_python/blob/fcf7221c1e079307ff13d32239b7782d2f1dc48c/python/private/pypi/simpleapi_download.bzl#L208 and it makes it hard to spot that it's a misconfiguration on your downloader config.

🌍 Your Environment

Operating System:

linux aarch64

Output of bazel version:

95bbed03758a7651916d0708a892f5342a0421c5

Rules_python version:

https://github.com/bazelbuild/rules_python/commit/fcf7221c1e079307ff13d32239b7782d2f1dc48c

keith avatar Feb 27 '25 20:02 keith

I think this is working as intended. If the allow_fail is not there then we would not be able to handle extra_index_urls. Maybe we should set it to allow_fail = False if the overrides are passed?

aignas avatar Mar 09 '25 12:03 aignas

Yea I wasn't suggesting removing that, but we probably need custom error handling because that isn't set

keith avatar Mar 18 '25 16:03 keith

How can we enable bazel downloader in pip parser? So we can use r.g. tweag credential-helper utility?

AFMiziara avatar Sep 23 '25 00:09 AFMiziara

Please read our docs.

aignas avatar Sep 24 '25 02:09 aignas