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

fresh-cat-90827

07/11/2022, 10:11 AM
is there a more robust way to get 3rd-party dependencies out of a project in Pants than parsing output of the
./pants dependencies project::
or
./pants peek project::
commands? I was relying on
./pants dependencies project:: --dependencies-type=3rdparty
but this option was deprecated in
2.9.0
. The help docs say that a more robust way of querying dependencies should be available in the later versions, but I struggle to find any.
h

hundreds-father-404

07/11/2022, 1:12 PM
We generally recommend using
./pants export ::
to create a virtualenv instead. But if you just want the strings, the script in https://www.pantsbuild.org/v2.10/docs/python-third-party-dependencies#manual-lockfile-generation-techniques has a snippet using
peek
+
jq
f

fresh-cat-90827

07/11/2022, 1:23 PM
thanks, Eric! Sorry, I should have provided more context. What I am trying to do is to get a list of 3rd party dependencies that a project depends on (e.g.
projectA
depends on
numpy
and
pandas
— Pants should know this thanks to dependency inference). The
peek
+
jq
example gives me a list of requirements as per my
requirements.txt
file, not the actual dependencies of the projects. E.g. I’ve just added a few random PyPI packages (that no project is using) to the
requirements.txt
and the
export
command happily (totally expected though) created the venv with those deps. The use case is that the
requirements.txt
may contain arbitrary packages and I would like to make sure that all of them are actually being used in the projects. This is to find requirements that are present but are not used by code (some project depended on the package, but then code is refactored/removed and not this package is no longer required).
e

enough-analyst-54434

07/11/2022, 4:13 PM
That sounds like a built-in lint everyone would appreciate for all languages Pants supports!
4
4 Views