Building Python extensions on Windows with GCC and Cygwin:

1.) Get and install Cygwin from http://www.cygwin.com/

2.) Make sure that you also install the GCC compiler.
I.e.: run cygwin-setup and add the following packages: 
* gcc-mingw 
* gcc-mingw-core 
* gcc-mingw-g++ 
* make 
This will pull in several other packages. 
DONT install the Cygwin Python, btw, unless you have a good reason. You dont need it if youre building extensions for Windows Python.

3.) Ensure that Cygwin tools are on your system path. E.g. add C:\cygwin\bin to your PATH (My Computer ? Properties ? Advanced ? Environment Variables).

4.) Add a distutils.cfg file to your C:\Python2x\Lib\distutils directory, containing the lines: 
[build]
compiler=mingw32

5.) Now you are ready to compile Python extensions. Run e.g. python setup.py install or "setupPILc2g.py build" to install a C extensions.

6.) Update: 2008-09-10 
Recent versions of Cygwin binutils have version numbers that are breaking the version number parsing, resulting in errors like: ValueError: invalid version number '2.18.50.20080625'

To fix this, edit distutils/version.py. At line 100, replace:
     version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$',
                        re.VERBOSE)
with
     version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? (\. (\d+))?$',
                            re.VERBOSE)


