This page describes how to compile C/C++ Python
extensions with Mingw:
http://sebsauvage.net/python/mingw.html
This process works. However, you need to patch
Python to get the 'python setup.py install' step to work
correctly. This is the second step in installing a Python
extension.
The first step: 'python setup.py build -cmingw32' works
fine.
The second step: 'python setup.py install' fails with the
following error:
"error: Python was built with version 6 of Visual Studio,
and extensions need to
be built with the same version of the compiler, but it
isn't installed."
This statement is factually untrue. Python uses .pyd
files to run Python extensions, which are actually .dll
files, and are compatible across different compilers and
compiler versions.
So open \Python\Lib\distutils\msvccompiler.py and
remove the warning (it's around line 211).
Or apply the patch:
--- msvccompiler.bak Thu Dec 4 09:38:22 2003
+++ msvccompiler.py Wed May 19 13:15:34 2004
@@ -208,11 +208,10 @@
self.__root = r"Software\Microsoft\Devstudio"
self.__paths = self.get_msvc_paths("path")
- if len (self.__paths) == 0:
- raise DistutilsPlatformError, \
- ("Python was built with version %s of
Visual Studio, "
- "and extensions need to be built with the
same "
- "version of the compiler, but it isn't
installed." % self.__version)
+ # Note: Extensions CAN be built with Mingw32.
+ # See http://sebsauvage.net/python/mingw.html.
+ # The .pyd files created are DLLs, and these are
compatible across
+ # different compilers and compiler versions.
self.cc = self.find_exe("cl.exe")
self.linker = self.find_exe("link.exe")
|