[Cython] Windows Debug build improvement

Wolfgang tds333 at gmail.com
Thu Jul 18 15:24:21 CEST 2013


Hi,

I tried to submit a improvement for the Windows build but the tracker is not
accessible without a login.

On Windows if someone does a Debug build of an extension the flag _DEBUG is
set and so the Python Interpreter sets Py_DEBUG and for all extension modules
"_d" is appended to load the debug version of a module.
This is not really practical because then all modules and the Python
Interpreter must be build in Debug mode. For some modules this is even not
possible for Windows. :-(

To do a debug build for a Cython generated extension with a normal Python
Interpreter (none Debug) I have to patch the pyconfig.h file and undef _DEBUG
or I must patch the generated c file from Cython to undef _DEBUG before
pyconfig.h or Python.h is included. (and enable it afterwards)

Is it possible to add a flag to Cython to generate code that does this ?

Something like described in Boost.Python:
http://hepunx.rl.ac.uk/BFROOT/dist/releases/26.0.0/boost/libs/python/doc/building.html

It is enough to have a new Preprocessor Flag, if set, then surround the
Python.h inclusion with a disabled _DEBUG.

My workarround is to disable it before pyconfig.h (Python.h) include:

#ifdef _DEBUG
#undef _DEBUG
#define _RESTORE
#endif

and enable it afterwards

#ifdef _RESTORE
#define _DEBUG
#undef _RESTORE
#endif


Regards,

Wolfgang


More information about the cython-devel mailing list