Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Update pkginfo #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
Merged

Update pkginfo #2

merged 1 commit into from
Apr 30, 2025

Conversation

nmoroze
Copy link

@nmoroze nmoroze commented Mar 27, 2025

This fixes a regression that causes an exception to be raised when building OT Python deps:

.../.cache/bazel/.../.../external/rules_python/python/pip_install/extract_wheels/lib/wheel.py", line 57, in entry_points
    name = "{}-{}".format(metadata.name.replace("-", "_"), metadata.version)
AttributeError: 'NoneType' object has no attribute 'replace'

The issue seems related to pkginfo not being able to parse newer versions of package metadata, although the reason why this started failing all of a sudden has not been root caused.

To reproduce

In a fresh checkout of OpenTitan's earlgrey_es_sival branch (reproducing might require clearing your Bazel cache, but note that this will break future builds if this fix isn't applied):

$ bazel query "@ot_python_deps//:*"
...
 (Traceback (most recent call last):
  File "/home/noah/.cache/bazel/_bazel_noah/d7a503cb641b82d61262bab21b5880e3/external/python3_x86_64-unknown-linux-gnu/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/noah/.cache/bazel/_bazel_noah/d7a503cb641b82d61262bab21b5880e3/external/python3_x86_64-unknown-linux-gnu/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/noah/.cache/bazel/_bazel_noah/d7a503cb641b82d61262bab21b5880e3/external/rules_python/python/pip_install/extract_wheels/__main__.py", line 5, in <module>
    main()
  File "/home/noah/.cache/bazel/_bazel_noah/d7a503cb641b82d61262bab21b5880e3/external/rules_python/python/pip_install/extract_wheels/__init__.py", line 117, in main
    targets = [
  File "/home/noah/.cache/bazel/_bazel_noah/d7a503cb641b82d61262bab21b5880e3/external/rules_python/python/pip_install/extract_wheels/__init__.py", line 120, in <listcomp>
    bazel.extract_wheel(
  File "/home/noah/.cache/bazel/_bazel_noah/d7a503cb641b82d61262bab21b5880e3/external/rules_python/python/pip_install/extract_wheels/lib/bazel.py", line 412, in extract_wheel
    for name, entry_point in sorted(whl.entry_points().items()):
  File "/home/noah/.cache/bazel/_bazel_noah/d7a503cb641b82d61262bab21b5880e3/external/rules_python/python/pip_install/extract_wheels/lib/wheel.py", line 57, in entry_points
    name = "{}-{}".format(metadata.name.replace("-", "_"), metadata.version)
AttributeError: 'NoneType' object has no attribute 'replace'
)

Now, patch OpenTitan to apply this PR's changes:

diff --git a/WORKSPACE b/WORKSPACE
index 38da63b4c3..038d9cb8de 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -7,6 +7,14 @@

 workspace(name = "lowrisc_opentitan")

+load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
+
+git_repository(
+     name = "rules_python",
+     remote = "https://github.com/nmoroze/rules_python.git",
+     commit = "f6e98e8e390198726dc8cdeedb8c1dbad7041020",
+)
+
 # Bazel skylib library
 load("//third_party/skylib:repos.bzl", "bazel_skylib_repos")
 bazel_skylib_repos()

The command now completes successfully when re-run:

$ bazel query "@ot_python_deps//:*"
Starting local Bazel server and connecting to it...
@ot_python_deps//:BUILD.bazel
@ot_python_deps//:requirements.bzl
Loading: 1 packages loaded 

Actually completing the fix will require updating OpenTitan to declare the newer version of rules_python early in WORKSPACE (as shown here), or threading it through other transitive dependencies (like crt).

This fixes a regression where an exception is raised when setting up
OpenTitan's Python dependencies:

.../.cache/bazel/.../.../external/rules_python/python/pip_install/extract_wheels/lib/wheel.py", line 57, in entry_points
    name = "{}-{}".format(metadata.name.replace("-", "_"), metadata.version)
AttributeError: 'NoneType' object has no attribute 'replace'

The issue seems related to the previous version of pkginfo not being able to
parse newer versions of Python package metadata, although the reason why this
started failing all of a sudden has not been root caused.

Signed-off-by: Noah Moroze <noah@opentitan.org>
Copy link

@pqcfox pqcfox left a comment

Choose a reason for hiding this comment

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

Gave a quick review since I ran into the same problem--LGTM! Verified that this works by applying this commit to $(bazel info output_base)/external/rules_python on earlgrey_es_sival.

Would additionally love to have this merged if possible, since this currently is preventing use of earlgrey_es_sival without manually editing the Bazel output base--thanks so much!

@pamaury
Copy link

pamaury commented Apr 30, 2025

I think the issue might be this: https://bugs.launchpad.net/pkginfo/+bug/2058697
I have seem poetry bug report with the same issue and they had to update to pkginfo as well.

Copy link

@pamaury pamaury left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for debugging the issue

@nmoroze
Copy link
Author

nmoroze commented Apr 30, 2025

Thanks for taking a look @pamaury and @pqcfox!

I think we'll need someone with write access to merge, cc @timothytrippel maybe?

@timothytrippel timothytrippel merged commit 67923e8 into lowRISC:main Apr 30, 2025
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.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.