tall-salesclerk-68028
08/28/2024, 4:22 PMBUILD
file's path and the target name for each string. However I have around 50 files that would require these ignores.fresh-cat-90827
09/01/2024, 3:20 PMpants.toml
file (under [tailor]
or [cli.alias]
), so you do need to provide string literals.
Getting the list of paths is fairly straightforward, however, e.g.
$ tree cheeseshop/data
cheeseshop/data
āāā dir1
ā āāā dir1A
ā ā āāā __init__.py
ā ā āāā pymod.py
ā ā āāā test_pymod.py
ā āāā __init__.py
āāā dir2
ā āāā dir2A
ā ā āāā __init__.py
ā ā āāā pymod.py
ā ā āāā test_pymod.py
ā āāā __init__.py
āāā dir3
ā āāā dir3A
ā ā āāā __init__.py
ā ā āāā pymod.py
ā ā āāā test_pymod.py
ā āāā __init__.py
āāā __init__.py
7 directories, 13 files
I've created a directory with source and test targets. Now, by default both source and tests targets are going to be created:
$ pants tailor --check cheeseshop/data::
17:18:53.37 [INFO] Initializing scheduler...
17:18:56.65 [INFO] Scheduler initialized.
Would create cheeseshop/data/dir1/dir1A/BUILD:
- Add python_sources target dir1A
- Add python_tests target tests
Would create cheeseshop/data/dir2/dir2A/BUILD:
- Add python_sources target dir2A
- Add python_tests target tests
Would create cheeseshop/data/dir3/dir3A/BUILD:
- Add python_sources target dir3A
- Add python_tests target tests
To fix `tailor` failures, run `pants tailor`.
with a list of targets to ignore, only the sources are going to be tailored:
$ pants tailor --check --tailor-ignore-adding-targets="[$(find cheeseshop/data -type d -name 'dir*' | sed "s|$|:tests|;s|^|'|;s|$|'|" | paste -sd ',' -)]" cheeseshop/data::
Would create cheeseshop/data/dir1/dir1A/BUILD:
- Add python_sources target dir1A
Would create cheeseshop/data/dir2/dir2A/BUILD:
- Add python_sources target dir2A
Would create cheeseshop/data/dir3/dir3A/BUILD:
- Add python_sources target dir3A
To fix `tailor` failures, run `pants tailor`.
with the paths evaluated to:
$ echo "[$(find cheeseshop/data -type d -name 'dir*' | sed "s|$|:tests|;s|^|'|;s|$|'|" | paste -sd ',' -)]"
['cheeseshop/data/dir1:tests','cheeseshop/data/dir1/dir1A:tests','cheeseshop/data/dir2:tests','cheeseshop/data/dir2/dir2A:tests','cheeseshop/data/dir3:tests','cheeseshop/data/dir3/dir3A:tests']
fresh-cat-90827
09/01/2024, 3:24 PMPANTS_TAILOR_IGNORE_ADDING_TARGETS
env var with those paths pre-populated (either locally in your Shell .rc
file or in CI). Is that any good?
It should be possible to extend the tailor
logic to accept something more complex like a glob with a list of target types, but I am not sure how useful this is. I think most often, it is sufficient to ignore a handful of directories which you don't want to become "visible" to Pants. Or it could be a few directories where you know you don't want to create test python_requirement
targets because they are used outside of Pants.