Skip to content

Requirements parsing (pip.parse) does not work with experimental_index_url after 1.4.0 upgrade #2863

Closed

Description

@al-babych-fivetran

🐞 bug report

Affected Rule

The issue is caused by the rule: pip.parse

Is this a regression?

Yes, the previous version in which this bug was not present was: 1.3.0

Description

After upgrade to 1.4.0 we get an error on pip.parse:
Error: 'struct' value has no field or method 'sha256s_by_version'

965dd51 looks related

🔬 Minimal Reproduction

...
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
    experimental_index_url = "http://some-proxy-url/pypi/simple", # have to be set
    hub_name = "hub",
    python_version = "3.10.8",
    requirements_lock = "//:requirements.txt",
)
...

Run bazel mod deps --lockfile_mode=update

🔥 Exception or Error



```
File "/private/var/tmp/_bazel_roman.vlasenko/7eb23c38ebf1165e125a92c28d7d5daa/external/rules_python+/python/private/pypi/parse_requirements.bzl", line 321, column 33, in _add_dists
                shas_to_use = index_urls.sha256s_by_version.get(version, [])
Error: 'struct' value has no field or method 'sha256s_by_version'
Available attributes: sdists, sha256_by_version, whls
ERROR: error evaluating module extension @@rules_python+//python/extensions:pip.bzl%pip
```

🌍 Your Environment

Operating System:

  
24.4.0 Darwin Kernel Version 24.4.0: Wed Mar 19 21:17:35 PDT 2025; root:xnu-11417.101.15~1/RELEASE_ARM64_T6041 arm64
  

Output of bazel version:

  
Bazelisk version: 1.25.0
Build label: 8.1.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Tue Feb 25 18:53:44 2025 (1740509624)
Build timestamp: 1740509624
Build timestamp as int: 1740509624
  

Rules_python version:

  
1.4.0
  

Anything else relevant?

Activity

  1. jfirebaugh commented on May 7, 2025

    @jfirebaugh

    Based on the error message

    Error: 'struct' value has no field or method 'sha256s_by_version'
    Available attributes: sdists, sha256_by_version, whls
    

    and code

    sha256_by_version = sha256_by_version,

    I think the attribute is spelled sha256_by_version, not sha256s_by_version.

    (It seems this feature is missing test coverage.)

  2. added theissue type on May 7, 2025
  3. added a commit that references this issue on May 7, 2025
    3463500
  4. added this to the v1.4.1 milestone on May 7, 2025
  5. added a commit that references this issue on May 8, 2025
    9dfa3ab
  6. added a commit that references this issue on May 8, 2025
    4f5a693
  7. aignas commented on May 9, 2025

    @aignas
    Collaborator

    Just for posterity, if you didn't specify hashes before 1.4, the experimental_index_url feature would fallback to legacy operation and rules_python would not be using the downloader. To work around this issue or similar/related ones, please specify hashes in your requirements.txt file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: pippip/pypi integration

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions