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.

classification
Title: gcc compiler on Windows
Type: Stage:
Components: Distutils Versions: Python 2.4
process
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.

Files
File name Uploaded Description Edit
msvccompiler.py.diff mdehoon, 2004-11-30 10:06 Patch to distutils' msvccompiler.py
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
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.
msg47341 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-04 13:41
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)
msg47342 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-04 13:52
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
msg47343 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-12 14:04
Logged In: YES 
user_id=21627

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

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