[Patches] [ python-Patches-1075887 ] gcc compiler on Windows

SourceForge.net noreply at sourceforge.net
Sat Mar 12 15:04:39 CET 2005


Patches item #1075887, was opened at 2004-11-30 11:06
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1075887&group_id=5470

Category: Distutils and setup.py
Group: Python 2.4
Status: Closed
Resolution: Accepted
Priority: 7
Submitted By: Michiel de Hoon (mdehoon)
Assigned to: Martin v. Löwis (loewis)
Summary: gcc compiler on Windows

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2005-03-12 15:04

Message:
Logged In: YES 
user_id=21627

Unfortunately, the patch never sets initialized to True :-(

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2005-03-04 14:52

Message:
Logged In: YES 
user_id=21627

Thanks for the patch. Committed as

msvccompiler.py 1.65 and 1.64.2.1
NEWS 1.2363 and 1.1193.2.30


----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2005-03-04 14:41

Message:
Logged In: YES 
user_id=21627

I see. Notice that you can get the compilation to pass using

\Python25\python.exe setup.py build --compiler=mingw32
bdist_wininst

(i.e. all in one invocation)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1075887&group_id=5470


More information about the Patches mailing list