Use Python 3 for all scripts of the build system. configure.in: enforce Python version >= 3.0 Updated Python scripts with "2to3" and added a shebang.

This commit is contained in:
Matthias Rustler 2019-12-29 23:33:21 +01:00 committed by deadwood
parent c57cba2f42
commit f93f13178a
13 changed files with 130 additions and 109 deletions

13
configure vendored
View File

@ -6371,13 +6371,13 @@ fi
if test -n "$PYTHON"; then
# If the user set $PYTHON, use it and don't search something else.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version is >= 2.5" >&5
$as_echo_n "checking whether $PYTHON version is >= 2.5... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version is >= 3.0" >&5
$as_echo_n "checking whether $PYTHON version is >= 3.0... " >&6; }
prog="import sys
# split strings by '.' and convert to numeric. Append some zeros
# because we need at least 4 digits for the hex conversion.
# map returns an iterator in Python 3.0 and a list in 2.x
minver = list(map(int, '2.5'.split('.'))) + [0, 0, 0]
minver = list(map(int, '3.0'.split('.'))) + [0, 0, 0]
minverhex = 0
# xrange is not present in Python 3.0 and range returns an iterator
for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[i]
@ -6398,8 +6398,8 @@ fi
else
# Otherwise, try each interpreter until we find one that satisfies
# VERSION.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a Python interpreter with version >= 2.5" >&5
$as_echo_n "checking for a Python interpreter with version >= 2.5... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a Python interpreter with version >= 3.0" >&5
$as_echo_n "checking for a Python interpreter with version >= 3.0... " >&6; }
if ${am_cv_pathless_PYTHON+:} false; then :
$as_echo_n "(cached) " >&6
else
@ -6410,7 +6410,7 @@ else
# split strings by '.' and convert to numeric. Append some zeros
# because we need at least 4 digits for the hex conversion.
# map returns an iterator in Python 3.0 and a list in 2.x
minver = list(map(int, '2.5'.split('.'))) + [0, 0, 0]
minver = list(map(int, '3.0'.split('.'))) + [0, 0, 0]
minverhex = 0
# xrange is not present in Python 3.0 and range returns an iterator
for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[i]
@ -9907,7 +9907,6 @@ fi
$as_echo "$aros_gcc_cpu" >&6; }
aros_isa_flags="$""(ISA_MC"$aros_gcc_cpu"_FLAGS)"
;;
*x86_64*)
aros_isa_extra="$export_newline$x86_isa_extra$export_newline$x86_64_isa_extra$export_newline"

View File

