https://pantsbuild.org/ logo
c

curved-policeman-2796

01/04/2023, 10:37 AM
Hi, is there a way to get pants to output 3rd party requirements for a target in a
requirements.txt
format? It looks like
./pants dependencies
used to do this with
--type=3rdparty
(see

https://www.youtube.com/watch?v=IpEv5cWfyko&t=120s&ab_channel=PantsBuild

) but that option seems to have disappeared.
From the docs, it looks like it was deprecated in 2.8: https://www.pantsbuild.org/v2.8/docs/reference-dependencies Is the recommended way still something like this?
Copy code
./pants dependencies --dependencies-transitive <target> | xargs ./pants peek --filter-target-type=python_requirement | jq -r '.[]["requirements"][]'
h

happy-kitchen-89482

01/04/2023, 12:12 PM
Something like that, yeah... The old way of doing this was perhaps more convenient for this specific use-case, but very ad-hoc
c

curved-policeman-2796

01/04/2023, 12:16 PM
Thanks - I don't mind wrapping the above in a script or something, but I'd have preferred to avoid doing that if Pants supported it directly.
Is there anywhere in the docs that includes (or could include) recipes like this? If I hadn't come across that youtube video and then searched through the old versions of the docs, I'm not sure I'd have come up with that myself.
h

happy-kitchen-89482

01/04/2023, 12:45 PM
There are various examples here that we could add to: https://www.pantsbuild.org/docs/project-introspection
(under "Piping other introspection commands into ./pants peek")
So yeah, adding this to one of those would be great! The docs are generated from sources in the repo, if you want to take a crack at it
c

curved-policeman-2796

01/04/2023, 1:04 PM
Ah that must be where that youtube video came from! (A colleague sent me the link - presumably he got it from that page.)
And yeah happy to have a rummage around the repo and maybe submit a PR once I've had a read of this!
f

fresh-cat-90827

01/04/2023, 1:45 PM
thanks, Alex, this is great. I was exploring this myself in https://pantsbuild.slack.com/archives/C046T6T9U/p1671482123490549 a couple weeks ago.