hey team. Is there a prettier way to package all `...
# general
f
hey team. Is there a prettier way to package all
pex_binary
targets in a particular project within a Pants monorepo than doing:
Copy code
./pants filter --target-type=pex_binary --filter-address-regex="myproject" :: | xargs ./pants package
?
c
No idea.. but you can make the above slightly prettier on the eye with an alias:
Copy code
[cli.alias]
myproject-binaries = "--target-type=pex_binary --filter-address-regex=myproject ::"
Then:
Copy code
./pants filter myproject-binaries | xargs ./pants package
🙌 1
p
This can be achieved by adding tags to the relevant pex binary targets and the use advanced targets selection https://www.pantsbuild.org/docs/advanced-target-selection
f
@polite-garden-50641 thanks for this, this is definitely an option, however, this implies making changes to the declarations which I’d like to avoid 🙂
p
So maybe use a spec file with the list of targets ( you can the filter command to create it) https://www.pantsbuild.org/docs/advanced-target-selection
👀 1
e
How about
./pants package myproject::
🤯 1
That will also package
python_distribution
targets, but maybe that's OK for you use case?
f
black magic! 😄 works like a charm, just what I needed. I am fine with
python_distribution
as well, indeed. Thanks @enough-analyst-54434
e
The magic is just globs.
:
Is all targets in this dir,
::
is all targets recursively under this dir.
c
Haha, that was too easy 😛
f
The magic is just globs. 
:
 Is all targets in this dir, 
::
 is all targets recursively under this dir.
aha, I was using
./pants package ::
all the time, but it didn’t occur to me to put a directory name in front of
::
cheers
e
Well, it uses targets though and you shouldn't have to know about those unless forced. You can also work in files:
./pants package 'myproject/***'*
(let Pants expand file globs) or
./pants package myproject/**
(if your shell supports it).
✅ 1