Upgrade: adapt to use Scons 4.x which uses Python 3

The build system Scons switched from using Python 2.7 to using
Python 3.x, so the build breaks on, for example, Debian Bullseye.

As a first step use `ato3` to convert Python scripts from 2 to 3.
This commit is contained in:
benn 2022-09-05 23:02:29 +02:00 committed by Ichthyostega
parent cc9a1e410a
commit 406275abbe
9 changed files with 34 additions and 33 deletions

View file

@ -23,6 +23,7 @@ import os
import os.path
import glob
from fnmatch import fnmatch
from functools import reduce
def DoxyfileParse(file_contents):
@ -62,7 +63,7 @@ def DoxyfileParse(file_contents):
key_token = False
else:
if token == "+=":
if not data.has_key(key):
if key not in data:
data[key] = list()
elif token == "=":
data[key] = list()
@ -78,7 +79,7 @@ def DoxyfileParse(file_contents):
append_data(data, key, new_data, '\\')
# compress lists of len 1 into single strings
for (k, v) in data.items():
for (k, v) in list(data.items()):
if len(v) == 0:
data.pop(k)
@ -146,7 +147,7 @@ def DoxySourceScan(node, env, path):
for pattern in file_patterns:
sources.extend(glob.glob("/".join([node, pattern])))
sources = map( lambda path: env.File(path), sources )
sources = [env.File(path) for path in sources]
return sources
@ -172,7 +173,7 @@ def DoxyEmitter(source, target, env):
out_dir = data.get("OUTPUT_DIRECTORY", ".")
# add our output locations
for (k, v) in output_formats.items():
for (k, v) in list(output_formats.items()):
if data.get("GENERATE_" + k, v[0]) == "YES":
targets.append(env.Dir( os.path.join(out_dir, data.get(k + "_OUTPUT", v[1]))) )

View file

@ -47,11 +47,11 @@ def setup_dependency(target,source,env, key):
path = scanner.path(env)
deps = scanner(source[0], env, path)
if env.has_key(key) and env[key]:
if key in env and env[key]:
for header in env[key]:
header_path = header.path.strip('.gch')
if header_path in [x.path for x in deps]:
print "Precompiled header(%s) %s \t <--- %s" % (key,header_path,source[0])
print("Precompiled header(%s) %s \t <--- %s" % (key,header_path,source[0]))
env.Depends(target, header)

View file

@ -113,7 +113,7 @@ def filterNodes(nlist, removeName=None):
else:
predicate = lambda n : True
return filter(predicate, nlist)
return list(filter(predicate, nlist))
@ -167,13 +167,13 @@ def checkCommandOption(env, optID, val=None, cmdName=None):
if val=='True' or val=='true' or val=='yes' or val=='1' or val == 1 :
if not cmdName:
print "WARNING: no default for %s, please specify a full path." % optID
print("WARNING: no default for %s, please specify a full path." % optID)
del env[optID]
return False
else:
val = env.WhereIs(cmdName)
if not val:
print "WARNING: %s not found, please specify a full path" % cmdName
print("WARNING: %s not found, please specify a full path" % cmdName)
del env[optID]
return False
@ -218,7 +218,7 @@ def extract_localPathDefs (localDefs):
pattern and returns them wrapped into a Record for convenient access
"""
def relevantPathDefs (mapping):
for (k,v) in mapping.items():
for (k,v) in list(mapping.items()):
if (k.startswith('src') or k.startswith('build') or k.startswith('install')) and Util.is_String(v):
v = v.strip()
if not v.endswith('/'): v += '/'

View file

@ -54,7 +54,7 @@ def createDirectory (name):
if not os.path.exists (name):
os.mkdir (name)
except:
print 'WARNING: createDirectory("%s") failed. Permission problems?' % name
print('WARNING: createDirectory("%s") failed. Permission problems?' % name)
def copyMergeDirectory (src, dst):
@ -91,7 +91,7 @@ def parsePlateLayer (layer):
def parseSVG (file_path):
print "Parsing " + file_path
print("Parsing " + file_path)
svgdoc = minidom.parse (file_path)
for root_node in svgdoc.childNodes:
if root_node.nodeType == minidom.Node.ELEMENT_NODE:
@ -114,7 +114,7 @@ def renderSvgRsvg (file_path, out_dir, artwork_name, rectangle, _doc_size):
height = int(rectangle[3])
if not os.path.exists(rsvgPath):
print "Error: executable %s not found." % rsvgPath
print("Error: executable %s not found." % rsvgPath)
os.spawnlp(os.P_WAIT, rsvgPath, rsvgPath,
"--source-rect=%g:%g:%g:%g" % (rectangle[0], rectangle[1], width, height),
@ -135,8 +135,8 @@ def getTargetNames (file_path):
def printHelp():
print "render-icon.py SRCFILE.svg TARGETDIR"
print "An icon rendering utility script for lumiera"
print("render-icon.py SRCFILE.svg TARGETDIR")
print("An icon rendering utility script for lumiera")
def parseArguments(argv):
_optlist, args = getopt.getopt(argv, "")
@ -152,14 +152,14 @@ def main (argv):
in_path, out_dir = parseArguments(argv)
if not (in_path and out_dir):
print "Missing arguments in_path and out_dir."
print("Missing arguments in_path and out_dir.")
sys.exit(1)
if os.path.isfile(out_dir):
print "Unable to use '%s' as output directory, because it\'s a file." % out_dir
print("Unable to use '%s' as output directory, because it\'s a file." % out_dir)
sys.exit(1)
if not os.path.isdir(out_dir):
print "Output directory '%s' not found." % out_dir
print("Output directory '%s' not found." % out_dir)
sys.exit(1)
# Create the icons folders

View file

@ -48,7 +48,7 @@ class LumieraEnvironment(Environment):
def Configure (self, *args, **kw):
kw['env'] = self
return apply(LumieraConfigContext, args, kw)
return LumieraConfigContext(*args, **kw)
def mergeConf (self,other):
""" extract the library/compiler flags from other Environment.
@ -77,7 +77,7 @@ class LumieraEnvironment(Environment):
"""
minVersion = str(minVersion)
if 0 != os.system('pkg-config --print-errors --exists "%s >= %s"' % (libID,minVersion)):
print "Problems configuring the Library %s (>= %s)" % (libID,minVersion)
print("Problems configuring the Library %s (>= %s)" % (libID,minVersion))
return False
self.libInfo[libID] = libInfo = Environment()
@ -104,7 +104,7 @@ class LumieraConfigContext(ConfigBase):
ConfigBase.__init__(self,*args,**kw)
def CheckPkgConfig (self, libID, minVersion=0, alias=None):
print "Checking for library configuration: %s " % libID
print("Checking for library configuration: %s " % libID)
# self.Message(self,"Checking for library configuration: %s " % libID)
return self.env.addLibInfo (libID, minVersion, alias)
@ -212,7 +212,7 @@ class WrappedStandardExeBuilder(SCons.Util.Proxy):
def __init__(self, originalBuilder):
SCons.Util.Proxy.__init__ (self, originalBuilder)
def __nonzero__(self): return True
def __bool__(self): return True
def __call__(self, env, target=None, source=None, **kw):
""" when the builder gets invoked from the SConscript...

