summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-09-28 10:21:25 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-09-28 10:21:25 +0200
commit4f3ca5f60f4de1aca6e3b9d7f30467ba0f724c27 (patch)
treed47e14dc637e15861e9ba7d65e5f4aae5d79df6d /script
parent3765e33b76c51c81dd7bbbfacab0c4e76a1713cb (diff)
parent7c651e273c4db37f4babd91aaecf26800c50dd79 (diff)
Updated version 3.0.0 from 'upstream/3.0.0'
with Debian dir f5f84710e04b09c178d76c96bcda7517932c0c17
Diffstat (limited to 'script')
-rw-r--r--script/scons22
-rw-r--r--script/scons-configure-cache280
-rw-r--r--script/scons-time55
-rw-r--r--script/scons.bat6
-rw-r--r--script/sconsign82
5 files changed, 231 insertions, 214 deletions
diff --git a/script/scons b/script/scons
index 967d398..bee0224 100644
--- a/script/scons
+++ b/script/scons
@@ -2,7 +2,7 @@
#
# SCons - a Software Constructor
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -23,15 +23,17 @@
# 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/scons.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+from __future__ import print_function
-__version__ = "2.5.1"
+__revision__ = "src/script/scons.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
-__build__ = "rel_2.5.1:3735:9dc6cee5c168[MODIFIED]"
+__version__ = "3.0.0"
-__buildsys__ = "mongodog"
+__build__ = "rel_3.0.0:4395:8972f6a2f699"
-__date__ = "2016/11/03 14:02:02"
+__buildsys__ = "ubuntu-16"
+
+__date__ = "2017/09/18 12:59:24"
__developer__ = "bdbaddog"
@@ -56,9 +58,9 @@ import sys
# engine modules if they're in either directory.
-if sys.version_info >= (3,0,0):
+if (3,0,0) < sys.version_info < (3,5,0) or sys.version_info < (2,7,0):
msg = "scons: *** SCons version %s does not run under Python version %s.\n\
-Python 3 is not yet supported.\n"
+Python < 3.5 is not yet supported.\n"
sys.stderr.write(msg % (__version__, sys.version.split()[0]))
sys.exit(1)
@@ -98,7 +100,7 @@ try:
except ImportError:
pass
else:
- # when running from an egg add the egg's directory
+ # when running from an egg add the egg's directory
try:
d = pkg_resources.get_distribution('scons')
except pkg_resources.DistributionNotFound:
@@ -191,7 +193,7 @@ if __name__ == "__main__":
except ImportError:
print("SCons import failed. Unable to find engine files in:")
for path in libs:
- print(" %s" % path)
+ print(" {}".format(path))
raise
# this does all the work, and calls sys.exit
diff --git a/script/scons-configure-cache b/script/scons-configure-cache
index a376b2d..9b8b737 100644
--- a/script/scons-configure-cache
+++ b/script/scons-configure-cache
@@ -1,139 +1,141 @@
-#! /usr/bin/env python
-#
-# SCons - a Software Constructor
-#
-# Copyright (c) 2001 - 2016 The SCons Foundation
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# 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/scons-configure-cache.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
-
-__version__ = "2.5.1"
-
-__build__ = "rel_2.5.1:3735:9dc6cee5c168[MODIFIED]"
-
-__buildsys__ = "mongodog"
-
-__date__ = "2016/11/03 14:02:02"
-
-__developer__ = "bdbaddog"
-
-import argparse
-import glob
-import json
-import os
-
-def rearrange_cache_entries(current_prefix_len, new_prefix_len):
- print 'Changing prefix length from', current_prefix_len, 'to', new_prefix_len
- dirs = set()
- old_dirs = set()
- for file in glob.iglob(os.path.join('*', '*')):
- name = os.path.basename(file)
- dir = name[:current_prefix_len].upper()
- if dir not in old_dirs:
- print 'Migrating', dir
- old_dirs.add(dir)
- dir = name[:new_prefix_len].upper()
- if dir not in dirs:
- os.mkdir(dir)
- dirs.add(dir)
- os.rename(file, os.path.join(dir, name))
-
- # Now delete the original directories
- for dir in old_dirs:
- os.rmdir(dir)
-
-# This dictionary should have one entry per entry in the cache config
-# Each entry should have the following:
-# implicit - (optional) This is to allow adding a new config entry and also
-# changing the behaviour of the system at the same time. This
-# indicates the value the config entry would have had if it had been
-# specified.
-# default - The value the config entry should have if it wasn't previously
-# specified
-# command-line - parameters to pass to ArgumentParser.add_argument
-# converter - (optional) Function to call if it's necessary to do some work
-# if this configuration entry changes
-config_entries = {
- 'prefix_len' : {
- 'implicit' : 1,
- 'default' : 2 ,
- 'command-line' : {
- 'help' : 'Length of cache file name used as subdirectory prefix',
- 'metavar' : '<number>',
- 'type' : int
- },
- 'converter' : rearrange_cache_entries
- }
-}
-parser = argparse.ArgumentParser(
- description = 'Modify the configuration of an scons cache directory',
- epilog = '''
- Unless you specify an option, it will not be changed (if it is
- already set in the cache config), or changed to an appropriate
- default (it it is not set).
- '''
- )
-
-parser.add_argument('cache-dir', help='Path to scons cache directory')
-for param in config_entries:
- parser.add_argument('--' + param.replace('_', '-'),
- **config_entries[param]['command-line'])
-parser.add_argument('--version', action='version', version='%(prog)s 1.0')
-
-# Get the command line as a dict without any of the unspecified entries.
-args = dict(filter(lambda x: x[1], vars(parser.parse_args()).items()))
-
-# It seems somewhat strange to me, but positional arguments don't get the -
-# in the name changed to _, whereas optional arguments do...
-os.chdir(args['cache-dir'])
-del args['cache-dir']
-
-if not os.path.exists('config'):
- # Validate the only files in the directory are directories 0-9, a-f
- expected = [ '{:X}'.format(x) for x in range(0, 16) ]
- if not set(os.listdir('.')).issubset(expected):
- raise RuntimeError("This doesn't look like a version 1 cache directory")
- config = dict()
-else:
- with open('config') as conf:
- config = json.load(conf)
-
-# Find any keys that aren't currently set but should be
-for key in config_entries:
- if key not in config:
- if 'implicit' in config_entries[key]:
- config[key] = config_entries[key]['implicit']
- else:
- config[key] = config_entries[key]['default']
- if key not in args:
- args[key] = config_entries[key]['default']
-
-#Now we go through each entry in args to see if it changes an existing config
-#setting.
-for key in args:
- if args[key] != config[key]:
- if 'converter' in config_entries[key]:
- config_entries[key]['converter'](config[key], args[key])
- config[key] = args[key]
-
-# and write the updated config file
-with open('config', 'w') as conf:
- json.dump(config, conf) \ No newline at end of file
+#! /usr/bin/env python
+#
+# SCons - a Software Constructor
+#
+# Copyright (c) 2001 - 2017 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# 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 print_function
+
+__revision__ = "src/script/scons-configure-cache.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+
+__version__ = "3.0.0"
+
+__build__ = "rel_3.0.0:4395:8972f6a2f699"
+
+__buildsys__ = "ubuntu-16"
+
+__date__ = "2017/09/18 12:59:24"
+
+__developer__ = "bdbaddog"
+
+import argparse
+import glob
+import json
+import os
+
+def rearrange_cache_entries(current_prefix_len, new_prefix_len):
+ print('Changing prefix length from', current_prefix_len, 'to', new_prefix_len)
+ dirs = set()
+ old_dirs = set()
+ for file in glob.iglob(os.path.join('*', '*')):
+ name = os.path.basename(file)
+ dir = name[:current_prefix_len].upper()
+ if dir not in old_dirs:
+ print('Migrating', dir)
+ old_dirs.add(dir)
+ dir = name[:new_prefix_len].upper()
+ if dir not in dirs:
+ os.mkdir(dir)
+ dirs.add(dir)
+ os.rename(file, os.path.join(dir, name))
+
+ # Now delete the original directories
+ for dir in old_dirs:
+ os.rmdir(dir)
+
+# This dictionary should have one entry per entry in the cache config
+# Each entry should have the following:
+# implicit - (optional) This is to allow adding a new config entry and also
+# changing the behaviour of the system at the same time. This
+# indicates the value the config entry would have had if it had been
+# specified.
+# default - The value the config entry should have if it wasn't previously
+# specified
+# command-line - parameters to pass to ArgumentParser.add_argument
+# converter - (optional) Function to call if it's necessary to do some work
+# if this configuration entry changes
+config_entries = {
+ 'prefix_len' : {
+ 'implicit' : 1,
+ 'default' : 2 ,
+ 'command-line' : {
+ 'help' : 'Length of cache file name used as subdirectory prefix',
+ 'metavar' : '<number>',
+ 'type' : int
+ },
+ 'converter' : rearrange_cache_entries
+ }
+}
+parser = argparse.ArgumentParser(
+ description = 'Modify the configuration of an scons cache directory',
+ epilog = '''
+ Unless you specify an option, it will not be changed (if it is
+ already set in the cache config), or changed to an appropriate
+ default (it it is not set).
+ '''
+ )
+
+parser.add_argument('cache-dir', help='Path to scons cache directory')
+for param in config_entries:
+ parser.add_argument('--' + param.replace('_', '-'),
+ **config_entries[param]['command-line'])
+parser.add_argument('--version', action='version', version='%(prog)s 1.0')
+
+# Get the command line as a dict without any of the unspecified entries.
+args = dict([x for x in vars(parser.parse_args()).items() if x[1]])
+
+# It seems somewhat strange to me, but positional arguments don't get the -
+# in the name changed to _, whereas optional arguments do...
+os.chdir(args['cache-dir'])
+del args['cache-dir']
+
+if not os.path.exists('config'):
+ # Validate the only files in the directory are directories 0-9, a-f
+ expected = [ '{:X}'.format(x) for x in range(0, 16) ]
+ if not set(os.listdir('.')).issubset(expected):
+ raise RuntimeError("This doesn't look like a version 1 cache directory")
+ config = dict()
+else:
+ with open('config') as conf:
+ config = json.load(conf)
+
+# Find any keys that aren't currently set but should be
+for key in config_entries:
+ if key not in config:
+ if 'implicit' in config_entries[key]:
+ config[key] = config_entries[key]['implicit']
+ else:
+ config[key] = config_entries[key]['default']
+ if key not in args:
+ args[key] = config_entries[key]['default']
+
+#Now we go through each entry in args to see if it changes an existing config
+#setting.
+for key in args:
+ if args[key] != config[key]:
+ if 'converter' in config_entries[key]:
+ config_entries[key]['converter'](config[key], args[key])
+ config[key] = args[key]
+
+# and write the updated config file
+with open('config', 'w') as conf:
+ json.dump(config, conf)
diff --git a/script/scons-time b/script/scons-time
index 3438062..08bde60 100644
--- a/script/scons-time
+++ b/script/scons-time
@@ -9,7 +9,7 @@
#
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -29,10 +29,9 @@
# 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
+from __future__ import division, print_function
-__revision__ = "src/script/scons-time.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/script/scons-time.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import getopt
import glob
@@ -66,8 +65,8 @@ def HACK_for_exec(cmd, *args):
internal functions.
'''
if not args: exec(cmd)
- elif len(args) == 1: exec cmd in args[0]
- else: exec cmd in args[0], args[1]
+ elif len(args) == 1: exec(cmd, args[0])
+ else: exec(cmd, args[0], args[1])
class Plotter(object):
def increment_size(self, largest):
@@ -103,7 +102,7 @@ class Line(object):
def print_label(self, inx, x, y):
if self.label:
- print 'set label %s "%s" at %s,%s right' % (inx, self.label, x, y)
+ print('set label %s "%s" at %0.1f,%0.1f right' % (inx, self.label, x, y))
def plot_string(self):
if self.title:
@@ -116,15 +115,15 @@ class Line(object):
if fmt is None:
fmt = self.fmt
if self.comment:
- print '# %s' % self.comment
+ print('# %s' % self.comment)
for x, y in self.points:
# If y is None, it usually represents some kind of break
# in the line's index number. We might want to represent
# this some way rather than just drawing the line straight
# between the two points on either side.
if not y is None:
- print fmt % (x, y)
- print 'e'
+ print(fmt % (x, y))
+ print('e')
def get_x_values(self):
return [ p[0] for p in self.points ]
@@ -210,8 +209,8 @@ class Gnuplotter(Plotter):
return
if self.title:
- print 'set title "%s"' % self.title
- print 'set key %s' % self.key_location
+ print('set title "%s"' % self.title)
+ print('set key %s' % self.key_location)
min_y = self.get_min_y()
max_y = self.max_graph_value(self.get_max_y())
@@ -226,7 +225,7 @@ class Gnuplotter(Plotter):
inx += 1
plot_strings = [ self.plot_string(l) for l in self.lines ]
- print 'plot ' + ', \\\n '.join(plot_strings)
+ print('plot ' + ', \\\n '.join(plot_strings))
for line in self.lines:
line.print_points()
@@ -249,7 +248,7 @@ def unzip(fname):
os.makedirs(dir)
except:
pass
- open(name, 'w').write(zf.read(name))
+ open(name, 'wb').write(zf.read(name))
def read_tree(dir):
for dirpath, dirnames, filenames in os.walk(dir):
@@ -460,7 +459,9 @@ class SConsTimer(object):
output = os.popen(command).read()
if self.verbose:
sys.stdout.write(output)
- open(log, 'wb').write(output)
+ # TODO: Figure out
+ # Not sure we need to write binary here
+ open(log, 'w').write(output)
#
@@ -497,7 +498,7 @@ class SConsTimer(object):
header_fmt = ' '.join(['%12s'] * len(columns))
line_fmt = header_fmt + ' %s'
- print header_fmt % columns
+ print(header_fmt % columns)
for file in files:
t = line_function(file, *args, **kw)
@@ -507,7 +508,7 @@ class SConsTimer(object):
if diff > 0:
t += [''] * diff
t.append(file_function(file))
- print line_fmt % tuple(t)
+ print(line_fmt % tuple(t))
def collect_results(self, files, function, *args, **kw):
results = {}
@@ -647,7 +648,7 @@ class SConsTimer(object):
"""
try:
import pstats
- except ImportError, e:
+ except ImportError as e:
sys.stderr.write('%s: func: %s\n' % (self.name, e))
sys.stderr.write('%s This version of Python is missing the profiler.\n' % self.name_spaces)
sys.stderr.write('%s Cannot use the "func" subcommand.\n' % self.name_spaces)
@@ -708,7 +709,7 @@ class SConsTimer(object):
return self.default(argv)
try:
return func(argv)
- except TypeError, e:
+ except TypeError as e:
sys.stderr.write("%s %s: %s\n" % (self.name, cmdName, e))
import traceback
traceback.print_exc(file=sys.stderr)
@@ -813,7 +814,7 @@ class SConsTimer(object):
self.title = a
if self.config_file:
- exec open(self.config_file, 'rU').read() in self.__dict__
+ exec(open(self.config_file, 'r').read(), self.__dict__)
if self.chdir:
os.chdir(self.chdir)
@@ -846,13 +847,13 @@ class SConsTimer(object):
try:
f, line, func, time = \
self.get_function_profile(file, function_name)
- except ValueError, e:
+ except ValueError as e:
sys.stderr.write("%s: func: %s: %s\n" %
(self.name, file, e))
else:
if f.startswith(cwd_):
f = f[len(cwd_):]
- print "%.3f %s:%d(%s)" % (time, f, line, func)
+ print("%.3f %s:%d(%s)" % (time, f, line, func))
elif format == 'gnuplot':
@@ -932,7 +933,7 @@ class SConsTimer(object):
self.title = a
if self.config_file:
- HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
+ HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__)
if self.chdir:
os.chdir(self.chdir)
@@ -1052,7 +1053,7 @@ class SConsTimer(object):
object_name = args.pop(0)
if self.config_file:
- HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
+ HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__)
if self.chdir:
os.chdir(self.chdir)
@@ -1190,7 +1191,7 @@ class SConsTimer(object):
sys.exit(1)
if self.config_file:
- exec open(self.config_file, 'rU').read() in self.__dict__
+ exec(open(self.config_file, 'r').read(), self.__dict__)
if args:
self.archive_list = args
@@ -1423,14 +1424,14 @@ class SConsTimer(object):
elif o in ('--title',):
self.title = a
elif o in ('--which',):
- if not a in self.time_strings.keys():
+ if not a in list(self.time_strings.keys()):
sys.stderr.write('%s: time: Unrecognized timer "%s".\n' % (self.name, a))
sys.stderr.write('%s Type "%s help time" for help.\n' % (self.name_spaces, self.name))
sys.exit(1)
which = a
if self.config_file:
- HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
+ HACK_for_exec(open(self.config_file, 'r').read(), self.__dict__)
if self.chdir:
os.chdir(self.chdir)
diff --git a/script/scons.bat b/script/scons.bat
index 7a7690e..f759e43 100644
--- a/script/scons.bat
+++ b/script/scons.bat
@@ -1,11 +1,11 @@
-@REM Copyright (c) 2001 - 2016 The SCons Foundation
-@REM src/script/scons.bat rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog
+@REM Copyright (c) 2001 - 2017 The SCons Foundation
+@REM src/script/scons.bat rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog
@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-2.5.1'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-2.5.1'), 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-3.0.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-3.0.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
diff --git a/script/sconsign b/script/sconsign
index 90572c3..d3450ab 100644
--- a/script/sconsign
+++ b/script/sconsign
@@ -2,7 +2,7 @@
#
# SCons - a Software Constructor
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -23,15 +23,17 @@
# 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 rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+from __future__ import print_function
-__version__ = "2.5.1"
+__revision__ = "src/script/sconsign.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
-__build__ = "rel_2.5.1:3735:9dc6cee5c168[MODIFIED]"
+__version__ = "3.0.0"
-__buildsys__ = "mongodog"
+__build__ = "rel_3.0.0:4395:8972f6a2f699"
-__date__ = "2016/11/03 14:02:02"
+__buildsys__ = "ubuntu-16"
+
+__date__ = "2017/09/18 12:59:24"
__developer__ = "bdbaddog"
@@ -55,13 +57,6 @@ import sys
# engine modules if they're in either directory.
-if sys.version_info >= (3,0,0):
- msg = "sconsign: *** Version %s does not run under Python version %s.\n\
-Python 3 is not yet supported.\n"
- sys.stderr.write(msg % (__version__, sys.version.split()[0]))
- sys.exit(1)
-
-
script_dir = sys.path[0]
if script_dir in sys.path:
@@ -95,7 +90,7 @@ try:
except ImportError:
pass
else:
- # when running from an egg add the egg's directory
+ # when running from an egg add the egg's directory
try:
d = pkg_resources.get_distribution('scons')
except pkg_resources.DistributionNotFound:
@@ -182,9 +177,14 @@ sys.path = libs + sys.path
# END STANDARD SCons SCRIPT HEADER
##############################################################################
-import SCons.compat # so pickle will import cPickle instead
+import SCons.compat
+
+try:
+ import whichdb
+ whichdb = whichdb.whichdb
+except ImportError as e:
+ from dbm import whichdb
-import whichdb
import time
import pickle
import imp
@@ -202,8 +202,14 @@ def my_whichdb(filename):
pass
return _orig_whichdb(filename)
-_orig_whichdb = whichdb.whichdb
-whichdb.whichdb = my_whichdb
+
+# Should work on python2
+_orig_whichdb = whichdb
+whichdb = my_whichdb
+
+# was changed for python3
+#_orig_whichdb = whichdb.whichdb
+#dbm.whichdb = my_whichdb
def my_import(mname):
if '.' in mname:
@@ -235,6 +241,11 @@ def default_mapper(entry, name):
val = eval("entry."+name)
except:
val = None
+ if sys.version_info.major >= 3 and isinstance(val, bytes):
+ # This is a dirty hack for py 2/3 compatibility. csig is a bytes object
+ # in Python3 while Python2 bytes are str. Hence, we decode the csig to a
+ # Python3 string
+ val = val.decode()
return str(val)
def map_action(entry, name):
@@ -323,14 +334,14 @@ def printfield(name, entry, prefix=""):
outlist = field("implicit", entry, 0)
if outlist:
if Verbose:
- print " implicit:"
- print " " + outlist
+ print(" implicit:")
+ print(" " + outlist)
outact = field("action", entry, 0)
if outact:
if Verbose:
- print " action: " + outact
+ print(" action: " + outact)
else:
- print " " + outact
+ print(" " + outact)
def printentries(entries, location):
if Print_Entries:
@@ -343,9 +354,9 @@ def printentries(entries, location):
try:
ninfo = entry.ninfo
except AttributeError:
- print name + ":"
+ print(name + ":")
else:
- print nodeinfo_string(name, entry.ninfo)
+ print(nodeinfo_string(name, entry.ninfo))
printfield(name, entry.binfo)
else:
for name in sorted(entries.keys()):
@@ -353,9 +364,9 @@ def printentries(entries, location):
try:
ninfo = entry.ninfo
except AttributeError:
- print name + ":"
+ print(name + ":")
else:
- print nodeinfo_string(name, entry.ninfo)
+ print(nodeinfo_string(name, entry.ninfo))
printfield(name, entry.binfo)
class Do_SConsignDB(object):
@@ -374,7 +385,7 @@ class Do_SConsignDB(object):
# .sconsign => .sconsign.dblite
# .sconsign.dblite => .sconsign.dblite.dblite
db = self.dbm.open(fname, "r")
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
print_e = e
try:
# That didn't work, so try opening the base name,
@@ -388,7 +399,7 @@ class Do_SConsignDB(object):
# suffix-mangling).
try:
open(fname, "r")
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
# Nope, that file doesn't even exist, so report that
# fact back.
print_e = e
@@ -399,7 +410,7 @@ class Do_SConsignDB(object):
except pickle.UnpicklingError:
sys.stderr.write("sconsign: ignoring invalid `%s' file `%s'\n" % (self.dbm_name, fname))
return
- except Exception, e:
+ except Exception as e:
sys.stderr.write("sconsign: ignoring invalid `%s' file `%s': %s\n" % (self.dbm_name, fname, e))
return
@@ -416,13 +427,13 @@ class Do_SConsignDB(object):
self.printentries(dir, db[dir])
def printentries(self, dir, val):
- print '=== ' + dir + ':'
+ print('=== ' + dir + ':')
printentries(pickle.loads(val), dir)
def Do_SConsignDir(name):
try:
fp = open(name, 'rb')
- except (IOError, OSError), e:
+ except (IOError, OSError) as e:
sys.stderr.write("sconsign: %s\n" % (e))
return
try:
@@ -432,7 +443,7 @@ def Do_SConsignDir(name):
except pickle.UnpicklingError:
sys.stderr.write("sconsign: ignoring invalid .sconsign file `%s'\n" % (name))
return
- except Exception, e:
+ except Exception as e:
sys.stderr.write("sconsign: ignoring invalid .sconsign file `%s': %s\n" % (name, e))
return
printentries(sconsign.entries, args[0])
@@ -494,13 +505,13 @@ for o, a in opts:
SCons.dblite.ignore_corrupt_dbfiles = 0
except:
sys.stderr.write("sconsign: illegal file format `%s'\n" % a)
- print helpstr
+ print(helpstr)
sys.exit(2)
Do_Call = Do_SConsignDB(a, dbm)
else:
Do_Call = Do_SConsignDir
elif o in ('-h', '--help'):
- print helpstr
+ print(helpstr)
sys.exit(0)
elif o in ('-i', '--implicit'):
Print_Flags['implicit'] = 1
@@ -515,12 +526,13 @@ for o, a in opts:
elif o in ('-v', '--verbose'):
Verbose = 1
+
if Do_Call:
for a in args:
Do_Call(a)
else:
for a in args:
- dbm_name = whichdb.whichdb(a)
+ dbm_name = whichdb(a)
if dbm_name:
Map_Module = {'SCons.dblite' : 'dblite'}
if dbm_name != "SCons.dblite":