scons: Fixes to improve python 3 support.

Some simple fixes to improve python 3 compatability in scons.

Change-Id: I89aba6ed9d73ee733307c57e033c636029d9cb7a
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23264
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2019-12-02 17:52:44 -08:00
parent 451ff4aa04
commit a39c8db854
4 changed files with 8 additions and 7 deletions

View File

@@ -206,7 +206,7 @@ def rfind(l, elt, offs = -1):
for i in range(len(l)+offs, 0, -1): for i in range(len(l)+offs, 0, -1):
if l[i] == elt: if l[i] == elt:
return i return i
raise ValueError, "element not found" raise ValueError("element not found")
# Take a list of paths (or SCons Nodes) and return a list with all # Take a list of paths (or SCons Nodes) and return a list with all
# paths made absolute and ~-expanded. Paths will be interpreted # paths made absolute and ~-expanded. Paths will be interpreted
@@ -717,7 +717,8 @@ if main['USE_PYTHON']:
# verify that this stuff works # verify that this stuff works
if not conf.CheckHeader('Python.h', '<>'): if not conf.CheckHeader('Python.h', '<>'):
error("Check failed for Python.h header in", py_includes, "\n" error("Check failed for Python.h header in",
' '.join(py_includes), "\n"
"Two possible reasons:\n" "Two possible reasons:\n"
"1. Python headers are not installed (You can install the " "1. Python headers are not installed (You can install the "
"package python-dev on Ubuntu and RedHat)\n" "package python-dev on Ubuntu and RedHat)\n"
@@ -941,7 +942,7 @@ class CpuModel(object):
# Add self to dict # Add self to dict
if name in CpuModel.dict: if name in CpuModel.dict:
raise AttributeError, "CpuModel '%s' already registered" % name raise AttributeError("CpuModel '%s' already registered" % name)
CpuModel.dict[name] = self CpuModel.dict[name] = self
Export('CpuModel') Export('CpuModel')

View File

@@ -49,7 +49,7 @@ try:
# 0.98, and the second will fail for 0.98.0 # 0.98, and the second will fail for 0.98.0
EnsureSConsVersion(0, 98) EnsureSConsVersion(0, 98)
EnsureSConsVersion(0, 98, 1) EnsureSConsVersion(0, 98, 1)
except SystemExit, e: except SystemExit as e:
print(""" print("""
For more details, see: For more details, see:
http://gem5.org/Dependencies http://gem5.org/Dependencies
@@ -59,7 +59,7 @@ For more details, see:
# pybind11 requires python 2.7 # pybind11 requires python 2.7
try: try:
EnsurePythonVersion(2, 7) EnsurePythonVersion(2, 7)
except SystemExit, e: except SystemExit as e:
print (""" print ("""
You can use a non-default installation of the Python interpreter by You can use a non-default installation of the Python interpreter by
rearranging your PATH so that scons finds the non-default 'python' and rearranging your PATH so that scons finds the non-default 'python' and

View File

@@ -61,7 +61,7 @@ def common_config(env):
"M5", # M5 configuration (e.g., path to kernels) "M5", # M5 configuration (e.g., path to kernels)
] ]
for key,val in sorted(os.environ.iteritems()): for key,val in sorted(os.environ.items()):
if key in use_vars or \ if key in use_vars or \
any([key.startswith(prefix) for prefix in use_prefixes]): any([key.startswith(prefix) for prefix in use_prefixes]):
env['ENV'][key] = val env['ENV'][key] = val

View File

@@ -54,7 +54,7 @@ def install_style_hooks(env):
try: try:
gitdir = env.Dir(readCommand( gitdir = env.Dir(readCommand(
["git", "rev-parse", "--git-dir"]).strip("\n")) ["git", "rev-parse", "--git-dir"]).strip("\n"))
except Exception, e: except Exception as e:
print("Warning: Failed to find git repo directory: %s" % e) print("Warning: Failed to find git repo directory: %s" % e)
return return