Skip to content

fix(pypi): include RECORD file in installed wheel targets#3752

Open
rickeylev wants to merge 1 commit intobazel-contrib:mainfrom
rickeylev:fix-importlib-metadata-files-20260501
Open

fix(pypi): include RECORD file in installed wheel targets#3752
rickeylev wants to merge 1 commit intobazel-contrib:mainfrom
rickeylev:fix-importlib-metadata-files-20260501

Conversation

@rickeylev
Copy link
Copy Markdown
Collaborator

@rickeylev rickeylev commented May 1, 2026

Currently, importlib.metadata.files() returns None for packages installed via rules_python's wheel rules. This happens because the RECORD file in the .dist-info directory is explicitly excluded from the data attribute of the generated py_library targets.

To fix this, remove **/*.dist-info/RECORD from the _data_exclude list in whl_library_targets.bzl. This ensures that the RECORD file is preserved in the runfiles and available at runtime, enabling importlib.metadata.files() to correctly list the files in the package.

#3024

Currently, `importlib.metadata.files()` returns `None` for packages installed via `rules_python`'s wheel rules. This happens because the `RECORD` file in the `.dist-info` directory is explicitly excluded from the `data` attribute of the generated `py_library` targets.

To fix this, remove `**/*.dist-info/RECORD` from the `_data_exclude` list in `whl_library_targets.bzl`. This ensures that the `RECORD` file is preserved in the runfiles and available at runtime, enabling `importlib.metadata.files()` to correctly list the files in the package.
@rickeylev rickeylev requested a review from aignas as a code owner May 1, 2026 15:30
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies whl_library_targets.bzl to stop excluding **/*.dist-info/RECORD files, which allows importlib.metadata to correctly report files associated with a package. A corresponding test case has been added to tests/venv_site_packages_libs/ to verify this behavior. I have no feedback to provide.

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.

1 participant