How do you tell setuptools to build an extension for --debug when using pyproject.toml / PEP 518

144 Views Asked by At

I have created a Python project with a C++ extension using pyproject.toml (PEP 518, PEP 517, PEP 621, PEP 660, etc.). I'm sure I could be doing some things better, but generally speaking it's working great.

In typical cases, this project will be built without C++ debug symbols, which is the default for Setuptools and works as I'd expect. However, for troubleshooting purposes, I want to document a process for building the project with debug symbols. Even if not specifically attaching a debugger, debug symbols can be helpful for diagnosing crashes, if/when they occur.

I have tried various incantations to pip install:

  • --debug: silently ignored, library still built with -DNDEBUG -g -O3
  • --global-option --debug ("WARNING: Ignoring --global-option when building ifaddrs4py using PEP 517" and "DEPRECATION: --build-option and --global-option are deprecated")
  • --config-setting="--global-option=--debug": fails with "error: option --debug not recognized" after first emitting "SetuptoolsDeprecationWarning: Incompatible `config_settings` passed to build backend."
  • --config-setting="--build-option=--debug": no warning, but still fails with "error: option --debug not recognized"
  • Adding [build_ext] \n debug = 1 to pyproject.toml like you would normally add to setup.cfg (see here)

The Setuptools documentation doesn't provide instructions on this is far as I can find.

I've seen several suggestions (like this) to use python setup.py build -g or python setup.py build --debug, but this is a deprecated way to use setup.py under the above PEPs.

Is it not possible under this new standard to build Python extensions with debug symbols? If it is, how to do this?

0

There are 0 best solutions below