summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/command/build_ext.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-05-26 01:31:53 (GMT)
committerGreg Ward <gward@python.net>2000-05-26 01:31:53 (GMT)
commit521340034ee0f813d76b07f01de6f25306f01c1c (patch)
tree1c8c6a913494e949db2ee955af783e0ffb778f45 /Lib/distutils/command/build_ext.py
parent59d382e482d22fadf4c49251adfc1817f33c055b (diff)
downloadcpython-521340034ee0f813d76b07f01de6f25306f01c1c.zip
cpython-521340034ee0f813d76b07f01de6f25306f01c1c.tar.gz
cpython-521340034ee0f813d76b07f01de6f25306f01c1c.tar.bz2
Rene Liebscher: check if the extension file (.so or .pyd) is
up-to-date with respect to the source files; that way, we don't needlessly rebuild just because object files go away.
Diffstat (limited to 'Lib/distutils/command/build_ext.py')
-rw-r--r--Lib/distutils/command/build_ext.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 4fb51ac..acf1d7b 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -12,7 +12,7 @@ import sys, os, string, re
from types import *
from distutils.core import Command
from distutils.errors import *
-
+from distutils.dep_util import newer_group
# An extension name is just a dot-separated list of Python NAMEs (ie.
# the same as a fully-qualified module name).
@@ -285,7 +285,29 @@ class build_ext (Command):
"a list of source filenames") % extension_name
sources = list (sources)
- self.announce ("building '%s' extension" % extension_name)
+ fullname = self.get_ext_fullname (extension_name)
+ if self.inplace:
+ # ignore build-lib -- put the compiled extension into
+ # the source tree along with pure Python modules
+
+ modpath = string.split (fullname, '.')
+ package = string.join (modpath[0:-1], '.')
+ base = modpath[-1]
+
+ build_py = self.find_peer ('build_py')
+ package_dir = build_py.get_package_dir (package)
+ ext_filename = os.path.join (package_dir,
+ self.get_ext_filename(base))
+ else:
+ ext_filename = os.path.join (self.build_lib,
+ self.get_ext_filename(fullname))
+
+ if not newer_group(sources, ext_filename, 'newer'):
+ self.announce ("skipping '%s' extension (up-to-date)" %
+ extension_name)
+ continue # 'for' loop over all extensions
+ else:
+ self.announce ("building '%s' extension" % extension_name)
# First step: compile the source code to object files. This
# drops the object files in the current directory, regardless
@@ -357,23 +379,6 @@ class build_ext (Command):
self.mkpath (os.path.dirname (implib_file))
# if MSVC
- fullname = self.get_ext_fullname (extension_name)
- if self.inplace:
- # ignore build-lib -- put the compiled extension into
- # the source tree along with pure Python modules
-
- modpath = string.split (fullname, '.')
- package = string.join (modpath[0:-1], '.')
- base = modpath[-1]
-
- build_py = self.find_peer ('build_py')
- package_dir = build_py.get_package_dir (package)
- ext_filename = os.path.join (package_dir,
- self.get_ext_filename(base))
- else:
- ext_filename = os.path.join (self.build_lib,
- self.get_ext_filename(fullname))
-
self.compiler.link_shared_object (objects, ext_filename,
libraries=libraries,
library_dirs=library_dirs,