I have source code for an extension in Python. I want to see debug symbols for that extension when I debug it. How do I tell PIP to compile and link debug symbols for my extension?
(Preferably platform agnostic, else Linux)
In order to debug the C/C++ code of an extension, you need to use the native debugger, GDB or LLDB, and debug the interpreter process that loads your script and runs the application. For that, you can either attach to a running Python process or debug a properly configured Custom Build Application.
Directly use command python pdg-debug.py without -m pdb to run the code. The program will automatically break at the position of pdb. set_trace() and enter the pdb debugging environment. You can use the command p variable to view the variables or use the command c to continue to run.
Python in Visual Studio supports debugging without a project. With a stand-alone Python file open, right-click in the editor, select Start with Debugging, and Visual Studio launches the script with the global default environment (see Python environments) and no arguments.
You need to invoke setup.py
's build
command with --debug
flag during package installation. Using pip
additional flags to setup.py
can be passed using --global-option
:
pip install --no-binary :all: --global-option build --global-option --debug PACKAGE
In case of errors try upgrading pip
and setuptools
:
pip install -U setuptools
pip install -U pip
I found this information in this blogpost by Jonathan Lange: https://jml.io/2015/08/debugging-python-with-gdb.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With