Issue 1075887: gcc compiler on Windows (original) (raw)
C extension modules can be built for Python on Windows with various compilers, such as Borland's C compiler and the gcc compiler using cygwin/mingw. With Python 2.3, a binary installer for Windows can be built as follows:
python setup.py build --compiler=mingw32
compiles the extension module using the gcc compiler
on cygwin / mingw
python setup.py bdist_wininst
to create the binary installer.
Hence, no need for Microsoft's compiler.
With Python 2.4, a problem arises with the bdist_wininst command (and also with python setup.py install) if a user does not have Microsoft's compiler installed, even if gcc or Borland's compiler is used to compile the extension module.
The problem is that distutils first creates an MSVCCompiler object and then checks if anything still needs to be compiled. In Python 2.4, the init function of MSVCCompiler checks if the version of the installed Microsoft VC compiler is compatible with the version that was used to build Python itself. If Microsoft's VC compiler is not installed, init will fail, even though the extension module has already been compiled by gcc or Borland's compiler.
The solution, in the attached patch, is to postpone the full initialization of MSVCCompiler until Distutils determines that there is something left to be compiled. For users of gcc or Borland, MSVCCompiler's init function does not need Microsoft VC to be installed. For users of Microsoft VC, the remainder of the initialization is performed when MSVCCompiler is asked to compile or link something for the first time. Hence, both gcc or Borland and Microsoft VC can be used to build extension modules for Python on Windows, just like in Python 2.3.