@ -597,7 +597,8 @@ AROS_REQUIRED(chmod,$CHMOD)
AROS_PROG(PATCH,[patch])
AROS_REQUIRED(patch,$PATCH)
AM_PATH_PYTHON(2.5)
dnl TODO it might be necessary to use a higher version of Python 3
AM_PATH_PYTHON(3.0)
AC_ARG_ENABLE([libpng-config], [--disable-libpng-config disable libpng-config test and configuration])
if test "$enable_libpng_config" != "no"; then

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
""" This script is used to generate built-in string tables for dos.library
They use very own format which is impossible to generate with FlexCat.
@ -34,19 +34,19 @@ def main():
strings.append(str_line)
print "/* This file is automatically generated! Do not edit! */"
print
print("/* This file is automatically generated! Do not edit! */")
print()
print "/*"
print " * Error codes index table."
print " * This table actually consists of pairs of values (begin, end)."
print " * One string in the table below corresponds to one error code"
print " * from the specified interval."
print " * The table is terminated by two zeros."
print " * This layout was recreated based on locale.library code brought from MorphOS."
print " */"
print "const ULONG err_Numbers[] ="
print "{"
print("/*")
print(" * Error codes index table.")
print(" * This table actually consists of pairs of values (begin, end).")
print(" * One string in the table below corresponds to one error code")
print(" * from the specified interval.")
print(" * The table is terminated by two zeros.")
print(" * This layout was recreated based on locale.library code brought from MorphOS.")
print(" */")
print("const ULONG err_Numbers[] =")
print("{")
first = ids[0]
last = ids[0]
n = 0
@ -56,25 +56,25 @@ def main():
if int(numbers[n]) == prev + 1:
last = ids[n]
else:
print " %s, %s," % (first, last)
print(" %s, %s," % (first, last))
first = ids[n]
last = ids[n]
print " 0, 0"
print "};"
print
print(" 0, 0")
print("};")
print()
print "/*"
print " * Strings follow each other."
print " * Every string is prefixed by length byte in BCPL manner. NULL terminator is counted too."
print " */"
print "const char err_Strings[] ="
print "{"
print("/*")
print(" * Strings follow each other.")
print(" * Every string is prefixed by length byte in BCPL manner. NULL terminator is counted too.")
print(" */")
print("const char err_Strings[] =")
print("{")
for str_line in strings:
print " %d," % (len(str_line) + 1)
print(" %d," % (len(str_line) + 1))
for c in str_line:
print "'%s'," % c,
print "0,"
print "};"
print("'%s'," % c, end=' ')
print("0,")
print("};")
fhandle.close()

View File

@ -1,5 +1,7 @@
#!/usr/bin/env python3
# -*- coding: iso-8859-1 -*-
# Copyright © 2013-2017, The AROS Development Team. All rights reserved.
# Copyright (C) 2013-2017, The AROS Development Team. All rights reserved.
# Copy directory 'src' recursively to 'dst' while ignoring
# all files given by 'ignore' parameter. Only files younger
@ -29,12 +31,17 @@ def in_ignore_list(name, ignore):
def copy_tree(src, dst, ignore):
# Conversion to Unicode is needed in order to yield Unicode file names.
# This can be important on Windows. Without this the script fails to access
# directories like Locale/Help/Español on non-western systems, where locale
# directories like Locale/Help/Espanol on non-western systems, where locale
# is different from Latin-1 (e. g. russian).
# See http://docs.python.org/2/howto/unicode.html#unicode-filenames
src_u = unicode(src, "utf-8").encode("utf-8")
names = os.listdir(src_u)
# TODO: the following didn't work anymore with Python 3
#src_u = str(src, "utf-8").encode("utf-8")
#names = os.listdir(src_u)
names = os.listdir(src)
if not os.path.exists(dst):
os.makedirs(dst)
@ -71,9 +78,9 @@ for arg in sys.argv:
elif arg == "-e":
state = st_exclude
elif arg == "-h":
print "Usage: python cpy-dir-rec.py -s <souredir> -d <target directories> [-e <files to exclude>]"
print("Usage: python cpy-dir-rec.py -s <souredir> -d <target directories> [-e <files to exclude>]")
elif arg[0] == "-":
print "cpy-dir-rec: unknown argument %s" % arg
print("cpy-dir-rec: unknown argument %s" % arg)
sys.exit(1)
else:
if state == st_source:
@ -84,5 +91,5 @@ for arg in sys.argv:
ignore.append(arg)
for destdir in destdirs:
print "Copying directory '%s' to '%s', ignore '%s'" % (sourcedir, destdir, ignore)
print("Copying directory '%s' to '%s', ignore '%s'" % (sourcedir, destdir, ignore))
copy_tree(sourcedir, destdir, ignore)

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python
#!/usr/bin/env python3
# This program reads the output of cxref:
# http://www.gedanken.demon.co.uk/cxref/
@ -67,12 +67,12 @@ try:
if opt == '-k':
knownflag = 1
if opt == '-t':
if papertypes.has_key(arg):
if arg in papertypes:
paperdef = papertypes[arg]
else:
raise getopt.error, "unknown paper type '%s'" % arg
raise getopt.error("unknown paper type '%s'" % arg)
except getopt.error, msg:
except getopt.error as msg:
sys.stderr.write("%s: %s\n" % (__scriptname, msg))
printusage()
sys.exit(1)
@ -96,7 +96,7 @@ for line in profile:
l = sp.split(string.strip(line))
node = l[1]
nodelist.append(node)
if filename.has_key(node) or calls.has_key(node):
if node in filename or node in calls:
sys.stderr.write("duplicate function '%s', ignoring previous definition\n" % node)
filename[node] = l[0]
calls[node] = []
@ -105,16 +105,16 @@ for line in profile:
# Output the graph.
print 'digraph call {'
print 'page = "%(page)s"; %(rotate)s size = "%(size)s"' % paperdef
print 'ratio = fill; center = 1'
print('digraph call {')
print('page = "%(page)s"; %(rotate)s size = "%(size)s"' % paperdef)
print('ratio = fill; center = 1')
for node in nodelist:
if nodeflag:
label = '%s\\n%s' % (node, filename[node])
print '%s [label = "%s"]' % (node, label)
print('%s [label = "%s"]' % (node, label))
for n in calls[node]:
if not knownflag or n in nodelist:
print node, '->', n
print(node, '->', n)
print '}'
print('}')

View File

@ -1,14 +1,14 @@
#! @PYTHON@
#!/usr/bin/env python3
# -*- coding: iso-8859-1 -*-
# Copyright © 2003-2008, The AROS Development Team. All rights reserved.
# Copyright (C) 2003-2008, The AROS Development Team. All rights reserved.
import sys, re, os, errno
if not len(sys.argv) in [2, 3, 4, 5] :
print "Usage:",sys.argv[0],"tmplfile [inputfile outputfile]"
print "Usage:",sys.argv[0],"tmplfile --usetmp [inputfile outputfile]"
print "Usage:",sys.argv[0],"tmplfile --listfile filename"
print "Usage:",sys.argv[0],"tmplfile --usetmp --listfile filename"
print("Usage:",sys.argv[0],"tmplfile [inputfile outputfile]")
print("Usage:",sys.argv[0],"tmplfile --usetmp [inputfile outputfile]")
print("Usage:",sys.argv[0],"tmplfile --listfile filename")
print("Usage:",sys.argv[0],"tmplfile --usetmp --listfile filename")
# A regular expression for the start of a template instantiation (ex. %build_module)
re_tmplinst = re.compile('%([a-zA-Z0-9][a-zA-Z0-9_]*)(?=(?:\s|$))')
@ -47,7 +47,7 @@ def generate_templrefs(lines, templates):
continue
m = re_tmplinst.search(line)
if m and templates.has_key(m.group(1)) and not (m.start() > 0 and line[m.start()-1] == "#"):
if m and m.group(1) in templates and not (m.start() > 0 and line[m.start()-1] == "#"):
templrefs.append((lineno, m))
return templrefs
@ -79,7 +79,7 @@ def writelines(lines, templrefs, templates, outfile):
try:
templates[m.group(1)].write(outfile, m.group(1), line[m.end():].lstrip(), templates)
except GenmfException, ge:
except GenmfException as ge:
raise GenmfException(("In instantiation of %s, line %d\n" % (m.group(1), lineno+1))+ge.s)
if start < len(lines):
@ -159,7 +159,7 @@ class template:
self.linerefs = None
self.templrefs = None
for argname, argbody in args.items():
for argname, argbody in list(args.items()):
if argbody.ismulti:
if self.multiarg:
sys.exit('A template can have only one main (/M) argument')
@ -176,7 +176,7 @@ class template:
while lineno < len(self.body):
argrefs = []
for m in template.re_arginst.finditer(self.body[lineno]):
if self.args.has_key(m.group(2)):
if m.group(2) in self.args:
argbody = self.args[m.group(2)]
argrefs.append((argbody, m.start(), m.end(),m.group(1),m.group(3)))
argbody.used = 1
@ -187,7 +187,7 @@ class template:
lineno = lineno+1
self.linerefs = linerefs
for argname, argbody in self.args.items():
for argname, argbody in list(self.args.items()):
if not argbody.used:
sys.stderr.write("Warning: template '%s': unused argument '%s'\n" % (self.name, argname))
@ -202,7 +202,7 @@ class template:
argno = 0
while len(line) > 0:
m = re_arg.match(line)
if m and self.args.has_key(m.group(1)):
if m and m.group(1) in self.args:
value = m.group(2)
if value == None:
#sys.stderr.write("Arg:"+m.group(1)+" Value: None Line:"+line+"\n")
@ -223,13 +223,13 @@ class template:
self.generate_linerefs()
self.templrefs = generate_templrefs(self.body, templates)
for argname, argbody in self.args.items():
for argname, argbody in list(self.args.items()):
if argbody.isneeded and argbody.value == None:
raise GenmfException('Arg "%s" not specified but should have been' % argname)
text = self.body[:]
for lineno, argrefs in self.linerefs.items():
for lineno, argrefs in list(self.linerefs.items()):
line = text[lineno]
pos=0
@ -261,7 +261,7 @@ class template:
writelines(text, self.templrefs, templates, outfile)
#outfile.write('\n')
for argname, argbody in self.args.items():
for argname, argbody in list(self.args.items()):
argbody.value = None
self.used = 0
@ -273,7 +273,7 @@ def read_templates(filename):
try:
infile = open(filename)
except:
print "Error reading template file: "+filename
print("Error reading template file: "+filename)
re_name = re.compile('[a-zA-Z0-9][a-zA-Z0-9_]*(?=(?:\s|$))')
re_openstring = re.compile('[^\s"]*"[^"]*$')
@ -311,7 +311,7 @@ def read_templates(filename):
lineno = lineno+1
line = lines[lineno]
bodystart = lineno
while lineno < len(lines) and line[0:4] <> "%end":
while lineno < len(lines) and line[0:4] != "%end":
lineno = lineno+1
line = lines[lineno]
@ -372,7 +372,7 @@ if listfile == None:
try:
writelines(lines, generate_templrefs(lines, templates), templates, outfile)
except GenmfException, ge:
except GenmfException as ge:
s = ge.s
if len(sys.argv) == argin + 2:
s = sys.argv[argin + 1]+":"+s
@ -381,7 +381,7 @@ if listfile == None:
# If %common was not present in the file write it out at the end of the file
if not template.hascommon:
outfile.write("\n")
if templates.has_key("common"):
if "common" in templates:
templates["common"].write(outfile, "common", "", templates)
if closeout:
@ -403,7 +403,7 @@ else:
for fileno in range(len(filelist)):
files = filelist[fileno].split()
if len(files) <> 2:
if len(files) != 2:
sys.exit('%s:%d: Syntax error: %s' % (listfile, fileno+1, filelist[fileno]))
progcount = progcount + 1
@ -412,14 +412,14 @@ else:
sys.stderr.write('.')
sys.stderr.flush()
infile = open(files[0], "r")
infile = open(files[0], "r", encoding = "iso-8859-1")
lines = infile.readlines()
infile.close()
try:
# os.makedirs will also create all the parent directories
os.makedirs(os.path.dirname(files[1]))
except OSError, err:
except OSError as err:
# Do nothing ..
s = err.errno
@ -432,7 +432,7 @@ else:
try:
writelines(lines, generate_templrefs(lines, templates), templates, outfile)
except GenmfException, ge:
except GenmfException as ge:
s = ge.s
if len(sys.argv) == argin + 2:
s = files[0]+":"+s
@ -440,7 +440,7 @@ else:
if not template.hascommon:
outfile.write("\n")
if templates.has_key("common"):
if "common" in templates:
templates["common"].write(outfile, "common", "", templates)
outfile.close()

View File

@ -1,3 +1,5 @@
#!/usr/bin/env python3
import re, os, sys
class Module:
@ -27,7 +29,7 @@ def loadsymbolinformation():
# New module is needed
if (modname != lastmodname):
if (module):
print "%s %x %x" % (module.name, module.minaddr, module.maxaddr)
print("%s %x %x" % (module.name, module.minaddr, module.maxaddr))
module = Module()
module.name = modname
modules.append(module)
@ -71,7 +73,7 @@ def main():
addmodulespec.nextmoduleid = 1000
print "Processing..."
print("Processing...")
reg = r'([c]*fn=\(\d*\) )0x([a-f0-9]*)'
output = open(sys.argv[1] + ".processed", "w")

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2013, The AROS Development Team. All rights reserved.
# $Id$
@ -39,7 +40,7 @@ TITLES_REGX = re.compile(r"""
def parsedoc(filename, targetdir):
# print "reading " + filename
blocks = {}
filehandle = open(filename)
filehandle = open(filename, encoding="ISO-8859-15")
content = filehandle.read()
doc = AD_REGX.search(content)
current_title = None
@ -53,13 +54,13 @@ def parsedoc(filename, targetdir):
blocks[current_title] += line.expandtabs()[4:] + "\n"
# check for empty chapters, because we don't want to print them
for title, content in blocks.iteritems():
for title, content in blocks.items():
if content.strip() == "":
blocks[title] = ""
filehandle.close()
if blocks.has_key("NAME"):
if "NAME" in blocks:
# get docname
docname = blocks["NAME"].split()[0]
if docname == "":
@ -81,7 +82,7 @@ def parsedoc(filename, targetdir):
for title in shell_titles:
title_key = title.upper()
if blocks.has_key(title_key) and blocks[title_key] != "":
if title_key in blocks and blocks[title_key] != "":
filehandle.write("@{B}" + title + "@{UB}\n")
filehandle.write(blocks[title_key])
filehandle.write("\n")
@ -97,7 +98,7 @@ def main():
sourcedir = sys.argv[1]
targetdir = sys.argv[2]
print "gendoc sourcedir " + sourcedir + " targetdir " + targetdir
print("gendoc sourcedir " + sourcedir + " targetdir " + targetdir)
if not os.path.exists(targetdir):
os.mkdir(targetdir)

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2013, The AROS Development Team. All rights reserved.
# $Id$
@ -31,7 +32,7 @@ def write_section(helpdir, filehandle, section):
def main():
helpdir = sys.argv[1]
print "genindex helpdir " + helpdir
print("genindex helpdir " + helpdir)
sections = (
("Commands", "C:"),
@ -40,7 +41,7 @@ def main():
today = datetime.date.today()
filehandle = open(os.path.join(helpdir, "Index.guide"), "w")
filehandle = open(os.path.join(helpdir, "Index.guide"), "w", encoding="ISO-8859-15")
filehandle.write("@DATABASE Index.guide\n\n")
filehandle.write("@$VER: Index.guide 1.0 (%d.%d.%d)\n" % (today.day, today.month, today.year))
filehandle.write("@(C) Copyright (C) %d, The AROS Development Team. All rights reserved.\n\n" % (today.year))

View File

@ -34,15 +34,15 @@ $(GENDIR)/$(CURDIR)/aboutaros.o: $(GENERATED)
$(TOP)/$(CURDIR)/authors.h : $(SRCDIR)/$(CURDIR)/db/credits $(SRCDIR)/$(CURDIR)/scripts/authors2header.py
@$(ECHO) Generating $@
@$(PYTHON) $(SRCDIR)/$(CURDIR)/scripts/authors2header.py <$< >$@
@$(PYTHON) $(SRCDIR)/$(CURDIR)/scripts/authors2header.py $< >$@
$(TOP)/$(CURDIR)/sponsors.h : $(SRCDIR)/$(CURDIR)/db/sponsors $(SRCDIR)/$(CURDIR)/scripts/sponsors2header.py
@$(ECHO) Generating $@
@$(PYTHON) $(SRCDIR)/$(CURDIR)/scripts/sponsors2header.py <$< >$@
@$(PYTHON) $(SRCDIR)/$(CURDIR)/scripts/sponsors2header.py $< >$@
$(TOP)/$(CURDIR)/acknowledgements.h : $(SRCDIR)/ACKNOWLEDGEMENTS $(SRCDIR)/$(CURDIR)/scripts/acknowledgements2header.py
@$(ECHO) Generating $@
@$(PYTHON) $(SRCDIR)/$(CURDIR)/scripts/acknowledgements2header.py <$< >$@
@$(PYTHON) $(SRCDIR)/$(CURDIR)/scripts/acknowledgements2header.py $< >$@
#MM
aboutaros-clean :

View File

@ -1,9 +1,9 @@
#!/bin/env python
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-
import sys
print '''#ifndef _ACKNOWLEDGEMENTS_H_
print('''#ifndef _ACKNOWLEDGEMENTS_H_
#define _ACKNOWLEDGEMENTS_H_
/*
@ -13,16 +13,19 @@ print '''#ifndef _ACKNOWLEDGEMENTS_H_
const char * const ACKNOWLEDGEMENTS[] =
{
'''
''')
count = 0
for line in sys.stdin:
print ' "%s",' % line.strip()
file = open(sys.argv[1], "r", encoding="iso-8859-15")
for line in file:
print(' "%s",' % line.strip())
count += 1
print '''};
print('''};
#define ACKNOWLEDGEMENTS_SIZE (%d)
#endif /* _ACKNOWLEDGEMENTS_H_ */
''' % count
''' % count)
file.close()

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-
# Copyright © 2002-2008, The AROS Development Team. All rights reserved.
# $Id$
@ -36,22 +37,23 @@ def parse(file):
line = line.strip()
if ':' in line:
if len(names) > 0:
credits.append([area, names])
if len(names) > 0:
credits.append([area, names])
area = line[:-1]
area = line[:-1]
names = []
names = []
elif line != '':
names.append(line)
names.append(line)
if len(names) > 0:
credits.append([area, names])
return credits
credits = parse(sys.stdin)
file = open(sys.argv[1], "r", encoding="iso-8859-15")
credits = parse(file)
sys.stdout.write('''#ifndef _AUTHORS_H_
#define _AUTHORS_H_
@ -98,9 +100,11 @@ for area in credits:
for name in area[1]:
sys.stdout.write(',\n NAME("%s")' % name.replace('"', '\\"'))
print '\n ),'
print('\n ),')
print ''' TAG_DONE
print(''' TAG_DONE
);
#endif /* _AUTHORS_H_ */'''
#endif /* _AUTHORS_H_ */''')
file.close()

View File

@ -1,4 +1,4 @@
#!/bin/env python
#!/usr/bin/env python3
# -*- coding: iso-8859-15 -*-
import sys
@ -20,11 +20,14 @@ struct TagItem *SPONSORS = TAGLIST
(
SID_NONE''')
for line in sys.stdin:
file = open(sys.argv[1], "r", encoding="iso-8859-15")
for line in file:
sys.stdout.write(',\n NAME("%s")' % line.strip())
print '''\n ),
print('''\n ),
TAG_DONE
);
#endif /* _SPONSORS_H_ */'''
#endif /* _SPONSORS_H_ */''')
file.close()