Is there a built-in way to change the naming schem...
# general
a
Is there a built-in way to change the naming scheme of
tailor
? Or would I need to write a plugin for that?
e.g. append
_src
to every
python_sources
target's name
I think I could create a macro that sets the name, and then use
alias_mapping
👍 1
👆 1
h
Let us know if that worked for your needs
a
Hmm so I think this isn't really doable this way. The problem I have is that I often find the auto-generated target names (based on the directory) ambiguous. I'd often like to name the final artifact this way, so stuff like
docker_image
but the name is taken by
python_sources
. I rarely use the sources targets in any pants invocations. So I figured I'd like to use the format
<dirname>_src
for sources.
I tried the approach above, but the name is defined implicitly on
python_sources
if not set. Tailor generates
python_sources()
so there's no way to get the name from **kwargs. So I think the only way to achieve this would be to write a plugin. Am I right?
Or actually, I think I need to test it some more
Copy code
def custom_python_sources(**kwargs):
    kwargs["name"] = f"{kwargs['name']}_src"
    python_sources(**kwargs)
this is what I came up with and this is the error I get with
custom_python_sources()
in BUILD
Copy code
21:49:53.58 [ERROR] 1 Exception encountered:

Engine traceback:
  in `list` goal
  in Find targets from input specs
  in Search for addresses in BUILD files - src/b24/celery

MappingError: Failed to parse ./src/b24/celery/BUILD:
'name'