trying to get Cython to work

Thanks Craig for the blog post on using Cython. I tried to squeeze every millisecond from one of my modules, but its still not as fast as I’d want. Not having anyone else who could port the module to C++ and having only basic C knowledge, Cython seems like a great option.
For now I’m trying to just convert the pure Python module to C with Cython and it doesn’t really work.

I think this topic might be useful to others, so I’ll post all my steps here.

  1. I could configure Cython to use MinGW instead of VisualStudio in Windows by following these instructions: wiki.cython.org/InstallingOnWindows

  2. Latest MinGW wasn’t working properly with the distutils which comes with Python 2.7.
    The version of gcc this installer downloads seems to work though: “mingw-get-inst-20110530.exe”.
    sourceforge.net/projects/mingw/f … -20110530/

  3. I’m using a 64bit version of Windows 7 and the MinGW installer didn’t seem to add anything to the Path variable, so “gcc” was not found by distutils. I had to add “C:\MinGW\bin” and “C:\MinGW\include” to the Path variable manually.

Then I could get the example from the Cython manual to work.
For Craig’s example, you’ll need to change the Panda version in the strings inside setup.py, of course.
I still get an error, though.

running install
running build
running build_ext
cythoning testc.pyx to testc.cpp
building 'testc' extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Panda3D-1.8.0\include -IC:\
Panda3D-1.8.0\python\include -IC:\Panda3D-1.8.0\python\PC -c testc.cpp -o build\
temp.win32-2.7\Release\testc.o /EHsc
gcc: /EHsc: No such file or directory
In file included from C:\Panda3D-1.8.0\include/pandabase.h:22:0,
                 from C:\Panda3D-1.8.0\include/geom.h:18,
                 from testc.cpp:273:
C:\Panda3D-1.8.0\include/dtoolbase.h:174:20: fatal error: minmax.h: No such file
 or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

I don’t know where “minmax.h” is supposed to be.

And here is the error when trying to compile my own module:

running install
running build
running build_ext
cythoning testc.pyx to testc.cpp
building 'testc' extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Panda3D-1.8.0\include -IC:\
Panda3D-1.8.0\python\include -IC:\Panda3D-1.8.0\python\PC -c testc.cpp -o build\
temp.win32-2.7\Release\testc.o /EHsc
gcc: /EHsc: No such file or directory
testc.cpp:28143:1: warning: deprecated conversion from string constant to 'char*
'
error: command 'gcc' failed with exit status 1