make, scripts: Flip some more switches from pathon 2 to 3 (untested!)

This commit flips some more switches from Python 2 to Python 3 in makefiles and
Python code. Build runs through, but it's still likely to break things.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2019-06-02 12:28:13 +00:00
commit 13fa28e23f
6 changed files with 27 additions and 17 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/python2 -u
#!/usr/bin/python3 -u
from __future__ import print_function
import os
@ -88,7 +88,7 @@ class Build(object):
prereq_type, scope = 2, add_self=False, names_only=True)
debug('prerequisites = ' + ' '.join(r))
else: # legacy from build.py
projects_py="/usr/bin/python2 " + my_dir + "/projects.py --prefix " + projs_root + " " + os.getenv('PROJECTS_PY_EXTRA_ARGS', "")
projects_py = sys.executable + " " + my_dir + "/projects.py --prefix " + projs_root + " " + os.getenv('PROJECTS_PY_EXTRA_ARGS', "")
cmd = projects_py + " prereq " + prereq_type + " " + cur
debug('running', cmd)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
@ -97,7 +97,8 @@ class Build(object):
raise Exception("failed to get " + prereq_type + " prerequisites for " + cur + ": " + cmd)
r = set()
pattern = re.compile(r'.*') # might be useful at a later point, currently pointless
for line in iter(p.stdout.readline,''):
for line in iter(p.stdout.readline, b''):
line = line.decode(sys.stdout.encoding)
debug(cmd + ' returned: ', line)
if not pattern.match(line):
continue
@ -166,7 +167,8 @@ class Build(object):
os.chdir(path)
p = subprocess.Popen(make_cmd, shell=False, stdout=subprocess.PIPE, stderr=None, close_fds=True)
for line in iter(p.stdout.readline, ''):
for line in iter(p.stdout.readline, b''):
line = line.decode(sys.stdout.encoding)
sys.stdout.write('| ' + line) # avoid extra newlines from print()
sys.stdout.flush()
p.wait()
@ -803,7 +805,7 @@ def read_dep_graph(modules, section, graph):
def flip_graph(graph):
r = {}
for m, deps in graph.iteritems():
for m, deps in graph.items():
for d in deps:
if not d in r:
r[d] = set()