https://pantsbuild.org/ logo
i

incalculable-yacht-75851

12/16/2021, 12:15 AM
I'm building a python script to format files not tracked by pants (rogue python scripts, markdown, html, json, yaml, etc.) and was wondering if the
requirements.txt
file will install a dependency in CI to give my script access to it from the shell. Now, I could just load
black
as a module but I'd rather have all commands for
black
,
prettier
,
scalafmt
, and any other formatters to be handled the same exact way (subprocess.run). Will
black
be available from the shell w/ the requirements.txt file specifying
black
as a dep?
h

hundreds-father-404

12/16/2021, 12:19 AM
Hi Ken! You'd need to install your
requirements.txt
independently of Pants, like directly creating a virtual environment and doing
pip install -r reqs.txt
. When Pants installs dependencies, it does so in a sandbox and it is not exposed to the general system
i

incalculable-yacht-75851

12/16/2021, 12:22 AM
Thx! This was my concern.
h

hundreds-father-404

12/16/2021, 12:23 AM
Alternatively, Pants 2.9 added
./pants export
which will create a virtual environment of your
constraints.txt
if you're using
[python].requirement_constraints
i

incalculable-yacht-75851

12/16/2021, 12:25 AM
interesting. I'll give that a look.