How can I extend `./pants tailor` ? I'd like to ha...
# plugins
p
How can I extend
./pants tailor
? I'd like to have it add
skip_pylint=True
whenever it adds a
python_tests()
target. I would also like it to add another target (possibly a macro for a files target) in any directory with
pack.yaml
(which is a market file for source roots).
K. I see how I can register a
PutativeTargetsRequest
to add new targets for the relevant files near
pack.yaml
, but it's not clear how I can add extra kwargs to the python targets identified by the python
find_putative_targets
rule.
h
Yeah, adding new targets should be easy, modifying existing ones... let me take a look and remind myself how this works.
p
Hmm. I figured I would create a macro for a files target, and then my
PutativeTargets
would add that macro to the BUILD files. But, macros are defined much later, so am I better off to create a new files-like target?
Here's my plugin: https://github.com/st2sandbox/st2/tree/pants/pants-plugins/pack_metadata Do you have any feedback? Also, it looks like we would need another hook similar to setup_py to allow adjusting the targets that tailor already knows how to generate.
h
Small bit of feedback: Do you expect the pack_metadata to need
dependencies=
? If not you can omit the
Dependencies
from the core_fields
I think this should work with macros?
Your
PutativeTargets
really just contains text components for generating BUILD file entries
True, you wouldn't be able to call
for_target_type()
to create the
PutativeTarget
and would have to invoke the ctor directly, but I think that should work OK with macros, unless you have evidence to the contrary?
šŸ‘ 1
And re modifying the fields in the created python_tests targets - still thinking about this
There is no good story if multiple attempt to claim the same sources
We handle conflicts with existing targets, but not conflicts between putative target
šŸ‘ 1
So need to fix that
p
ok. My metadata target seems to work. It wasn't as complex as I thought. I can switch to a macro if I do something more complex.
Small bit of feedback: Do you expect the pack_metadata to needĀ 
dependencies=
? If not you can omit theĀ 
Dependencies
Ā from the core_fields
I'm undecided. I'm still figuring out how to wire up all the dependencies. I may need the
dependencies
field depending on the final state.