fix(pypi): support source-less wheels with dependencies - #4054
Open
hartikainen wants to merge 1 commit into
Open
fix(pypi): support source-less wheels with dependencies#4054hartikainen wants to merge 1 commit into
hartikainen wants to merge 1 commit into
Conversation
`rules_python` `2.3.x` wraps source-less wheels in a `py_library` whose `srcs` target has no Python files. Forward the target only when it has valid sources, and cover the wrapper behavior with unit tests.
There was a problem hiding this comment.
Pull request overview
This PR fixes an analysis-time failure in pip.parse-generated per-wheel repositories when consuming source-less wheels that still declare dependencies. It prevents the generated wrapper py_library from pointing its srcs at an empty source target (which Bazel rejects), while still keeping the source target in deps so PyInfo continues to propagate.
Changes:
- Plumbs a computed
wrapper_srcsvalue out ofwhl_library_srcs()and intowhl_library_deps_targets()so the wrapperpy_library(srcs=...)is only populated when it would be source-producing. - Adds regression tests covering sourceless wheels, normal sourceful wheels, and the “generated namespace-package init files” case.
- Adds a news entry documenting the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
python/private/pypi/whl_library_targets.bzl |
Computes and forwards wrapper srcs to avoid analysis errors for source-less wheels while preserving PyInfo propagation via deps. |
tests/pypi/whl_library_targets/whl_library_targets_tests.bzl |
Adds targeted regression coverage for sourceless/sourceful/namespace-init scenarios by asserting the generated py_library calls. |
news/sourceless-wheel-srcs.fixed.md |
Documents the bugfix in the changelog/news system. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source-less wheels with dependency metadata fail analysis because the generated wrapper
py_libraryputs an empty:srcstarget in itssrcsattribute.This forwards
:srcsthrough the wrapper only when it produces Python sources, while retaining it indepsforPyInfopropagation. Before this change,py-spy==0.4.1dependency fails during analysis. Afterward, it can be used as a dependency.Adds regression coverage for source-less, sourceful, and generated namespace-package source targets, along with a news entry.
Largely implemented with Opus.
Fixes #4053.