Remark concerning msvc 7.0 for c/c++ extensions for python in windows

Hello, I have a small remark concerning msvc 7.0 and the pre-compiled version of python in windows. Recently I tried to compile the source-code for a library named PyMat, a link between python and matlab. I wanted to use this library in windows with python2.3. I tried to compile with microsoft visual c++ 7.0 ( NET ) and disutils. The pre-compiled version of python 2.3 is however compiled with msvc 6.0... This seemed to be a problem for disutils. I recieved following error/ following exception is raised: "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." Thx to google, I found the following sollution: http://mail.python.org/pipermail/patches/2004-May/014807.html In $python_root$/lib/disutils/msvccompiler.py you have to comment out some lines (approx: line 214) ## 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)The compiled library works correct. The library compiled and seems to work correct! Now my question is: is it absolutely necessary to compile everything with the same msvc as python is compiled with? If not, is the line in msvccompiler.py absolutely necessary? Could this be replaced with a warning, instead of raising an exception? Simply aborting completely the compilation proces seems kind of drastic. greetz and thx for reading so far Peter ps. I presume this problem still is present in python 2.4, because msvccompiler.py still contains the conflicting lines in the cvs-version...

Peter Vandersteegen <Peter.Vandersteegen@intec.Ugent.be> writes: [...]
Now my question is: is it absolutely necessary to compile everything with the same msvc as python is compiled with? If not, is the line in msvccompiler.py absolutely necessary? Could this be replaced with a warning, instead of raising an exception? Simply aborting completely the compilation proces seems kind of drastic.
Strictly speaking, it is necessary to link the extension module to the same MS runtime libraries as the python dll. For MSVC 6, this is MSVCRT.DLL, for MSVC7.1, it is MSVCR71.DLL. If you don't have MSVC6, you can try to compile your extensions with Mingw32, which also links with MSVCRT.DLL. Or you compile Python yourself with the C compiler you have, and do the same for the extensions.
greetz and thx for reading so far
Peter
ps. I presume this problem still is present in python 2.4, because msvccompiler.py still contains the conflicting lines in the cvs-version...
It's not a Python problem ;-) Thomas
participants (2)
-
Peter Vandersteegen
-
Thomas Heller