See https://github.com/pantsbuild/pants/blob/master/src/python/pants/notes/2.0.x.rst for the changelog.
await Get(TransitiveTargets, Addresses([addr1])), use
await Get(TransitiveTargets, TransitiveTargetsRequest([addr1])), from
It's no longer possible to include
TransitiveTargets in your
@rule signature in order to get the transitive closure of what the user specified on the command. Instead, put
Addresses in your rule's signature, and use
await Get(TransitiveTargets, TransitiveTargetsRequest(addresses)).
Due to a new cycle in the rule graph, for any codegen implementations, you must use
DependenciesRequestLite instead of
TransitiveTargetsLite instead of
TransitiveTargetsRequest. Both imports are still from
These behave identically, except that they do not include dependency inference in the results. Unless you are generating for
input = PythonSources, this should be fine, as dependency inference is currently only used with Python.
This is tracked by https://github.com/pantsbuild/pants/issues/10917.
If you have any custom fields that act like the dependencies field, but do not subclass
Dependencies, there are two new mechanisms for better support.
- Instead of subclassing
pants.engine.target. This will ensure that the dependencies show up with
- You can use
pants.engine.addressesto resolve the addresses:
from pants.engine.addresses import Address, Addresses, UnparsedAddressedInputs from pants.engine.target import Targets ... addresses = await Get(Addresses, UnparsedAddressedInputs(["//:addr1", "project/addr2"], owning_address=None) # Or, use this. targets = await Get( Targets, UnparsedAddressedInputs(["//:addr1", "project/addr2"], owning_address=Address("project", target_name="original") )
If you defined a subclass of
SpecialCasedDependencies, you can use
await Get(Addresses | Targets, UnparsedAddressInputs, my_tgt[MyField].to_unparsed_address_inputs()).
(Why would you ever do this? If you have dependencies that you don't treat like normal—e.g. that you will call the equivalent of
./pants package on those deps—it's often helpful to call out this magic through a dedicated field. For example, Pants's archive target type has the fields
packages, rather than
All of Pants's target types that can be built via
./pants package now have an
output_path field, which allows the user to override the path used for the created asset.
You optionally may want to add this
output_path field to your custom target type for consistency:
pants.core.goals.packagein your target's
- In your
- When computing the filename in your rule, use
Updated about 1 year ago