diff options
-rw-r--r-- | SConstruct | 2 | ||||
-rw-r--r-- | bin/SConsDoc.py | 3 | ||||
-rw-r--r-- | bin/scons-time.py | 180 | ||||
-rwxr-xr-x | runtest.py | 22 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | site_scons/BuildCommandLine.py | 9 | ||||
-rw-r--r-- | site_scons/epydoc.py | 2 | ||||
-rw-r--r-- | site_scons/site_init.py | 4 | ||||
-rw-r--r-- | src/engine/SCons/Utilities/sconsign.py | 10 | ||||
-rw-r--r-- | test/scons-time/run/archive/dir.py | 1 |
10 files changed, 116 insertions, 119 deletions
@@ -37,7 +37,7 @@ import textwrap project = 'scons' -default_version = '3.1.2' +default_version = '3.9.9' copyright = "Copyright (c) %s The SCons Foundation" % copyright_years # diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 1e88c5b..e211b3c 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -114,6 +114,7 @@ import os.path import re import sys import copy +import importlib # Do we have libxml2/libxslt/lxml? has_libxml2 = True @@ -867,7 +868,7 @@ def importfile(path): try: return importlib._bootstrap._load(spec) except ImportError: - raise ErrorDuringImport(path, sys.exc_info()) + raise Exception(path, sys.exc_info()) # Local Variables: # tab-width:4 diff --git a/bin/scons-time.py b/bin/scons-time.py index 6494349..37de2f0 100644 --- a/bin/scons-time.py +++ b/bin/scons-time.py @@ -40,7 +40,7 @@ import shutil import sys import tempfile import time -import subprocess + def HACK_for_exec(cmd, *args): """ @@ -49,9 +49,13 @@ def HACK_for_exec(cmd, *args): This function is a hack that calls exec() in a function with no internal functions. """ - if not args: exec(cmd) - elif len(args) == 1: exec(cmd, args[0]) - else: exec(cmd, args[0], args[1]) + if not args: + exec(cmd) + elif len(args) == 1: + exec(cmd, args[0]) + else: + exec(cmd, args[0], args[1]) + class Plotter(object): def increment_size(self, largest): @@ -76,6 +80,7 @@ class Plotter(object): increment = self.increment_size(largest) return ((largest + increment - 1) // increment) * increment + class Line(object): def __init__(self, points, type, title, label, comment, fmt="%s %s"): self.points = points @@ -111,10 +116,11 @@ class Line(object): print('e') def get_x_values(self): - return [ p[0] for p in self.points ] + return [p[0] for p in self.points] def get_y_values(self): - return [ p[1] for p in self.points ] + return [p[1] for p in self.points] + class Gnuplotter(Plotter): @@ -201,22 +207,21 @@ class Gnuplotter(Plotter): max_y = self.max_graph_value(self.get_max_y()) incr = (max_y - min_y) / 10.0 start = min_y + (max_y / 2.0) + (2.0 * incr) - position = [ start - (i * incr) for i in range(5) ] + position = [start - (i * incr) for i in range(5)] inx = 1 for line in self.lines: - line.print_label(inx, line.points[0][0]-1, - position[(inx-1) % len(position)]) + line.print_label(inx, line.points[0][0] - 1, + position[(inx - 1) % len(position)]) inx += 1 - plot_strings = [ self.plot_string(l) for l in self.lines ] + plot_strings = [self.plot_string(l) for l in self.lines] print('plot ' + ', \\\n '.join(plot_strings)) for line in self.lines: line.print_points() - def untar(fname): import tarfile tar = tarfile.open(name=fname, mode='r') @@ -224,6 +229,7 @@ def untar(fname): tar.extract(tarinfo) tar.close() + def unzip(fname): import zipfile zf = zipfile.ZipFile(fname, 'r') @@ -231,11 +237,12 @@ def unzip(fname): dir = os.path.dirname(name) try: os.makedirs(dir) - except: + except OSError: pass with open(name, 'wb') as f: f.write(zf.read(name)) + def read_tree(dir): for dirpath, dirnames, filenames in os.walk(dir): for fn in filenames: @@ -244,14 +251,15 @@ def read_tree(dir): with open(fn, 'rb') as f: f.read() + def redirect_to_file(command, log): return '%s > %s 2>&1' % (command, log) + def tee_to_file(command, log): return '%s 2>&1 | tee %s' % (command, log) - class SConsTimer(object): """ Usage: scons-time SUBCOMMAND [ARGUMENTS] @@ -267,45 +275,45 @@ class SConsTimer(object): """ name = 'scons-time' - name_spaces = ' '*len(name) + name_spaces = ' ' * len(name) def makedict(**kw): return kw default_settings = makedict( - chdir = None, - config_file = None, - initial_commands = [], - key_location = 'bottom left', - orig_cwd = os.getcwd(), - outdir = None, - prefix = '', - python = '"%s"' % sys.executable, - redirect = redirect_to_file, - scons = None, - scons_flags = '--debug=count --debug=memory --debug=time --debug=memoizer', - scons_lib_dir = None, - scons_wrapper = None, - startup_targets = '--help', - subdir = None, - subversion_url = None, - svn = 'svn', - svn_co_flag = '-q', - tar = 'tar', - targets = '', - targets0 = None, - targets1 = None, - targets2 = None, - title = None, - unzip = 'unzip', - verbose = False, - vertical_bars = [], - - unpack_map = { - '.tar.gz' : (untar, '%(tar)s xzf %%s'), - '.tgz' : (untar, '%(tar)s xzf %%s'), - '.tar' : (untar, '%(tar)s xf %%s'), - '.zip' : (unzip, '%(unzip)s %%s'), + chdir=None, + config_file=None, + initial_commands=[], + key_location='bottom left', + orig_cwd=os.getcwd(), + outdir=None, + prefix='', + python='"%s"' % sys.executable, + redirect=redirect_to_file, + scons=None, + scons_flags='--debug=count --debug=memory --debug=time --debug=memoizer', + scons_lib_dir=None, + scons_wrapper=None, + startup_targets='--help', + subdir=None, + subversion_url=None, + svn='svn', + svn_co_flag='-q', + tar='tar', + targets='', + targets0=None, + targets1=None, + targets2=None, + title=None, + unzip='unzip', + verbose=False, + vertical_bars=[], + + unpack_map={ + '.tar.gz': (untar, '%(tar)s xzf %%s'), + '.tgz': (untar, '%(tar)s xzf %%s'), + '.tar': (untar, '%(tar)s xf %%s'), + '.zip': (unzip, '%(unzip)s %%s'), }, ) @@ -329,10 +337,10 @@ class SConsTimer(object): ] stage_strings = { - 'pre-read' : 'Memory before reading SConscript files:', - 'post-read' : 'Memory after reading SConscript files:', - 'pre-build' : 'Memory before building targets:', - 'post-build' : 'Memory after building targets:', + 'pre-read': 'Memory before reading SConscript files:', + 'post-read': 'Memory after reading SConscript files:', + 'pre-build': 'Memory before building targets:', + 'post-build': 'Memory after building targets:', } memory_string_all = 'Memory ' @@ -340,10 +348,10 @@ class SConsTimer(object): default_stage = stages[-1] time_strings = { - 'total' : 'Total build time', - 'SConscripts' : 'Total SConscript file execution time', - 'SCons' : 'Total SCons execution time', - 'commands' : 'Total command execution time', + 'total': 'Total build time', + 'SConscripts': 'Total SConscript file execution time', + 'SCons': 'Total SCons execution time', + 'commands': 'Total command execution time', } time_string_all = 'Total .* time' @@ -425,7 +433,7 @@ class SConsTimer(object): Executes a list of commands, substituting values from the specified dictionary. """ - commands = [ self.subst_variables(c, dict) for c in commands ] + commands = [self.subst_variables(c, dict) for c in commands] for action, string, args in commands: self.display(string, *args) sys.stdout.flush() @@ -444,11 +452,11 @@ class SConsTimer(object): p = os.popen(command) output = p.read() p.close() - #TODO: convert to subrocess, os.popen is obsolete. This didn't work: - #process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) - #output = process.stdout.read() - #process.stdout.close() - #process.wait() + # TODO: convert to subrocess, os.popen is obsolete. This didn't work: + # process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) + # output = process.stdout.read() + # process.stdout.close() + # process.wait() if self.verbose: sys.stdout.write(output) # TODO: Figure out @@ -563,7 +571,7 @@ class SConsTimer(object): except IndexError: t = '??? %s ???' % i results[i].sort() - gp.line(results[i], i+1, t, None, t, fmt=fmt) + gp.line(results[i], i + 1, t, None, t, fmt=fmt) for bar_tuple in self.vertical_bars: try: @@ -592,11 +600,13 @@ class SConsTimer(object): if lines[0] == '': lines = lines[1:] spaces = re.match(' *', lines[0]).group(0) - def strip_initial_spaces(l, s=spaces): - if l.startswith(spaces): - l = l[len(spaces):] - return l - return '\n'.join([ strip_initial_spaces(l) for l in lines ]) + '\n' + + def strip_initial_spaces(line, s=spaces): + if line.startswith(spaces): + line = line[len(spaces):] + return line + + return '\n'.join([strip_initial_spaces(l) for l in lines]) + '\n' def profile_name(self, invocation): """ @@ -625,7 +635,7 @@ class SConsTimer(object): sys.stderr.write('file %s has no contents!\n' % repr(file)) return None result = re.findall(r'%s: ([\d.]*)' % search_string, contents)[-4:] - result = [ float(r) for r in result ] + result = [float(r) for r in result] if time_string is not None: try: result = result[0] @@ -646,7 +656,7 @@ class SConsTimer(object): sys.stderr.write('%s Cannot use the "func" subcommand.\n' % self.name_spaces) sys.exit(1) statistics = pstats.Stats(file).stats - matches = [ e for e in statistics.items() if e[0][2] == function ] + matches = [e for e in statistics.items() if e[0][2] == function] r = matches[0] return r[0][0], r[0][1], r[0][2], r[1][3] @@ -667,8 +677,8 @@ class SConsTimer(object): search_string = memory_string with open(file) as f: lines = f.readlines() - lines = [ l for l in lines if l.startswith(search_string) ][-4:] - result = [ int(l.split()[-1]) for l in lines[-4:] ] + lines = [l for l in lines if l.startswith(search_string)][-4:] + result = [int(l.split()[-1]) for l in lines[-4:]] if len(result) == 1: result = result[0] return result @@ -680,13 +690,12 @@ class SConsTimer(object): object_string = ' ' + object_name + '\n' with open(file) as f: lines = f.readlines() - line = [ l for l in lines if l.endswith(object_string) ][0] - result = [ int(field) for field in line.split()[:4] ] + line = [l for l in lines if l.endswith(object_string)][0] + result = [int(field) for field in line.split()[:4]] if index is not None: result = result[index] return result - command_alias = {} def execute_subcommand(self, argv): @@ -841,7 +850,7 @@ class SConsTimer(object): for file in args: try: f, line, func, time = \ - self.get_function_profile(file, function_name) + self.get_function_profile(file, function_name) except ValueError as e: sys.stderr.write("%s: func: %s: %s\n" % (self.name, file, e)) @@ -956,7 +965,7 @@ class SConsTimer(object): args = self.args_to_files(args, tail) - cwd_ = os.getcwd() + os.sep + # cwd_ = os.getcwd() + os.sep if format == 'ascii': @@ -1216,11 +1225,11 @@ class SConsTimer(object): except ValueError: result.append(int(n)) else: - result.extend(list(range(int(x), int(y)+1))) + result.extend(list(range(int(x), int(y) + 1))) return result def scons_path(self, dir): - return os.path.join(dir,'scripts', 'scons.py') + return os.path.join(dir, 'scripts', 'scons.py') def scons_lib_dir_path(self, dir): return os.path.join(dir, 'src', 'engine') @@ -1247,9 +1256,9 @@ class SConsTimer(object): if prepare: prepare(commands, removals) - save_scons = self.scons - save_scons_wrapper = self.scons_wrapper - save_scons_lib_dir = self.scons_lib_dir + save_scons = self.scons + save_scons_wrapper = self.scons_wrapper + save_scons_lib_dir = self.scons_lib_dir if self.outdir is None: self.outdir = self.orig_cwd @@ -1308,7 +1317,7 @@ class SConsTimer(object): commands.extend([ (lambda: read_tree('.'), - 'find * -type f | xargs cat > /dev/null'), + 'find * -type f | xargs cat > /dev/null'), (self.set_env, 'export %%s=%%s', 'SCONS_LIB_DIR', self.scons_lib_dir), @@ -1338,9 +1347,9 @@ class SConsTimer(object): self.run_command_list(commands, self.__dict__) - self.scons = save_scons - self.scons_lib_dir = save_scons_lib_dir - self.scons_wrapper = save_scons_wrapper + self.scons = save_scons + self.scons_lib_dir = save_scons_lib_dir + self.scons_wrapper = save_scons_wrapper # @@ -1454,6 +1463,7 @@ class SConsTimer(object): sys.stderr.write('%s: time: Unknown format "%s".\n' % (self.name, format)) sys.exit(1) + if __name__ == '__main__': opts, args = getopt.getopt(sys.argv[1:], 'h?V', ['help', 'version']) @@ -486,26 +486,8 @@ ld = None if not baseline or baseline == '.': base = cwd elif baseline == '-': - url = None - with os.popen("svn info 2>&1", "r") as p: - svn_info = p.read() - match = re.search(r'URL: (.*)', svn_info) - if match: - url = match.group(1) - if not url: - sys.stderr.write('runtest.py: could not find a URL:\n') - sys.stderr.write(svn_info) - sys.exit(1) - import tempfile - base = tempfile.mkdtemp(prefix='runtest-tmp-') - - command = 'cd %s && svn co -q %s' % (base, url) - - base = os.path.join(base, os.path.split(url)[1]) - if printcommand: - print(command) - if execute_tests: - os.system(command) + print("This logic used to checkout from svn. It's been removed. If you used this, please let us know on devel mailing list, IRC, or discord server") + sys.exit(-1) else: base = baseline @@ -1,5 +1,5 @@ import fnmatch -from setuptools import find_packages, setup +from setuptools import setup from setuptools.command.build_py import build_py as build_py_orig diff --git a/site_scons/BuildCommandLine.py b/site_scons/BuildCommandLine.py index 4694472..b8c7d63 100644 --- a/site_scons/BuildCommandLine.py +++ b/site_scons/BuildCommandLine.py @@ -102,25 +102,28 @@ class BuildCommandLine(object): self.revision = ARGUMENTS.get('REVISION', '') - def generate_build_id(revision): + def _generate_build_id(revision): return revision + generate_build_id=_generate_build_id + if not self.revision and BuildCommandLine.git: with os.popen("%s rev-parse HEAD 2> /dev/null" % BuildCommandLine.git, "r") as p: self.git_hash = p.read().strip() - def generate_build_id(revision): + def _generate_build_id_git(revision): result = self.git_hash if [l for l in self.git_status_lines if 'modified' in l]: result = result + '[MODIFIED]' return result + generate_build_id = _generate_build_id_git self.revision = self.git_hash self.checkpoint = ARGUMENTS.get('CHECKPOINT', '') if self.checkpoint: if self.checkpoint == 'd': - cself.heckpoint = time.strftime('%Y%m%d', time.localtime(time.time())) + self.checkpoint = time.strftime('%Y%m%d', time.localtime(time.time())) elif self.checkpoint == 'r': self.checkpoint = 'r' + self.revision self.version = self.version + '.beta.' + self.checkpoint diff --git a/site_scons/epydoc.py b/site_scons/epydoc.py index da74d9c..3d6e5de 100644 --- a/site_scons/epydoc.py +++ b/site_scons/epydoc.py @@ -53,7 +53,7 @@ if not epydoc_cli: from epydoc.docbuilder import build_doc_index from epydoc.docwriter.html import HTMLWriter - from epydoc.docwriter.latex import LatexWriter + # from epydoc.docwriter.latex import LatexWriter # first arg is a list where can be names of python package dirs, # python files, object names or objects itself diff --git a/site_scons/site_init.py b/site_scons/site_init.py index 7e7c569..81c4753 100644 --- a/site_scons/site_init.py +++ b/site_scons/site_init.py @@ -1,8 +1,10 @@ +import os.path + from SConsRevision import SCons_revision from Utilities import is_windows, whereis, platform, deb_date from zip_utils import unzipit, zipit, zcat from soe_utils import soelim, soscan, soelimbuilder -from epydoc import epydoc_cli, epydoc_commands +# from epydoc import epydoc_cli, epydoc_commands from BuildCommandLine import BuildCommandLine gzip = whereis('gzip') diff --git a/src/engine/SCons/Utilities/sconsign.py b/src/engine/SCons/Utilities/sconsign.py index 8b16b18..89084ba 100644 --- a/src/engine/SCons/Utilities/sconsign.py +++ b/src/engine/SCons/Utilities/sconsign.py @@ -218,12 +218,12 @@ def nodeinfo_raw(name, ninfo, prefix=""): keys = ninfo.field_list + ['_version_id'] except AttributeError: keys = sorted(d.keys()) - l = [] - for k in keys: - l.append('%s: %s' % (repr(k), repr(d.get(k)))) + values = [] + for key in keys: + values.append('%s: %s' % (repr(key), repr(d.get(key)))) if '\n' in name: name = repr(name) - return name + ': {' + ', '.join(l) + '}' + return name + ': {' + ', '.join(values) + '}' def nodeinfo_cooked(name, ninfo, prefix=""): @@ -280,7 +280,7 @@ def printentries(entries, location): for name in sorted(entries.keys()): entry = entries[name] try: - ninfo = entry.ninfo + entry.ninfo except AttributeError: print(name + ":") else: diff --git a/test/scons-time/run/archive/dir.py b/test/scons-time/run/archive/dir.py index 6b6d992..590d568 100644 --- a/test/scons-time/run/archive/dir.py +++ b/test/scons-time/run/archive/dir.py @@ -32,7 +32,6 @@ directory tree. import TestSCons_time test = TestSCons_time.TestSCons_time() -test.verbose_set(1) test.write_fake_scons_py() |