does a codegen rule have to be a `Sources` -> `...
# plugins
a
does a codegen rule have to be a
Sources
->
Sources
? I'm trying to generate a single
python_source
from multiple
python_sources
. So I've got
python_sources()
and then
inlined_python(entrypoint='main.py')
but given the entrypoint is a
SecondaryOwnerMixin
it doesn't seem to work
although maybe I'm missing a trick.
[WARN] No codegen files/targets matched. All codegen target types: experimental_shell_command, inlined_python
how does it know my target is meant to be a codegen target. ?? magic
ahh, i see
seems wrong, But defining a
SingleSourceField
with expected_num_files=0 and using that as a 'marker' seems to work
needs a
default
value, which will error if it doesn't exist. but ehhhh.
b
Yeah afaik that's the dirty little secret
1
I think if the field starts with underscore it might not be included in help 🤷‍♂️
a
the output paths on a codegen target need to be with slashes right? I can't use OutputPathField.value_or_default(file_ending="py")
b
I'm a fan of "do it and see what happens"
a
yeah, I'm just not sure what I'm doing. At the moment I'm just cargo-culting the "add codegen" doc page and not really sure if my outputs are approximate to the doc outputs
b
I suggest cargo-culting other in-repo plugins, personally 😂
w
@ambitious-actor-36781: were you able to get this figured out?
agree with @bitter-ability-32190 with regard to using codegen examples from
pantsbuild/pants
rather than from the docsite: there are more, with more variety of purpose
a
yeah. worked it out.
w
yea, awkward but working.
seems to be tangentially related to https://github.com/pantsbuild/pants/issues/15400 … i wonder if codegen should be using a FieldSet rather than a SourcesField type too. cc @hundreds-father-404