Fix use of generic target in runtime package dependencies#23248
Fix use of generic target in runtime package dependencies#23248RaniSputnik wants to merge 4 commits intopantsbuild:mainfrom
Conversation
I think this is useful in the release notes, yes.
GenericTarget has no I think this issue affects the archive target too. Shall I investigate that in this PR? Or keep it small and investigate separately? I don't think one would naturally use |
benjyw
left a comment
There was a problem hiding this comment.
This is great! Just one fix needed, plus the release notes
Allows a `target()` alias to be used in `runtime_package_dependencies` to group packageable targets, rather than having to list each one individually. Uses a ShouldTraverseDepsPredicate to delegate traversal to the existing transitive_dependency_mapping infrastructure, which handles batched-concurrent BFS and cycle safety. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0b8b431 to
e8ba29a
Compare
Apologies for being unclear @benjyw, I meant that if one were to depend on a generic target in the
Right, that makes sense. The thing that felt weird to me about the implementation is it felt like a behaviour that generic target should own rather than it being imposed on the caller. I'm not familiar enough with the codebase to know how that would work, and the dependency walking + predicate model also makes sense 🤷♂️ it just means that callers has to be mindful to implement the behaviour of generic target rather than it being implemented once and used transparently everywhere. Thanks for the review! Should be all ready to go now 🚀 |
|
Currently the callers have to know how they want to traverse the graph. But yeah, it's possible that "give me my direct dependencies" should always elide GenericTarget, and so we could push this logic up to there. |
|
|
||
| When generating lockfiles, the new `python.resolves_to_uploaded_prior_to` option can be used to pass along [`--uploaded-prior-to`](https://pip.pypa.io/en/stable/user_guide/#filtering-by-upload-time). This allows you to filter packages by their upload time to an index, only considering packages that were uploaded before a specified point in time. | ||
|
|
||
| Including a generic `target` in the `runtime_package_dependencies` of `python_test` now correctly packages the transitive dependencies. |
There was a problem hiding this comment.
I don't think this is a matter of correctness - it's more that we moved the goalposts (to a hopefully better place). But I wouldn't classify the previous behavior as a bug, more as an over-literal interpretation of direct dependencies...
What
Fixes the following setup:
Previously the PEX dependencies would not get packaged and materialized when the tests were run.
Why
Allows a
target()alias to be used inruntime_package_dependenciesto group packageable targets, rather than having to list each one individually. This would help simplify a setup I have where I have the misfortune of having to write a loop to generate a list of targets:Using the generic target I can isolate this mess to the one relevant directory and keep the rest of the codebase clear.
Test plan
Open questions
TargetGeneratorwould that be a more robust fix? (sounds like it would be a much more invasive change)archivetarget too. Shall I investigate that in this PR? Or keep it small and investigate separately?