If `pants` manages its own virtual environments, h...
# general
e
If
pants
manages its own virtual environments, how do you debug your python code? I have used to just installing the app + needed libraries in a venv, running
ipython
and importing the code I'm working on. Can you somehow run
Copy code
pants python somescript.py
?
Or, is the workflow like 1. work in
venv
as you normally would, and debug here 2. deactivate
venv
3. run
pants
commands 4. activate
venv
again ?
r
So first of all, all the dependencies that your project needs should be defined either using
requirements.txt
or
pyprojec.toml
. You should check https://www.pantsbuild.org/docs/python-third-party-dependencies
b
e
Thanks a lot! I'll take a look on those!
b
Also, good ol
pdb
is an option too when running your code
Lastly,
test
also has the --debug-adaptor flag
e
You mean inserting
Copy code
import pdb; pdb.set_tracet()
into the source code or running pants equivalent of
Copy code
python -m pdb something.py
like (something like pants run --pdb something.py) ?
b
The former
1
I think technically just using
breakpoint()
when's too
You got options 😅
e
I've usually used
breakpoint()
with
PYTHONBREAKPOINT=IPython.embed
so I guess that would work similarly
b
It defaults to
pdb.set_trace
I Believe
e
that is correct
b
Well, there's a huge sack of options for ya, pick your favorites
👏 1