cool-easter-32542
07/22/2023, 11:26 AMpython_requirement targets a certain target may depend on. Currently, it is necessary to do:
__dependencies_rules__(
(
{"type": "*"},
"requirements#requests",
"requirements#tornado",
"requirements#flask",
"!*",
)
)
Target visibility rules only operate on direct dependencies - they do not validate dependencies transitively. Therefore, having a target (or a custom target from a plugin) with dependencies set to ["requirements#requests", "requirements#tornado", "requirements#flask"] won't work.
Describe the solution you'd like
# 3rdparty/BUILD
target(name="reqs-web", dependencies=["requirements#requests", "requirements#tornado", "requirements#flask"])
the rule is used to declare that targets may depend on any of these three requirements:
__dependencies_rules__(
(
{"type": "*"},
"3rdparty:reqs-web",
"!*",
)
)
This results in more expressive rules with less boilerplate.
Describe alternatives you've considered
I've experimented developing custom plugins that would have dependencies set dynamically, but the dependencies of a "composite" target are not "exploded" into individual targets, and therefore can't seem to be used in the visibility rules.
Synthetic targets may provide a way to achieve this, however, this would require writing a plugin, so not ideal for a casual user.
pantsbuild/pants