From 738149c9bfb9965d013d01ef99f9bb1c2819e7e8 Mon Sep 17 00:00:00 2001 From: Luca Falavigna Date: Tue, 15 Jun 2010 14:28:22 +0000 Subject: Imported Upstream version 2.0.0 --- src/script/README.txt | 4 +- src/script/scons-post-install.py | 25 +++++++--- src/script/scons-time.py | 105 ++++++++++++++++++++++----------------- src/script/scons.bat | 6 +-- src/script/scons.py | 25 +++++----- src/script/sconsign.py | 68 +++++++++++-------------- src/script/setup.py | 4 +- 7 files changed, 126 insertions(+), 111 deletions(-) (limited to 'src/script') diff --git a/src/script/README.txt b/src/script/README.txt index 5fa1e31..1f46437 100644 --- a/src/script/README.txt +++ b/src/script/README.txt @@ -5,12 +5,12 @@ ### A SEPARATE SCRIPT PACKAGE IN THE FUTURE. ### # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation -# src/script/README.txt 4720 2010/03/24 03:14:11 jars +# src/script/README.txt 5023 2010/06/14 22:05:46 scons SCons - a software construction tool - Version 1.3.0 + Version 2.0.0.final.0 This is an alpha release of SCons, a tool for building software (and diff --git a/src/script/scons-post-install.py b/src/script/scons-post-install.py index 40cbac1..4b04fec 100644 --- a/src/script/scons-post-install.py +++ b/src/script/scons-post-install.py @@ -31,10 +31,19 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/script/scons-post-install.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/script/scons-post-install.py 5023 2010/06/14 22:05:46 scons" -import os.path +import os import sys +import imp + +try: + # Before Python 3.0, the 'winreg' module was named '_winreg' + sys.modules['winreg'] = \ + imp.load_module('winreg', *imp.find_module('_winreg')) +except ImportError: + # No '_winreg' module: either 3.x or not Windows + pass scons_bat_path = os.path.join(sys.prefix, 'Scripts', 'scons.bat') @@ -43,15 +52,15 @@ app_paths_key = r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\SCons.bat' def install(): if sys.platform == 'win32': try: - import _winreg + import winreg except ImportError: pass else: print 'Writing "App Paths" registry entry for %s' % scons_bat_path - _winreg.SetValue( - _winreg.HKEY_LOCAL_MACHINE, + winreg.SetValue( + winreg.HKEY_LOCAL_MACHINE, app_paths_key, - _winreg.REG_SZ, + winreg.REG_SZ, scons_bat_path) print 'Done.' @@ -59,12 +68,12 @@ def install(): def remove(): if sys.platform == 'win32': try: - import _winreg + import winreg except ImportError: pass else: # print 'Remove "App Paths" registry entry' - _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, app_paths_key) + winreg.DeleteKey(winreg.HKEY_LOCAL_MACHINE, app_paths_key) if len(sys.argv) > 1: diff --git a/src/script/scons-time.py b/src/script/scons-time.py index ed8530c..36c1134 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -29,36 +29,58 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - +from __future__ import division from __future__ import nested_scopes -__revision__ = "src/script/scons-time.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/script/scons-time.py 5023 2010/06/14 22:05:46 scons" import getopt import glob import os -import os.path import re import shutil -import string import sys import tempfile import time try: - False + sorted except NameError: - # Pre-2.2 Python has no False keyword. - import __builtin__ - __builtin__.False = not 1 + # Pre-2.4 Python has no sorted() function. + # + # The pre-2.4 Python list.sort() method does not support + # list.sort(key=) nor list.sort(reverse=) keyword arguments, so + # we must implement the functionality of those keyword arguments + # by hand instead of passing them to list.sort(). + def sorted(iterable, cmp=None, key=None, reverse=False): + if key is not None: + result = [(key(x), x) for x in iterable] + else: + result = iterable[:] + if cmp is None: + # Pre-2.3 Python does not support list.sort(None). + result.sort() + else: + result.sort(cmp) + if key is not None: + result = [t1 for t0,t1 in result] + if reverse: + result.reverse() + return result -try: - True -except NameError: - # Pre-2.2 Python has no True keyword. - import __builtin__ - __builtin__.True = not 0 +if os.environ.get('SCONS_HORRIBLE_REGRESSION_TEST_HACK') is not None: + # We can't apply the 'callable' fixer until the floor is 2.6, but the + # '-3' option to Python 2.6 and 2.7 generates almost ten thousand + # warnings. This hack allows us to run regression tests with the '-3' + # option by replacing the callable() built-in function with a hack + # that performs the same function but doesn't generate the warning. + # Note that this hack is ONLY intended to be used for regression + # testing, and should NEVER be used for real runs. + from types import ClassType + def callable(obj): + if hasattr(obj, '__call__'): return True + if isinstance(obj, (ClassType, type)): return True + return False def make_temp_file(**kw): try: @@ -90,7 +112,7 @@ def HACK_for_exec(cmd, *args): elif len(args) == 1: exec cmd in args[0] else: exec cmd in args[0], args[1] -class Plotter: +class Plotter(object): def increment_size(self, largest): """ Return the size of each horizontal increment line for a specified @@ -98,12 +120,12 @@ class Plotter: between 5 and 9 horizontal lines on the graph, on some set of boundaries that are multiples of 10/100/1000/etc. """ - i = largest / 5 + i = largest // 5 if not i: return largest multiplier = 1 while i >= 10: - i = i / 10 + i = i // 10 multiplier = multiplier * 10 return i * multiplier @@ -111,9 +133,9 @@ class Plotter: # Round up to next integer. largest = int(largest) + 1 increment = self.increment_size(largest) - return ((largest + increment - 1) / increment) * increment + return ((largest + increment - 1) // increment) * increment -class Line: +class Line(object): def __init__(self, points, type, title, label, comment, fmt="%s %s"): self.points = points self.type = type @@ -177,13 +199,13 @@ class Gnuplotter(Plotter): result = [] for line in self.lines: result.extend(line.get_x_values()) - return filter(lambda r: not r is None, result) + return [r for r in result if not r is None] def get_all_y_values(self): result = [] for line in self.lines: result.extend(line.get_y_values()) - return filter(lambda r: not r is None, result) + return [r for r in result if not r is None] def get_min_x(self): try: @@ -236,10 +258,9 @@ class Gnuplotter(Plotter): min_y = self.get_min_y() max_y = self.max_graph_value(self.get_max_y()) - range = max_y - min_y - incr = range / 10.0 + incr = (max_y - min_y) / 10.0 start = min_y + (max_y / 2.0) + (2.0 * incr) - position = [ start - (i * incr) for i in xrange(5) ] + position = [ start - (i * incr) for i in range(5) ] inx = 1 for line in self.lines: @@ -274,12 +295,11 @@ def unzip(fname): open(name, 'w').write(zf.read(name)) def read_tree(dir): - def read_files(arg, dirname, fnames): - for fn in fnames: - fn = os.path.join(dirname, fn) + for dirpath, dirnames, filenames in os.walk(dir): + for fn in filenames: + fn = os.path.join(dirpath, fn) if os.path.isfile(fn): open(fn, 'rb').read() - os.path.walk('.', read_files, None) def redirect_to_file(command, log): return '%s > %s 2>&1' % (command, log) @@ -289,7 +309,7 @@ def tee_to_file(command, log): -class SConsTimer: +class SConsTimer(object): """ Usage: scons-time SUBCOMMAND [ARGUMENTS] Type "scons-time help SUBCOMMAND" for help on a specific subcommand. @@ -506,9 +526,7 @@ class SConsTimer: """ files = [] for a in args: - g = glob.glob(a) - g.sort() - files.extend(g) + files.extend(sorted(glob.glob(a))) if tail: files = files[-tail:] @@ -539,7 +557,7 @@ class SConsTimer: for file in files: base = os.path.splitext(file)[0] - run, index = string.split(base, '-')[-2:] + run, index = base.split('-')[-2:] run = int(run) index = int(index) @@ -577,11 +595,11 @@ class SConsTimer: and returns the next run number after the largest it finds. """ x = re.compile(re.escape(prefix) + '-([0-9]+).*') - matches = map(lambda e, x=x: x.match(e), os.listdir(dir)) - matches = filter(None, matches) + matches = [x.match(e) for e in os.listdir(dir)] + matches = [_f for _f in matches if _f] if not matches: return 0 - run_numbers = map(lambda m: int(m.group(1)), matches) + run_numbers = [int(m.group(1)) for m in matches] return int(max(run_numbers)) + 1 def gnuplot_results(self, results, fmt='%s %.3f'): @@ -590,10 +608,7 @@ class SConsTimer: """ gp = Gnuplotter(self.title, self.key_location) - indices = results.keys() - indices.sort() - - for i in indices: + for i in sorted(results.keys()): try: t = self.run_titles[i] except IndexError: @@ -964,7 +979,7 @@ class SConsTimer: if self.chdir: os.chdir(self.chdir) - logfile_path = lambda x, c=self.chdir: os.path.join(c, x) + logfile_path = lambda x: os.path.join(self.chdir, x) if not args: @@ -1084,7 +1099,7 @@ class SConsTimer: if self.chdir: os.chdir(self.chdir) - logfile_path = lambda x, c=self.chdir: os.path.join(c, x) + logfile_path = lambda x: os.path.join(self.chdir, x) if not args: @@ -1248,7 +1263,7 @@ class SConsTimer: except ValueError: result.append(int(n)) else: - result.extend(range(int(x), int(y)+1)) + result.extend(list(range(int(x), int(y)+1))) return result def scons_path(self, dir): @@ -1462,7 +1477,7 @@ class SConsTimer: if self.chdir: os.chdir(self.chdir) - logfile_path = lambda x, c=self.chdir: os.path.join(c, x) + logfile_path = lambda x: os.path.join(self.chdir, x) if not args: diff --git a/src/script/scons.bat b/src/script/scons.bat index 892f867..dbc1e75 100644 --- a/src/script/scons.bat +++ b/src/script/scons.bat @@ -1,11 +1,11 @@ @REM Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation -@REM src/script/scons.bat 4720 2010/03/24 03:14:11 jars +@REM src/script/scons.bat 5023 2010/06/14 22:05:46 scons @echo off set SCONS_ERRORLEVEL= if "%OS%" == "Windows_NT" goto WinNT @REM for 9x/Me you better not have more than 9 args -python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-1.3.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-1.3.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9 +python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-2.0.0.final.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-2.0.0.final.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9 @REM no way to set exit status of this script for 9x/Me goto endscons @@ -17,7 +17,7 @@ goto endscons setlocal @REM ensure the script will be executed with the Python it was installed for set path=%~dp0;%~dp0..;%path% -python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-1.3.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-1.3.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %* +python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-2.0.0.final.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-2.0.0.final.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %* endlocal & set SCONS_ERRORLEVEL=%ERRORLEVEL% if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto returncode diff --git a/src/script/scons.py b/src/script/scons.py index 7fe4c60..c95bfac 100644 --- a/src/script/scons.py +++ b/src/script/scons.py @@ -24,17 +24,17 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/script/scons.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/script/scons.py 5023 2010/06/14 22:05:46 scons" -__version__ = "1.3.0" +__version__ = "2.0.0.final.0" -__build__ = "r4720" +__build__ = "r5023" -__buildsys__ = "jars-desktop" +__buildsys__ = "scons-dev" -__date__ = "2010/03/24 03:14:11" +__date__ = "2010/06/14 22:05:46" -__developer__ = "jars" +__developer__ = "scons" import os import os.path @@ -76,7 +76,7 @@ if script_dir in sys.path: libs = [] -if os.environ.has_key("SCONS_LIB_DIR"): +if "SCONS_LIB_DIR" in os.environ: libs.append(os.environ["SCONS_LIB_DIR"]) local_version = 'scons-local-' + __version__ @@ -137,12 +137,11 @@ else: # check only /foo/lib/scons*. prefs.append(sys.prefix) - temp = map(lambda x: os.path.join(x, 'lib'), prefs) - temp.extend(map(lambda x: os.path.join(x, + temp = [os.path.join(x, 'lib') for x in prefs] + temp.extend([os.path.join(x, 'lib', 'python' + sys.version[:3], - 'site-packages'), - prefs)) + 'site-packages') for x in prefs]) prefs = temp # Add the parent directory of the current python's library to the @@ -175,8 +174,8 @@ else: # Look first for 'scons-__version__' in all of our preference libs, # then for 'scons'. -libs.extend(map(lambda x: os.path.join(x, scons_version), prefs)) -libs.extend(map(lambda x: os.path.join(x, 'scons'), prefs)) +libs.extend([os.path.join(x, scons_version) for x in prefs]) +libs.extend([os.path.join(x, 'scons') for x in prefs]) sys.path = libs + sys.path diff --git a/src/script/sconsign.py b/src/script/sconsign.py index e86f47f..c1f9632 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -22,22 +22,20 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/script/sconsign.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/script/sconsign.py 5023 2010/06/14 22:05:46 scons" -__version__ = "1.3.0" +__version__ = "2.0.0.final.0" -__build__ = "r4720" +__build__ = "r5023" -__buildsys__ = "jars-desktop" +__buildsys__ = "scons-dev" -__date__ = "2010/03/24 03:14:11" +__date__ = "2010/06/14 22:05:46" -__developer__ = "jars" +__developer__ = "scons" import os -import os.path import sys import time @@ -64,7 +62,7 @@ if script_dir in sys.path: libs = [] -if os.environ.has_key("SCONS_LIB_DIR"): +if "SCONS_LIB_DIR" in os.environ: libs.append(os.environ["SCONS_LIB_DIR"]) local_version = 'scons-local-' + __version__ @@ -125,12 +123,11 @@ else: # check only /foo/lib/scons*. prefs.append(sys.prefix) - temp = map(lambda x: os.path.join(x, 'lib'), prefs) - temp.extend(map(lambda x: os.path.join(x, + temp = [os.path.join(x, 'lib') for x in prefs] + temp.extend([os.path.join(x, 'lib', 'python' + sys.version[:3], - 'site-packages'), - prefs)) + 'site-packages') for x in prefs]) prefs = temp # Add the parent directory of the current python's library to the @@ -163,8 +160,8 @@ else: # Look first for 'scons-__version__' in all of our preference libs, # then for 'scons'. -libs.extend(map(lambda x: os.path.join(x, scons_version), prefs)) -libs.extend(map(lambda x: os.path.join(x, 'scons'), prefs)) +libs.extend([os.path.join(x, scons_version) for x in prefs]) +libs.extend([os.path.join(x, 'scons') for x in prefs]) sys.path = libs + sys.path @@ -172,10 +169,11 @@ sys.path = libs + sys.path # END STANDARD SCons SCRIPT HEADER ############################################################################## -import cPickle -import imp -import string +import SCons.compat # so pickle will import cPickle instead + import whichdb +import pickle +import imp import SCons.SConsign @@ -195,7 +193,7 @@ whichdb.whichdb = my_whichdb def my_import(mname): if '.' in mname: - i = string.rfind(mname, '.') + i = mname.rfind('.') parent = my_import(mname[:i]) fp, pathname, description = imp.find_module(mname[i+1:], parent.__path__) @@ -203,7 +201,7 @@ def my_import(mname): fp, pathname, description = imp.find_module(mname) return imp.load_module(mname, fp, pathname, description) -class Flagger: +class Flagger(object): default_value = 1 def __setitem__(self, item, value): self.__dict__[item] = value @@ -250,11 +248,11 @@ def map_bkids(entry, name): except AttributeError: return None result = [] - for i in xrange(len(bkids)): + for i in range(len(bkids)): result.append(nodeinfo_string(bkids[i], bkidsigs[i], " ")) if result == []: return None - return string.join(result, "\n ") + return "\n ".join(result) map_field = { 'action' : map_action, @@ -283,29 +281,27 @@ def nodeinfo_raw(name, ninfo, prefix=""): try: keys = ninfo.field_list + ['_version_id'] except AttributeError: - keys = d.keys() - keys.sort() + keys = sorted(d.keys()) l = [] for k in keys: l.append('%s: %s' % (repr(k), repr(d.get(k)))) if '\n' in name: name = repr(name) - return name + ': {' + string.join(l, ', ') + '}' + return name + ': {' + ', '.join(l) + '}' def nodeinfo_cooked(name, ninfo, prefix=""): try: field_list = ninfo.field_list except AttributeError: field_list = [] - f = lambda x, ni=ninfo, v=Verbose: field(x, ni, v) if '\n' in name: name = repr(name) - outlist = [name+':'] + filter(None, map(f, field_list)) + outlist = [name+':'] + [_f for _f in [field(x, ninfo, Verbose) for x in field_list] if _f] if Verbose: sep = '\n ' + prefix else: sep = ' ' - return string.join(outlist, sep) + return sep.join(outlist) nodeinfo_string = nodeinfo_cooked @@ -338,9 +334,7 @@ def printentries(entries, location): print nodeinfo_string(name, entry.ninfo) printfield(name, entry.binfo) else: - names = entries.keys() - names.sort() - for name in names: + for name in sorted(entries.keys()): entry = entries[name] try: ninfo = entry.ninfo @@ -350,7 +344,7 @@ def printentries(entries, location): print nodeinfo_string(name, entry.ninfo) printfield(name, entry.binfo) -class Do_SConsignDB: +class Do_SConsignDB(object): def __init__(self, dbm_name, dbm): self.dbm_name = dbm_name self.dbm = dbm @@ -388,7 +382,7 @@ class Do_SConsignDB: return except KeyboardInterrupt: raise - except cPickle.UnpicklingError: + except pickle.UnpicklingError: sys.stderr.write("sconsign: ignoring invalid `%s' file `%s'\n" % (self.dbm_name, fname)) return except Exception, e: @@ -404,14 +398,12 @@ class Do_SConsignDB: else: self.printentries(dir, val) else: - keys = db.keys() - keys.sort() - for dir in keys: + for dir in sorted(db.keys()): self.printentries(dir, db[dir]) def printentries(self, dir, val): print '=== ' + dir + ':' - printentries(cPickle.loads(val), dir) + printentries(pickle.loads(val), dir) def Do_SConsignDir(name): try: @@ -423,7 +415,7 @@ def Do_SConsignDir(name): sconsign = SCons.SConsign.Dir(fp) except KeyboardInterrupt: raise - except cPickle.UnpicklingError: + except pickle.UnpicklingError: sys.stderr.write("sconsign: ignoring invalid .sconsign file `%s'\n" % (name)) return except Exception, e: diff --git a/src/script/setup.py b/src/script/setup.py index c4955ea..36e5e00 100644 --- a/src/script/setup.py +++ b/src/script/setup.py @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/script/setup.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/script/setup.py 5023 2010/06/14 22:05:46 scons" import os import os.path @@ -36,7 +36,7 @@ if head: from distutils.core import setup setup(name = "scons-script", - version = "1.3.0", + version = "2.0.0.final.0", description = "an Open Source software construction tool script", long_description = """SCons is an Open Source software construction tool--that is, a build tool; an improved substitute for the classic Make utility; a better way to build -- cgit v1.2.3