[Distutils] Patch for msvccompiler.py (Win32)

Lyle Johnson jlj@cfd1.cfdrc.com
Wed, 12 Apr 2000 17:46:05 -0500


Here's a patch for distutils/msvccompiler.py to ensure that the appropriate
Python import library (e.g. "python15.lib" or "python15_d.lib") is linked in
with your extension DLL on Windows. As my comment indicates, there's
probably a cleaner way to pick up the correct library name but this should
work for Python 1.5.x and Python 1.6.

Index: msvccompiler.py
===================================================================
RCS file: /projects/cvsroot/distutils/distutils/msvccompiler.py,v
retrieving revision 1.25
diff -c -r1.25 msvccompiler.py
*** msvccompiler.py	2000/03/31 19:04:25	1.25
--- msvccompiler.py	2000/04/12 22:43:28
***************
*** 329,334 ****
--- 329,346 ----
                              extra_preargs=None,
                              extra_postargs=None):

+ 	# Add the Python library to the standard library list.
+ 	# There's probably a more elegant way to determine the correct name ;)
+ 	if sys.winver == '1.5':
+ 	    pythonlib = 'python15'
+ 	else:
+ 	    pythonlib = 'python16'
+
+ 	if debug:
+ 	    pythonlib = pythonlib + '_d'
+
+ 	self.add_library(pythonlib)
+
          (objects, output_dir) = self._fix_object_args (objects,
output_dir)
          (libraries, library_dirs, runtime_library_dirs) = \
              self._fix_lib_args (libraries, library_dirs,
runtime_library_dirs)