This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Enable Debug Build For Python Native Modules in Windows, with Visual Studio Toolchain
Type: compile error Stage: resolved
Components: Build, Windows Versions: Python 3.8
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jmoguill2, paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2020-11-12 23:06 by jmoguill2, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg380861 - (view) Author: Jeff Moguillansky (jmoguill2) Date: 2020-11-12 23:06
We developed a Python module that interfaces with native code via Cython.  
We currently build on Windows with Visual Studio Toolchain. 
We encounter the following issues when trying to build a debug version:
1) 3rd party modules installed via PIP are Release mode, but Visual Studio toolchain doesn't allow to mix Debug and Release libs.  To workaround this issue, we build our module in "Release" mode, with debug symbols enabled, and with compiled optimization disabled (essentially a hack). 
2) To build our module we currently use the following hack:
step 1: run python.exe build --compiler=msvc
step 2: extract the output
step 3: change /Ox to /Od (disable compiler optimization)
        add /Zi flag to compiler flags (enable debug symbols)
        add /DEBUG flag to linker flags

Please advise what is the best solution?
msg380958 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-11-14 05:45
This tracker is for developing patches to the cpython repository.  Questions are better asked on the python-list and occasionally the pydev mailing lists.  I am leaving this open in case there is a doc change request lurking somewhere.
msg387356 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-19 21:02
That's the best solution.

Alternatively, you can install the debug binaries of CPython using the option in the installer, recompile 3rd party packages from source, and use true debug builds that way.

Unfortunately, there's not much we can do about 3rd party packages being complicated to compile. You'll have to work with those projects.
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86504
2021-02-19 21:02:26steve.dowersetstatus: open -> closed
resolution: not a bug
messages: + msg387356

stage: resolved
2020-11-14 05:45:51terry.reedysetnosy: + terry.reedy, paul.moore, tim.golden, zach.ware, steve.dower
messages: + msg380958
components: + Windows
2020-11-12 23:06:15jmoguill2create