user
user

Reputation: 5390

How to compile Python extension with debug info using PIP

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)

Upvotes: 15

Views: 6447

Answers (1)

rutsky
rutsky

Reputation: 4110

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

Upvotes: 15

Related Questions