views:

1012

answers:

2

I have a C extension module and it would be nice to distribute built binaries. Setuptools makes it easy to build extensions modules on OS X and GNU/Linux, since those OSs come with GCC, but I don't know how to do it in Windows.

Would I need to buy a copy of Visual Studio, or does Visual Studio Express work? Can I just use Cygwin or MinGW?

+8  A: 

You can use both MinGW and VC++ Express (free, no need to buy it).

See:

  1. http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/
  2. http://eli.thegreenplace.net/2008/06/27/creating-python-extension-modules-in-c/
Eli Bendersky
Thanks. Your guide to compiling extensions with mingw worked perfectly.
Will Harris
Hey just wanted to let you know, I followed your guide under #1 (using the setup.py and hellomodule.c files provided in footnote 1 of the article) and everything worked like a charm. I am using Windows XP 32 bit, Python 2.6 and MinGW 4.5.0. I did not have to mess around with that .a/.dll stuff. Thanks!
oob
+1  A: 

Setuptools and distutils don't come with gcc, but they use the same compiler Python was built with. The difference is mostly that on the typical UNIX system that compiler is 'gcc' and you have it installed.

In order to compile extension modules on Windows, you need a compiler for Windows. MSVS will do, even the Express version I believe, but it does have to be the same MSVC++ version as Python was built with. Or you can use Cygwin or MinGW; See the appropriate section of Installing Python Modules.

Thomas Wouters
I am stumbled by the fact that you cannot use VS 2005 or newer, but you can use MinGW (a completely different compiler!)...
Roman Plášil