Skip to content

fix: allow pypi packages with empty data attribute#3463

Merged
rickeylev merged 3 commits intobazel-contrib:mainfrom
rickeylev:fix.allow.empty.packages
Dec 15, 2025
Merged

fix: allow pypi packages with empty data attribute#3463
rickeylev merged 3 commits intobazel-contrib:mainfrom
rickeylev:fix.allow.empty.packages

Conversation

@rickeylev
Copy link
Collaborator

An empty glob under site-packages (after excluding code and pyi files) is a bit strange,
but not actually incorrect. If such a situation occurs, it would cause a failure because
Bazel has since changed to disallow empty globs by default.

To fix, just set allow_empty=True on the data glob.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rickeylev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a specific build robustness issue related to Bazel's native.glob function. Previously, if a glob pattern for PyPI package data resulted in no matches after exclusions, Bazel's updated default behavior would cause a build failure. The change ensures that such valid scenarios, where a data glob might legitimately yield an empty set, are handled gracefully by explicitly allowing empty glob results, thereby preventing unnecessary build breaks.

Highlights

  • Build Fix: Resolves a potential build failure when processing PyPI packages where the data attribute's glob might result in an empty set, which Bazel now disallows by default.
  • Glob Configuration: Explicitly sets allow_empty=True for the native.glob call used to collect data files within site-packages for whl_library_targets.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@rickeylev rickeylev enabled auto-merge December 15, 2025 00:36
Copy link
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

The change to add allow_empty = True to the data glob is correct and aligns with the goal of handling PyPI packages that might not have data files besides the Python code. However, the pull request is missing updates to the test suite, which will likely fail with this change. I've added a comment with details on how to fix the tests.

@aignas
Copy link
Collaborator

aignas commented Dec 15, 2025

I think in reality dist-info will always match unless you manually exclude it. So the wheel won't be valid, most likely if you are hitting this.

@rickeylev
Copy link
Collaborator Author

Huh, interesting. Gemini warned that setting the attribute would cause a test failure. I wonder if it ran after CI was done and processed that? Or because it grokked the whole code base? In either case, it was right. That was legit impressive.

@rickeylev
Copy link
Collaborator Author

Thanks, yeah, good point. I don't see how a valid wheel could trigger this. But it seems relatively innocuous to allow.

@rickeylev rickeylev added this pull request to the merge queue Dec 15, 2025
Merged via the queue into bazel-contrib:main with commit 1090b6c Dec 15, 2025
4 checks passed
@rickeylev rickeylev deleted the fix.allow.empty.packages branch December 15, 2025 01:40
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.

2 participants