Hoa Nguyen has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/36157 )

Change subject: scons: Raise an exception when scons is run a Python2 environment
......................................................................

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 adds a few pointers on how to
install Python3 and 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 <hoangu...@ucdavis.edu>
---
M SConstruct
1 file changed, 30 insertions(+), 0 deletions(-)



diff --git a/SConstruct b/SConstruct
index 8e7ec34..07d419a 100755
--- a/SConstruct
+++ b/SConstruct
@@ -133,6 +133,36 @@
 if GetOption('no_lto') and GetOption('force_lto'):
     error('--no-lto and --force-lto are mutually exclusive')

+# Detect the existance of Python2
+# For the case where both Python2 and Python3 are installed and the
+# case where only Python2 is installed, those cases are not supported.
+# So, if Python2 is installed, the scons script should throw an error.
+if sys.version_info[0] == 2:
+    message = """\033[93m
+scons is being run in a Python2 environment, which is not supported.
+gem5 has started to use Python2 incompatible features.
+
+The following are steps to compile gem5 in a Python3 environment:
+
+- If Python3 is not installed, please do so.
+  For example, if you are using Debian/Ubuntu, the following command \
+installs Python3 for the system.
+
+ `sudo apt-get install python3 python3-six python-is-python3 python3-pydot`
+
+ If you prefer to use a Python3 container, please checkout the Dockerfiles \
+in util/dockerfiles/.
+
+- Add the following line to ~/.bashrc,
+
+    `alias scons3="/usr/bin/env python3 $(which scons)"`
+
+Restart the shell and use `scons3` instead of `scons` to compile gem5.\033[0m
+"""
+    print(message)
+    raise Exception("Unsupported Python version")
+
+
 ########################################################################
 #
 # Set up the main build environment.

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/36157
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I98d4a39f586f39d9253ab2517b77e86c5ed19466
Gerrit-Change-Number: 36157
Gerrit-PatchSet: 1
Gerrit-Owner: Hoa Nguyen <hoangu...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to