Skip to content

Error when pip.parse.experimental_index_url is a private index #2033

Closed
@dougthor42

Description

@dougthor42

🐞 bug report

Affected Rule

pip.parse

Is this a regression?

No. From what I can tell, it's always been present since experimental_index_url was added.

Description

Something wonky goes on when using a private index as the default pip index url. It seems like the credential helper is not working, but that may be a red herring.

🔬 Minimal Reproduction

This is fine:

pip.parse(
    experimental_extra_index_urls = ["https://[REDACTED]/simple"],
    experimental_index_url = "https://pypi.org/simple",
    hub_name = "pypi",
    python_version = "3.11",
    requirements_lock = "//:requirements.txt",
)

This fails:

pip.parse(
    experimental_extra_index_urls = ["https://pypi.org/simple"],
    experimental_index_url = "https://[REDACTED]/simple",
    hub_name = "pypi",
    python_version = "3.11",
    requirements_lock = "//:requirements.txt",
)

🔥 Exception or Error


ERROR: Traceback (most recent call last):                                                                              
        File "/usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dbe74c4144b5c9a438d84a119652bef9/external/rules_python~/python/private/bzlmod/pip.bzl", line 472, column 52, in _pip_impl                                                                                                                                                                                                                                                                                                
                is_hub_reproducible = _create_whl_repos(module_ctx, pip_attr, hub_whl_map, whl_overrides, hub_group_map, simpleapi_cache)                                                                                                                                                                                                                                                                                                                                                     
        File "/usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dbe74c4144b5c9a438d84a119652bef9/external/rules_python~/python/private/bzlmod/pip.bzl", line 187, column 50, in _create_whl_repos                                                                                                                                                                                                                                                                                        
                requirements_by_platform = parse_requirements(                                                                                                                                                                                 
        File "/usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dbe74c4144b5c9a438d84a119652bef9/external/rules_python~/python/private/parse_requirements.bzl", line 348, column 37, in parse_requirements                                                                                                                                                                                                                                                                               
                whls, sdist = _add_dists(                                                                              
        File "/usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dbe74c4144b5c9a438d84a119652bef9/external/rules_python~/python/private/parse_requirements.bzl", line 452, column 24, in _add_dists                                                                                                                                                                                                                                                                                       
                logger.warn("Could not find a whl or an sdist with sha256={}".format(sha256))                                                                                                                                                  
        File "/usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dbe74c4144b5c9a438d84a119652bef9/external/rules_python~/python/private/repo_utils.bzl", line 78, column 39, in lambda                                                                                                                                                                                                                                                                                                    
                warn = lambda message_cb: _log(0, "WARNING", message_cb),                                                                                                                                                                      
        File "/usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/dbe74c4144b5c9a438d84a119652bef9/external/rules_python~/python/private/repo_utils.bzl", line 72, column 71, in _log                                                                                                                                                                                                                                                                                                      
                print("\nrules_python: {}: ".format(level.upper()), message_cb())  # buildifier: disable=print                                                                                                                                 
Error: 'string' object is not callable                                                                                 
ERROR: error evaluating module extension pip in @@rules_python~//python/extensions:pip.bzl                                                                                                                                                     
INFO: Elapsed time: 8.798s                                                                                             
INFO: 0 processes.                                                                                                     
ERROR: Build did NOT complete successfully                                                                             
Loading: 0 packages loaded                                                                                             
    currently loading:                                                                                                 
    Fetching module extension pip in @@rules_python~//python/extensions:pip.bzl; starting 8s

🌍 Your Environment

Operating System:

gLinux

Output of bazel version:

$ bazel --version
bazel 7.2.0rc1

We're using 7.2.0rc1 because of bazelbuild/bazel#22664 which is actually a bug with jupyter/testpath that I haven't made a pip.override for yet.

Rules_python version:

Confirmed with:

0.33.1
0.33.2

Anything else relevant?

  • We use a credential helper to access the private index.
  • A different error happens with the latest rules_python commit at the time of writing (084b877):
    ERROR: no such package '@@[unknown repo 'com_github_bazelbuild_rules_go' requested from @@rules_python_gazelle_plugin~]//go/runfiles': The repository '@@[unknown repo 'com_github_bazelbuild_rules_go' requested from @@rules_python_gazelle_plugin~]' could not be resolved: No repository visible as '@com_github_bazelbuild_rules_go' from repository '@@rules_python_gazelle_plugin~'
    ERROR: /usr/local/google/home/dthor/dev/pyle/BUILD.bazel:81:24: no such package '@@[unknown repo 'com_github_bazelbuild_rules_go' requested from @@rules_python_gazelle_plugin~]//go/runfiles': The repository '@@[unknown repo 'com_github_bazelbuild_rules_go' requested from @@rules_python_gazelle_plugin~]' could not be resolved: No repository visible as '@com_github_bazelbuild_rules_go' from repository '@@rules_python_gazelle_plugin~' and referenced by '//:gazelle_python_manifest.test'
    ERROR: Analysis of target '//:gazelle_python_manifest.test' failed; build aborted: Analysis failed
    INFO: Elapsed time: 9.454s
    INFO: 0 processes.
    ERROR: Build did NOT complete successfully
    
    • This error happens for both "public pypi is main index" and "private index is main index" cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions