is there a way to filter output of `./pants list :...
# general
f
is there a way to filter output of
./pants list ::
based on target type? For example, I want to get only the python libraries using something like
./pants list --type=python_library ::
. The only thing I could only find in the docs was something like this:
Copy code
# find external dependecies
./pants dependencies --type=3rdparty <lib-target>
found this in the cli. don't know if it is the correct solution.
Copy code
./pants list :: | xargs ./pants filter --filter-target-type=python_library
although this does not work for 3rdparty dependencies
h
This should work:
./pants filter --filter-target-type=python_library ::
And for third party targets:
./pants filter --filter-target-type=python_requirement_library ::
h
If you haven’t yet seen it, you may find https://www.pantsbuild.org/docs/project-introspection helpful. I still need to document
filter
- my bad!
f
thx
h
Also you can use
./pants filter --target-type=python_requirement_library ::
, rather than
./pants filter --filter-target-type=python_requirement_library ::
. They’re different ways of typing the same thing
f
sometimes I get this error
Copy code
error	27-Aug-2020 07:34:27	13:34:27 [ERROR] Unrecognized command line flag '--target-type' on global scope. Suggestions:
error	27-Aug-2020 07:34:27	--filter-target-type, --target-types-details, --target-types-output-file, --target-types-sep
this was my command
Copy code
./pants --version && ./pants --changed-since=develop --changed-include-dependees=transitive filter --target-type=python_library | xargs ./pants setup-py ./pants --changed-since=develop --changed-include-dependees=transitive filter --target-type=python_library | xargs -i ./pants setup-py {} -- sdist && ./pants --changed-since=develop --changed-include-dependees=transitive filter --target-type=python_binary
h
Hmm, I can't reproduce this with any of those commands.
Is there a missing
&&
after the first
xargs ./pants setup-py
though?
To explain Eric's comment: The
--filter-target-type
flag means "The
target_type
option on the
filter
scope." This can be shortened to
--target-type
if it comes immediately after the
filter
goal on the command line. So that error means that pants encountered
--target-type
not immediately after
filter
.
This seems to be happening because of the missing `&&`:
Copy code
./pants setup-py ./pants --changed-since=develop --changed-include-dependees=transitive filter --target-type=python_library
11:31:03.16 [ERROR] Unrecognized command line flag '--target-type' on global scope. Suggestions:
--filter-target-type, --target-types-details, --target-types-output-file, --target-types-sep
Whereas
Copy code
/pants setup-py && ./pants --changed-since=develop --changed-include-dependees=transitive filter --target-type=python_library
should work
f
yes. you are right. my bad. the error code was misleading 🙂
h
f
👍