https://pantsbuild.org/ logo
#general
Title
# general
f

fresh-cat-90827

10/28/2021, 11:28 AM
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

curved-television-6568

10/28/2021, 11:38 AM
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

polite-garden-50641

10/28/2021, 11:56 AM
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

fresh-cat-90827

10/28/2021, 12:02 PM
@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

polite-garden-50641

10/28/2021, 12:11 PM
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

enough-analyst-54434

10/28/2021, 3:05 PM
How about
./pants package myproject::
🤯 1
That will also package
python_distribution
targets, but maybe that's OK for you use case?
f

fresh-cat-90827

10/28/2021, 3:07 PM
black magic! 😄 works like a charm, just what I needed. I am fine with
python_distribution
as well, indeed. Thanks @enough-analyst-54434
e

enough-analyst-54434

10/28/2021, 3:08 PM
The magic is just globs.
:
Is all targets in this dir,
::
is all targets recursively under this dir.
c

curved-television-6568

10/28/2021, 3:11 PM
Haha, that was too easy 😛
f

fresh-cat-90827

10/28/2021, 3:13 PM
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

enough-analyst-54434

10/28/2021, 3:35 PM
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