Are generated targets supposed to depend on the ge...
# development
p
Are generated targets supposed to depend on the generator? Or can the generator depend on its generated targets? I think I remember discussion about dependencies like this causing issues, but I can't remember what issues those were.
1
a
Generators have a dependency on their generated targets.
This might be what you're thinking of - basically another target type was needed so that changing the source of the generator (like
go.mod
or
requirements.txt
) actually caused pants to see the generator itself as changed.
p
Thank you for the link, that was helpful. I haven't found the code that adds the dependency from
GeneratorTarget
to its generated targets. I think I saw something about the files based generator, but that isn't quite what I needed. It turns out I can't really turn
PythonDistribution
until a generator because that would prevent people from using parametrize. I don't want to replace the generator with the generator target, I want to make some of its metadata (the
entry_points
defined on the
python_distribution
addressable.
a
You can use parametrize with generators? IIRC, the only thing you can't parametrize are copied fields in overrides. Everything else should be parametrizable though.
p
Parametrization is only supported for moved fields, not copied fields: https://github.com/pantsbuild/pants/blob/e5aff163d367f637720730f853ed07b6557a06fd/src/python/pants/engine/internals/graph.py#L323-L327 I was thinking of structuring it like this:
python_distribution
-> target generator
python_entry_point
-> new target generated by the python_distribution This "generated" target represents a small subset of the metadata recorded on the
python_distribution
, so people could easily run into issues trying to parametrize a field that has nothing to do with the entry points, since effectively only the fields on the "generated" target can be parametrized.