From: Hoa Nguyen Date: Thu, 15 Oct 2020 21:08:41 +0000 (-0700) Subject: scons: Raise an exception when scons is run a Python2 environment X-Git-Tag: develop-gem5-snapshot~600 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=257834d23f8b061e3687ab77ca785d6c556e8277;p=gem5.git scons: Raise an exception when scons is run a Python2 environment As gem5 has started to use Python2 incompatible features, compiling gem5 in a Python2 environment results in an error. This commit addresses this issue by raising an Exception when scons is run in a Python2 environment, and adding a few pointers on how to install Python3 and on how to use scons in a Python3 environment. The solution works in a system where both Python2 and Python3 are installed. JIRA: https://gem5.atlassian.net/browse/GEM5-797 Change-Id: I98d4a39f586f39d9253ab2517b77e86c5ed19466 Signed-off-by: Hoa Nguyen Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36157 Reviewed-by: Jason Lowe-Power Reviewed-by: Gabe Black Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/site_scons/site_init.py b/site_scons/site_init.py index 28a9d0c13..2f7cbf1be 100644 --- a/site_scons/site_init.py +++ b/site_scons/site_init.py @@ -51,14 +51,37 @@ For more details, see: """) raise -# pybind11 requires python 2.7 + +# Check for the python version. Python 2 is no longer supported. try: - EnsurePythonVersion(2, 7) + EnsurePythonVersion(3, 0) except SystemExit as e: - print (""" -You can use a non-default installation of the Python interpreter by -rearranging your PATH so that scons finds the non-default 'python' and -'python-config' first. + print("""\033[93m +Python 3 is now required. + +The following are steps to compile gem5 in Python 3 environment, + +*Step 1*: ensure Python 3 is installed. On Ubuntu like systems, you can try \ +this command: + + sudo apt-get install python3 python3-six python-is-python3 python3-pydot + +To run Python 3 from a container, you can try the Docker files in \ +util/dockerfiles folder. + +*Step 2*: ensure that scons is run in the Python 3 environment. If scons \ +isn't run automatically with Python 3, you can force it by replacing `scons` \ +by the following phrase, + + /usr/bin/env python3 $(which scons) + +For example, the following command will let scons compile gem5/X86 in the \ +Python 3 environment, + + /usr/bin/env python3 $(which scons) build/X86/gem5.opt + +(Optional) For convenience reasons, you can set up an alias for the Python3 \ +scons phrase in your environment. \033[0m """) raise