View file

@ -57,7 +57,7 @@ def configure(env):
if conf.CheckCHeader('valgrind/valgrind.h'):
conf.env.Append(CPPFLAGS = ' -DHAVE_VALGRIND_H')
else:
print 'Valgrind not found. The use of Valgrind is optional; building without.'
print('Valgrind not found. The use of Valgrind is optional; building without.')
if not conf.CheckPkgConfig('nobugmt', 201008.1):
problems.append('Did not find NoBug [http://nobug.pipapo.org/].')
@ -141,14 +141,14 @@ def configure(env):
# report missing dependencies
if problems:
print "*** unable to build due to the following problems:"
print("*** unable to build due to the following problems:")
for isue in problems:
print " * %s" % isue
print
print "build aborted."
print(" * %s" % isue)
print()
print("build aborted.")
Exit(1)
print "** Gathered Library Info: %s" % conf.env.libInfo.keys()
print("** Gathered Library Info: %s" % list(conf.env.libInfo.keys()))
# create new env containing the finished configuration

View file

@ -111,7 +111,7 @@ def handleNoBugSwitches(env):
level = env['BUILDLEVEL']
if level in ['ALPHA', 'BETA']:
if not env['DEBUG']:
print 'Warning: NoBug ALPHA or BETA builds requires DEBUG=yes, switching DEBUG on!'
print('Warning: NoBug ALPHA or BETA builds requires DEBUG=yes, switching DEBUG on!')
env.Replace( DEBUG = 1 )
env.Append(CPPDEFINES = 'EBUG_'+level)
elif level == 'RELEASE':

View file

@ -34,7 +34,7 @@ def generate(env):
env['CC'] = env.subst('$CCACHE $CC')
if not env['CCACHE'] in env['CXX']:
env['CXX'] = env.subst('$CCACHE $CXX')
print env.subst("* Build using $CCACHE")
print(env.subst("* Build using $CCACHE"))
for i in ['HOME'
,'CCACHE_DIR'
@ -55,7 +55,7 @@ def generate(env):
,'CCACHE_UNIFY'
,'CCACHE_EXTENSION'
]:
if os.environ.has_key(i) and not env.has_key(i):
if i in os.environ and i not in env:
env['ENV'][i] = os.environ[i]

View file

@ -34,7 +34,7 @@ def generate(env):
env['CC'] = env.subst('$DISTCC $CC')
if not env['DISTCC'] in env['CXX']:
env['CXX'] = env.subst('$DISTCC $CXX')
print env.subst("* Build using $DISTCC")
print(env.subst("* Build using $DISTCC"))
for i in ['HOME'
,'DISTCC_HOSTS'
,'DISTCC_VERBOSE'
@ -45,7 +45,7 @@ def generate(env):
,'DISTCC_TCP_CORK'
,'DISTCC_SSH'
]:
if os.environ.has_key(i) and not env.has_key(i):
if i in os.environ and i not in env:
env['ENV'][i] = os.environ[i]