[Distutils] Compiling extensions with MingW32 / python.org binary

Michael Droettboom mdboom at jhu.edu
Wed Jan 14 15:38:34 EST 2004

Michael Droettboom wrote:

> M.-A. Lemburg wrote:
>> Michael Droettboom wrote:
>>> Moore, Paul wrote:
>>>> From: Michael Droettboom
>>>>> I've come across a possible bug with --compiler=mingw32 and 
>>>>> --compiler=cygwin support when using the standard python.org 2.3.3 
>>>>> .exe.  (I do this so I can distribute binary installers that work 
>>>>> with the standard Python distribution, but don't want to buy MS 
>>>>> Visual Studio...)
>>>> I don't have a C extension handy to try at the moment, but I haven't
>>>> had a problem in the past using mingw (--compiler=mingw32) and
>>>> python.org python 2.3.3.
>>>> Can you clarify what you are having problems with? Using python.org
>>>> python with cygwin gcc (--compiler=cygwin)? If so, I have no 
>>>> experience
>>>> with that, so I can't help (beyond saying that mingw works fine, so
>>>> don't break that in the process of fixing the cygwin case!)
>>> I'm having problems with both --compiler=cygwin and --compiler=mingw32.
Okay, the detail that I realise is important is that this is a C++ 

 From unixccompiler.py (line 169 in Python 2.3.3):

                if target_desc == CCompiler.EXECUTABLE:
                    linker = self.linker_exe[:]
                    linker = self.linker_so[:]
                if target_lang == "c++" and self.compiler_cxx:  #***
                    linker[0] = self.compiler_cxx[0]                    #***
                self.spawn(linker + ld_args)
            except DistutilsExecError, msg:
                raise LinkError, msg

Since target_lang == "c++", and self.compiler_cxx is defined in 
unixccompiler.py as "cc", but not overridden in cygwinccompiler.py (as 
compiler, compiler_so, linker_exe and linker_so are...) we end up with 
the command line having cc instead of gcc at the front.

In the Python CVS history, it seems that the lines marked *** were added 
since the release22-maint branch, which explains why this used to work 
for me with Python 2.2.

Under a Cygwin or Mingw32 build where Python was built with Cygwin, the 
symlink from cc to gcc works.  However, "standard" Windows executables, 
such as the python.org interpreter can not follow Cygwin symlinks and it 

I seems that compiler_cxx should be defined as "gcc -mcygwin" and "gcc 
-mnocygwin" in cygwinccompiler.py.  I have a patch -- not sure what the 
procedure is to submit it, however.

Hope I'm on the right track...


More information about the Distutils-SIG mailing list