summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-03-31 03:50:23 (GMT)
committerGreg Ward <gward@python.net>2000-03-31 03:50:23 (GMT)
commit842296480e80873de5f5042da42533044a9586dd (patch)
tree660580506e5b2b232354121f964508c986a65f90 /Lib
parent6e8ee5d8e990d355fab602ab489ca43a7ae94aa5 (diff)
downloadcpython-842296480e80873de5f5042da42533044a9586dd.zip
cpython-842296480e80873de5f5042da42533044a9586dd.tar.gz
cpython-842296480e80873de5f5042da42533044a9586dd.tar.bz2
Patch (mostly) from Thomas Heller for building on Windows:
* build to "Debug" or "Release" temp directory * put linker turds (.lib and .exp files) in the build temp directory * tack on "_d" to extensions built with debugging * added 'get_ext_libname()' help in putting linker turds to temp dir Also, moved the code that simplifies None to empty list for a bunch of options to 'finalize_options()' instead of 'run()'.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/distutils/command/build_ext.py47
1 files changed, 36 insertions, 11 deletions
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index f2e0b31..2cb1c61 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -122,9 +122,24 @@ class build_ext (Command):
if type (self.libraries) is StringType:
self.libraries = [self.libraries]
- # XXX how the heck are 'self.define' and 'self.undef' supposed to
- # be set?
+ # Life is easier if we're not forever checking for None, so
+ # simplify these options to empty lists if unset
+ if self.libraries is None:
+ self.libraries = []
+ if self.library_dirs is None:
+ self.library_dirs = []
+ if self.rpath is None:
+ self.rpath = []
+ # for extensions under windows use different directories
+ # for Release and Debug builds.
+ # also Python's library directory must be appended to library_dirs
+ if os.name == 'nt':
+ self.library_dirs.append (os.path.join(sys.exec_prefix, 'libs'))
+ if self.debug:
+ self.build_temp = os.path.join (self.build_temp, "Debug")
+ else:
+ self.build_temp = os.path.join (self.build_temp, "Release")
# finalize_options ()
@@ -143,15 +158,6 @@ class build_ext (Command):
if not self.extensions:
return
- # Simplify the following logic (eg. don't have to worry about
- # appending to None)
- if self.libraries is None:
- self.libraries = []
- if self.library_dirs is None:
- self.library_dirs = []
- if self.rpath is None:
- self.rpath = []
-
# If we were asked to build any C/C++ libraries, make sure that the
# directory where we put them is in the library search path for
# linking extensions.
@@ -313,6 +319,14 @@ class build_ext (Command):
else:
modname = string.split (extension_name, '.')[-1]
extra_args.append('/export:init%s'%modname)
+
+ # The MSVC linker generates unneeded .lib and .exp files,
+ # which cannot be suppressed by any linker switches. So
+ # make sure they are generated in the temporary build
+ # directory.
+ implib_dir = os.path.join(self.build_temp,\
+ self.get_ext_libname(extension_name))
+ extra_args.append ('/IMPLIB:' + implib_dir)
# if MSVC
fullname = self.get_ext_fullname (extension_name)
@@ -351,6 +365,17 @@ class build_ext (Command):
def get_ext_filename (self, ext_name):
from distutils import sysconfig
ext_path = string.split (ext_name, '.')
+ # extensions in debug_mode are named 'module_d.pyd' under windows
+ if os.name == 'nt' and self.debug:
+ return apply (os.path.join, ext_path) + '_d' + sysconfig.SO
return apply (os.path.join, ext_path) + sysconfig.SO
+ def get_ext_libname (self, ext_name):
+ # create a filename for the (unneeded) lib-file.
+ # extensions in debug_mode are named 'module_d.pyd' under windows
+ ext_path = string.split (ext_name, '.')
+ if os.name == 'nt' and self.debug:
+ return apply (os.path.join, ext_path) + '_d.lib'
+ return apply (os.path.join, ext_path) + '.lib'
+
# class BuildExt