This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: gcc compiler on Windows
Type: Stage:
Components: Distutils Versions: Python 2.4
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: loewis Nosy List: loewis, mdehoon
Priority: high Keywords: patch

Created on 2004-11-30 10:06 by mdehoon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit mdehoon, 2004-11-30 10:06 Patch to distutils'
Messages (5)
msg47340 - (view) Author: Michiel de Hoon (mdehoon) * Date: 2004-11-30 10:06
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

python build --compiler=mingw32
# compiles the extension module using the gcc compiler
# on cygwin / mingw
python 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
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.
msg47341 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-04 13:41
Logged In: YES 

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

\Python25\python.exe build --compiler=mingw32

(i.e. all in one invocation)
msg47342 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-04 13:52
Logged In: YES 

Thanks for the patch. Committed as 1.65 and
NEWS 1.2363 and 1.1193.2.30
msg47343 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-12 14:04
Logged In: YES 

Unfortunately, the patch never sets initialized to True :-(
msg47344 - (view) Author: Michiel de Hoon (mdehoon) * Date: 2005-03-16 02:02
Logged In: YES 

Oops. I guess you're right. I saw that this was fixed in
CVS. Sorry for the trouble.
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41246
2004-11-30 10:06:26mdehooncreate