[Cython] Windows Debug build improvement

Wolfgang tds333 at gmail.com
Thu Jul 25 17:46:15 CEST 2013


Hi,

thank you.
But I don't use setup.py/distutils for the build.

I use cython as a code generator and include the generated files into a
Visual Studio project. But that's no problem, VS has the ability of custom
build steps.
A simple build with distutils is not possible.
Because I use not the VC version used to build the python executable.
The external library has other dependencies.

Also the project uses over 15 other Python libraries and none of them is
available as a Windows debug version with "_d" extension.

Basically this is a flaw in Python itself. For a Linux build of Python
there is the "Py_DEBUG" flag used as indicator, set during config. For Windows
this is not explicit, it is set if "_DEBUG" is set. And I think this implicit
setting is not good. (because this flag is widely used elsewhere)
But I have to workaround it, even if Python 3.4 or later changes it
I still use Python 2.7.

Boost Python does this in its configuration, see documentation:
--- copied from boost documentation

On unix-variant platforms, the debugging versions of Python's data structures
will only be used if the symbol Py_DEBUG is defined. On many windows
compilers, when extension modules are built with the preprocessor symbol
_DEBUG, Python defaults to force linking with a special debugging version of
the Python DLL. Since that symbol is very commonly used even when Python is
not present, Boost.Python temporarily undefines _DEBUG when Python.h is
#included from boost/python/detail/wrap_python.hpp - unless BOOST_DEBUG_PYTHON
is defined. The upshot is that if you want “python debugging”and you aren't
using Boost.Build, you should make sure BOOST_DEBUG_PYTHON is defined, or
python debugging will be suppressed.

---



Regards,

Wolfgang

> Message: 1
> Date: Wed, 24 Jul 2013 21:15:49 +0600
> From: "Nikita Nemkin" <nikita at nemkin.ru>
> To: "Core developer mailing list of the Cython compiler"
> 	<cython-devel at python.org>
> Subject: Re: [Cython] Windows Debug build improvement
> Message-ID: <op.w0qfcnj8yabthb at juga>
> Content-Type: text/plain; charset=windows-1251; format=flowed;
> 	delsp=yes
> 
> On Thu, 18 Jul 2013 19:24:21 +0600, Wolfgang <tds333 at gmail.com> wrote:
> 
>> 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 debug my extensions on Windows (in Visual Studio), I just add
> the appropriate compiler flags:
> 
> extension = Extension(
>      ...
>      extra_compile_args=['/Zi', '/Od'],  # generate PDB, disable  
> optimization
>      extra_link_args=['/DEBUG'])         # preserve debug info
> 
> Add to that symbol files for the Python release you are using
> ("program database" links on this page  
> http://www.python.org/getit/releases/2.7.5/)
> and you will have a comfortable debugging environment.
> 
> 
> Best regards,
> Nikita Nemkin
> 
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel
> 
> 
> ------------------------------
> 
> End of cython-devel Digest, Vol 30, Issue 17
> ********************************************
> 



More information about the cython-devel mailing list