[Numpy-svn] r5188 - trunk/numpy/distutils/command
numpy-svn at scipy.org
numpy-svn at scipy.org
Sun May 18 04:37:28 EDT 2008
Author: cdavid
Date: 2008-05-18 03:37:24 -0500 (Sun, 18 May 2008)
New Revision: 5188
Modified:
trunk/numpy/distutils/command/scons.py
Log:
Add --package-list to scons command, to speed-up no-op when working on scipy.
Modified: trunk/numpy/distutils/command/scons.py
===================================================================
--- trunk/numpy/distutils/command/scons.py 2008-05-18 03:56:19 UTC (rev 5187)
+++ trunk/numpy/distutils/command/scons.py 2008-05-18 08:37:24 UTC (rev 5188)
@@ -173,6 +173,29 @@
# already quoted path, for example).
return '"' + path + '"'
+def parse_package_list(pkglist):
+ return pkglist.split(",")
+
+def find_common(seq1, seq2):
+ """Given two list, return the index of the common items.
+
+ The index are relative to seq1.
+
+ Note: do not handle duplicate items."""
+ dict2 = dict([(i, None) for i in seq2])
+
+ return [i for i in range(len(seq1)) if dict2.has_key(seq1[i])]
+
+def select_packages(sconspkg, pkglist):
+ """Given a list of packages in pkglist, return the list of packages which
+ match this list."""
+ common = find_common(sconspkg, pkglist)
+ if not len(common) == len(pkglist):
+ msg = "the package list contains a package not found in "\
+ "the current list. The current list is %s" % sconspkg
+ raise ValueError(msg)
+ return common
+
class scons(old_build_ext):
# XXX: add an option to the scons command for configuration (auto/force/cache).
description = "Scons builder"
@@ -182,7 +205,10 @@
('scons-tool-path=', None, 'specify additional path '\
'(absolute) to look for scons tools'),
('silent=', None, 'specify whether scons output should less verbose'\
- '(1), silent (2), super silent (3) or not (0, default)')]
+ '(1), silent (2), super silent (3) or not (0, default)'),
+ ('package-list=', None, 'If specified, only run scons on the given '\
+ 'packages (example: --package-list=scipy.cluster). If empty, '\
+ 'no package is built')]
def initialize_options(self):
old_build_ext.initialize_options(self)
@@ -197,6 +223,8 @@
self.scons_compiler_path = None
self.scons_fcompiler = None
+ self.package_list = None
+
def finalize_options(self):
old_build_ext.finalize_options(self)
if self.distribution.has_scons_scripts():
@@ -260,6 +288,9 @@
cxxcompiler.customize_cmd(self)
self.cxxcompiler = cxxcompiler.cxx_compiler()
#print self.cxxcompiler.compiler_cxx[0]
+
+ if self.package_list:
+ self.package_list = parse_package_list(self.package_list)
def run(self):
if len(self.sconscripts) > 0:
@@ -283,9 +314,21 @@
scons_exec = get_python_exec_invoc()
scons_exec += ' ' + protect_path(pjoin(get_scons_local_path(), 'scons.py'))
- for sconscript, pre_hook, post_hook, pkg_name in zip(self.sconscripts,
- self.pre_hooks, self.post_hooks,
- self.pkg_names):
+ if self.package_list is not None:
+ id = select_packages(self.pkg_names, self.package_list)
+ sconscripts = [self.sconscripts[i] for i in id]
+ pre_hooks = [self.pre_hooks[i] for i in id]
+ post_hooks = [self.post_hooks[i] for i in id]
+ pkg_names = [self.pkg_names[i] for i in id]
+ else:
+ sconscripts = self.sconscripts
+ pre_hooks = self.pre_hooks
+ post_hooks = self.post_hooks
+ pkg_names = self.pkg_names
+
+ for sconscript, pre_hook, post_hook, pkg_name in zip(sconscripts,
+ pre_hooks, post_hooks,
+ pkg_names):
if pre_hook:
pre_hook()
More information about the Numpy-svn
mailing list