Patches item #957033, was opened at 2004-05-19 22:37 Message generated for change (Comment added) made by loewis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=957033&group_id=5470
Category: None Group: None >Status: Closed >Resolution: Out of Date 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: Martin v. L�wis (loewis) Date: 2005-03-04 15:02 Message: Logged In: YES user_id=21627 With the current CVS, this problem is fixed: The install command does not require a MSVC anymore if there is nothing to build. Closing the patch as out-of-date. ---------------------------------------------------------------------- Comment By: Thomas Heller (theller) Date: 2004-06-01 17:41 Message: Logged In: YES user_id=11105 This is not a bug. The 'install' command internally runs the 'build' command, and this command misses the -cmingw32 flag. Basically, you have two options to build and install the extension: - call 'python setup.py build -cmingw32 install' - create/edit your distutils configuration file setup.cfg. Add this section (untested, but you get the idea): [build_ext] compiler=mingw32 See distutils docs for more details - the latter way is the recommended one. Does this help? ---------------------------------------------------------------------- Comment By: Connelly (connelly) Date: 2004-05-19 22:41 Message: Logged In: YES user_id=1039782 Here's the upload. ---------------------------------------------------------------------- Comment By: Connelly (connelly) Date: 2004-05-19 22: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 _______________________________________________ Patches mailing list [email protected] http://mail.python.org/mailman/listinfo/patches
