[Patches] [ python-Patches-957033 ] Allow compilation of C/C++ Python extensions without MSVC

SourceForge.net noreply at sourceforge.net
Wed May 19 16:40:45 EDT 2004


Patches item #957033, was opened at 2004-05-19 20:37
Message generated for change (Comment added) made by connelly
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=957033&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Connelly (connelly)
Assigned to: Nobody/Anonymous (nobody)
Summary: Allow compilation of C/C++ Python extensions without MSVC

Initial Comment:

This page describes how to compile C/C++ Python 
extensions with Mingw:

http://sebsauvage.net/python/mingw.html

This process works.  However, you need to patch 
Python to get the 'python setup.py install' step to work 
correctly.  This is the second step in installing a Python 
extension.

The first step: 'python setup.py build -cmingw32' works 
fine.
The second step: 'python setup.py install' fails with the 
following error:

"error: Python was built with version 6 of Visual Studio, 
and extensions need to
be built with the same version of the compiler, but it 
isn't installed."

This statement is factually untrue.  Python uses .pyd 
files to run Python extensions, which are actually .dll 
files, and are compatible across different compilers and 
compiler versions.

So open \Python\Lib\distutils\msvccompiler.py and 
remove the warning (it's around line 211).  

Or apply the patch:

--- msvccompiler.bak	Thu Dec  4 09:38:22 2003
+++ msvccompiler.py	Wed May 19 13:15:34 2004
@@ -208,11 +208,10 @@
             self.__root = r"Software\Microsoft\Devstudio"
         self.__paths = self.get_msvc_paths("path")
 
-        if len (self.__paths) == 0:
-            raise DistutilsPlatformError, -                  ("Python was built with version %s of 
Visual Studio, "
-                   "and extensions need to be built with the 
same "
-                   "version of the compiler, but it isn't 
installed." % self.__version)
+        # Note: Extensions CAN be built with Mingw32.
+        # See http://sebsauvage.net/python/mingw.html.
+        # The .pyd files created are DLLs, and these are 
compatible across
+        # different compilers and compiler versions.
 
         self.cc = self.find_exe("cl.exe")
         self.linker = self.find_exe("link.exe")


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

>Comment By: Connelly (connelly)
Date: 2004-05-19 20:40

Message:
Logged In: YES 
user_id=1039782

BTW: You can test this out with the extension module 
myspell-python, available at:

  http://www.zgoda.biz/dnld/myspell-python-1.0-
minimal.tar.gz

Follow the directions at 
http://sebsauvage.net/python/mingw.html.  You'll encounter 
an error.  Patch msvccompiler.py and try again; now it works.


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

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



More information about the Patches mailing list