Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain pre-built *debug* version of Python library (e.g. Python27_d.dll) for Windows

Firstly, I should state that my current development environment is MSYS + mingw-w64 + ActivePython under Windows 7 and that on a normal day I am primarily a Linux developer. I am having no joy obtaining, or compiling, a version of the Python library with debug symbols.

I need both 32bit and 64bit debug versions of the Python27.dll file, ideally. I want to be able to embed Python and implement Python extensions in C++, and be able to call upon a seamless debugging facility using the gdb-7.4 I have built for mingw-w64, and WingIDE for the pure Python side of things.

Building Python 2.7.3 from source with my mingw-w64 toolchain is proving too problematic -- and before anyone flames me for trying: I acknowledge that this environment is unsupported, but I thought I might be able to get this working with a few judicious patches (hacks) and:

make OPT='-g -DMS_WIN32 -DWIN32 -DNDEBUG -D_WINDOWS -DUSE_DL_EXPORT'

I was wrong... I gave up at posixmodule.c since the impact of my changes became uncertain; ymmv.

I have tried building with Visual C++ 2010 Express but being primarily a Linux developer the culture-shock is too much for me to bear today; the Python project does not even import successfully. Apparently, I need Visual C++ 2008, yet I am already convinced I don't want to go down this road if at all possible...

It's really surprising to me that there is not a zip-file providing the requisite .dlls somewhere on the Internet. ActiveState should really provide these as an optional download with each release of ActivePython that they make -- perhaps that's where the paid support comes in ;-).

What is the best way to obtain the Python debug library files given my environment?

like image 534
codeasone Avatar asked Apr 25 '12 12:04

codeasone


2 Answers

I've just built CPython 2.7.5 in debug mode with Visual Studio 2012 Express (free).

I documented the process via wiki page: https://wiki.python.org/moin/VS2012

like image 50
Nick Avatar answered Nov 11 '22 11:11

Nick


The best way to create a debug version of Python under Windows is to use the Debug build in the Visual Studio projects that come with the Python source, using the compiler version needed for the specific Python release, i.e. VS 2008.

There may be other ways, but this is certainly the best way.

If you really need a 64-bit debug build also, the best way is to buy a copy of VS 2008 (i.e. not use the Express version). It may be possible to create an AMD64 debug build using the SDK 64-bit compiler, but again, using the officially-supported procedures is the best way.

like image 29
Martin v. Löwis Avatar answered Nov 11 '22 09:11

Martin v. Löwis