AFAIK (not sure, for I'm not using LL's build system), the Python
scripts in llbase are already Python v3 compatible. The llmanifest.py
script in the viewer sources might however still be a Python v2 script.
For my viewer (which uses a stand-alone build system with just a few
of the llbase scripts needed and included in its source tree), I
modified llmanifest.py (in fact, I kept the old one for Python v2 and
made a llmanifest3.py for Python 3, loading the right script from
viewer_manifest.py depending on the Python version).
You would not be able to just use my llmanifest3.py version (because
the sources layout is different than LL's viewer), but here is a diff
between the two, that could give you an idea of what you would need to
change to get your viewer to compile with Python v3:
---------------------- < cut here >----------------------
--- llmanifest.py 2020-09-26 16:29:04.434856548 +0200
+++ llmanifest3.py 2020-09-26 16:19:49.884873932 +0200
@@ -1,7 +1,7 @@
"""\
-@file llmanifest.py
+@file llmanifest3.py
@author Ryan Williams
-@brief Python2 library for specifying operations on a set of files.
+@brief Library for specifying operations on a set of files.
$LicenseInfo:firstyear=2007&license=mit$
@@ -153,20 +153,20 @@
def usage(srctree=""):
nd = {'name':sys.argv[0]}
- print """Usage:
+ print("""Usage:
%(name)s [options] [destdir]
Options:
- """ % nd
+ """ % nd)
for arg in ARGUMENTS:
default = arg['default']
if hasattr(default, '__call__'):
default = "(computed value) \"" + str(default(srctree)) + '"'
elif default is not None:
default = '"' + default + '"'
- print "\t--%s Default: %s\n\t%s\n" % (
+ print("\t--%s Default: %s\n\t%s\n" % (
arg['name'],
default,
- arg['description'] % nd)
+ arg['description'] % nd))
def main():
option_names = [arg['name'] + '=' for arg in ARGUMENTS]
@@ -183,9 +183,9 @@
for k in 'build dest source'.split():
args[k] = os.path.normpath(args[k])
- print "Source tree:", args['source']
- print "Build tree:", args['build']
- print "Destination tree:", args['dest']
+ print("Source tree:", args['source'])
+ print("Build tree:", args['build'])
+ print("Destination tree:", args['dest'])
# early out for help
if 'help' in args:
@@ -211,7 +211,7 @@
# debugging
for opt in args:
- print "Option:", opt, "=", args[opt]
+ print("Option:", opt, "=", args[opt])
wm = LLManifest.for_platform(args['platform'])(args)
wm.do(*args['actions'])
@@ -223,7 +223,7 @@
fp = open(touch, 'w')
fp.write('set package_file=%s\n' % wm.package_file)
fp.close()
- print 'touched', touch
+ print('touched', touch)
return 0
class LLManifestRegistry(type):
@@ -233,8 +233,7 @@
if match:
cls.manifests[match.group(1).lower()] = cls
-class LLManifest(object):
- __metaclass__ = LLManifestRegistry
+class LLManifest(object, metaclass=LLManifestRegistry):
manifests = {}
def for_platform(self, platform):
return self.manifests[platform.lower()]
@@ -289,7 +288,7 @@
build = self.build_prefix.pop()
dst = self.dst_prefix.pop()
if descr and not(src == descr or build == descr or dst == descr):
- raise ValueError, "End prefix '" + descr + "' didn't match '" +src+ "' or '" +dst + "'"
+ raise ValueError("End prefix '" + descr + "' didn't match '" +src+ "' or '" +dst + "'")
def get_src_prefix(self):
""" Returns the current source prefix."""
@@ -339,7 +338,7 @@
an exception if the command reurns a nonzero status code. For
debugging/informational purpoases, prints out the command's
output as it is received."""
- print "Running command:", command
+ print("Running command:", command)
fd = os.popen(command, 'r')
lines = []
while True:
@@ -347,7 +346,7 @@
if lines[-1] == '':
break
else:
- print lines[-1],
+ print(lines[-1], end=' ')
output = ''.join(lines)
status = fd.close()
if status:
@@ -361,7 +360,7 @@
a) verify that you really have created it
b) schedule it for cleanup"""
if not os.path.exists(path):
- raise RuntimeError, "Should be something at path " + path
+ raise RuntimeError("Should be something at path " + path)
self.created_paths.append(path)
def put_in_file(self, contents, dst, src=None):
@@ -388,7 +387,7 @@
contents = f.read()
f.close()
# apply dict replacements
- for old, new in searchdict.iteritems():
+ for old, new in searchdict.items():
contents = contents.replace(old, new)
self.put_in_file(contents, dst)
self.created_paths.append(dst)
@@ -404,7 +403,7 @@
# src is a dir
self.ccopytree(src,dst)
else:
- print "Doesn't exist:", src
+ print("Doesn't exist:", src)
def package_action(self, src, dst):
pass
@@ -419,7 +418,7 @@
unpacked_file_name = "unpacked_%(plat)s_%(vers)s.tar" % {
'plat':self.args['platform'],
'vers':'_'.join(self.args['version'])}
- print "Creating unpacked file:", unpacked_file_name
+ print("Creating unpacked file:", unpacked_file_name)
# could add a gz here but that doubles the time it takes to do this step
tf = tarfile.open(self.src_path_of(unpacked_file_name), 'w:')
# add the entire installation package, at the very top level
@@ -430,7 +429,7 @@
""" Delete paths that were specified to have been created by this script"""
for c in self.created_paths:
# *TODO is this gonna be useful?
- print "Cleaning up " + c
+ print("Cleaning up " + c)
def process_file(self, src, dst):
if self.includes(src, dst):
@@ -475,7 +474,7 @@
def remove(self, *paths):
for path in paths:
if os.path.exists(path):
- print "Removing path", path
+ print("Removing path", path)
if os.path.isdir(path):
shutil.rmtree(path)
else:
@@ -498,7 +497,7 @@
if self.includes(src, dst):
try:
os.unlink(dst)
- except OSError, err:
+ except OSError as err:
if err.errno != errno.ENOENT:
raise
@@ -523,10 +522,10 @@
else:
self.ccopy(srcname, dstname)
# XXX What about devices, sockets etc.?
- except (IOError, os.error), why:
+ except (IOError, os.error) as why:
errors.append((srcname, dstname, why))
if errors:
- raise RuntimeError, errors
+ raise RuntimeError(errors)
def cmakedirs(self, path):
@@ -646,7 +645,7 @@
# files. src is probably a wildcard meant for some other pfx. Loop
# back to try the next.
- print "%d files" % count
+ print("%d files" % count)
# Let caller check whether we processed as many files as expected. In
# particular, let caller notice 0.
---------------------- < cut here >----------------------
Henri.