Commit b081e180 authored by Greg Ward's avatar Greg Ward

Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()',

and added (empty) 'precompile_hook()' for symmetry.  One can envision
a much more elaborate hook mechanism, but this looks like it'll do for
now.
parent 7b9fb929
......@@ -160,7 +160,7 @@ class build_ext (Command):
# 'self.extensions', as supplied by setup.py, is a list of
# Extension instances. See the documentation for Extension (in
# distutils.core) for details.
# distutils.extension) for details.
#
# For backwards compatibility with Distutils 0.8.2 and earlier, we
# also allow the 'extensions' list to be a list of tuples:
......@@ -395,6 +395,11 @@ class build_ext (Command):
if os.environ.has_key('CFLAGS'):
extra_args.extend(string.split(os.environ['CFLAGS']))
# Run any platform/compiler-specific hooks needed before
# compiling (currently none, but any hypothetical subclasses
# might find it useful to override this).
self.precompile_hook()
objects = self.compiler.compile (sources,
output_dir=self.build_temp,
#macros=macros,
......@@ -409,6 +414,28 @@ class build_ext (Command):
objects.extend (ext.extra_objects)
extra_args = ext.extra_link_args
# Run any platform/compiler-specific hooks needed between
# compiling and linking (currently needed only on Windows).
self.prelink_hook()
self.compiler.link_shared_object (
objects, ext_filename,
libraries=ext.libraries,
library_dirs=ext.library_dirs,
runtime_library_dirs=ext.runtime_library_dirs,
extra_postargs=extra_args,
debug=self.debug)
# build_extensions ()
# -- Hooks ---------------------------------------------------------
def precompile_hook (self):
pass
def prelink_hook (self):
# XXX this is a kludge! Knowledge of specific compilers or
# platforms really doesn't belong here; in an ideal world, the
# CCompiler interface would provide access to everything in a
......@@ -445,16 +472,11 @@ class build_ext (Command):
self.mkpath (os.path.dirname (implib_file))
# if MSVC
self.compiler.link_shared_object (
objects, ext_filename,
libraries=ext.libraries,
library_dirs=ext.library_dirs,
runtime_library_dirs=ext.runtime_library_dirs,
extra_postargs=extra_args,
debug=self.debug)
# prelink_hook ()
# build_extensions ()
# -- Name generators -----------------------------------------------
# (extension names, filenames, whatever)
def get_ext_fullname (self, ext_name):
if self.package is None:
......@@ -463,6 +485,11 @@ class build_ext (Command):
return self.package + '.' + ext_name
def get_ext_filename (self, ext_name):
"""Convert the name of an extension (eg. "foo.bar") into the name
of the file from which it will be loaded (eg. "foo/bar.so", or
"foo\bar.pyd").
"""
from distutils import sysconfig
ext_path = string.split (ext_name, '.')
# extensions in debug_mode are named 'module_d.pyd' under windows
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment