scons: Import print_function from future
authorSiddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
Wed, 14 Feb 2018 18:38:38 +0000 (00:08 +0530)
committerSiddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
Tue, 6 Mar 2018 19:45:34 +0000 (19:45 +0000)
Scons on Fedora 27 imports print_function from the future[1] as a
result of which a gem5 build errors out with a syntax error.  Make all
the scons scripts that use the print statement import the print_function
from future and replace the statements with print function calls.

[1] https://github.com/SCons/scons/commit/34cf3bdb1743de9a5534bfd25998d0a01297f004

Change-Id: I67b7ef978fd7567f94d3cd9a904f8a0c1af07ffb
Signed-off-by: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
Reviewed-on: https://gem5-review.googlesource.com/8321
Reviewed-by: Gabe Black <gabeblack@google.com>
Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
Maintainer: Gabe Black <gabeblack@google.com>

site_scons/site_init.py
site_scons/site_tools/git.py
site_scons/site_tools/mercurial.py

index 6d9d24d3049269c1be83146343b98cd07f6a565e..351f49bc05930d247c7abbad0f45ca8111b5cba6 100644 (file)
@@ -38,6 +38,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+from __future__ import print_function
 from gem5_python_paths import extra_python_paths
 
 # Check for recent-enough Python and SCons versions.
@@ -49,24 +50,24 @@ try:
     EnsureSConsVersion(0, 98)
     EnsureSConsVersion(0, 98, 1)
 except SystemExit, e:
-    print """
+    print("""
 For more details, see:
     http://gem5.org/Dependencies
-"""
+""")
     raise
 
 # pybind11 requires python 2.7
 try:
     EnsurePythonVersion(2, 7)
 except SystemExit, e:
-    print """
+    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.
 
 For more details, see:
     http://gem5.org/wiki/index.php/Using_a_non-default_Python_installation
-"""
+""")
     raise
 
 sys.path[1:1] = extra_python_paths
index d9f8ab89f85bba6801bdc637b45c706d5c143e4c..1b40f28ef4c492b1356bcaad626a17a4b6d491a8 100644 (file)
@@ -38,6 +38,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+from __future__ import print_function
 import os
 
 import gem5_scons.util
@@ -54,7 +55,7 @@ def install_style_hooks(env):
         gitdir = env.Dir(readCommand(
             ["git", "rev-parse", "--git-dir"]).strip("\n"))
     except Exception, e:
-        print "Warning: Failed to find git repo directory: %s" % e
+        print("Warning: Failed to find git repo directory: %s" % e)
         return
 
     git_hooks = gitdir.Dir("hooks")
@@ -65,11 +66,12 @@ def install_style_hooks(env):
     def hook_install(hook_name, script):
         hook = git_hooks.File(hook_name)
         if hook.exists():
-            print "Warning: Can't install %s, hook already exists." % hook_name
+            print("Warning: Can't install %s, hook already exists." %
+                    hook_name)
             return
 
         if hook.islink():
-            print "Warning: Removing broken symlink for hook %s." % hook_name
+            print("Warning: Removing broken symlink for hook %s." % hook_name)
             os.unlink(hook.get_abspath())
 
         if not git_hooks.exists():
@@ -91,17 +93,17 @@ def install_style_hooks(env):
         try:
             os.symlink(script_path, hook.get_abspath())
         except:
-            print "Error updating git %s hook" % hook_name
+            print("Error updating git %s hook" % hook_name)
             raise
 
     if hook_exists("pre-commit") and hook_exists("commit-msg"):
         return
 
-    print git_style_message,
+    print(git_style_message, end=' ')
     try:
         raw_input()
     except:
-        print "Input exception, exiting scons.\n"
+        print("Input exception, exiting scons.\n")
         sys.exit(1)
 
     git_style_script = env.root.Dir("util").File("git-pre-commit.py")
index a38449f4392f3ba3461b9f8444deca1b5ab9e0ad..3c91b38349574c4e006445e6c7a0e3849365c035 100644 (file)
@@ -38,6 +38,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+from __future__ import print_function
 import re
 import sys
 
@@ -90,16 +91,16 @@ def install_style_hooks(env):
         style_hook = all(style_hooks)
         style_extension = ui.config('extensions', 'style', None)
     except ImportError:
-        print mercurial_lib_not_found
+        print(mercurial_lib_not_found)
 
     if "python:style.check_style" in style_hooks:
         # Try to upgrade the style hooks
-        print mercurial_style_upgrade_message
+        print(mercurial_style_upgrade_message)
         # continue unless user does ctrl-c/ctrl-d etc.
         try:
             raw_input()
         except:
-            print "Input exception, exiting scons.\n"
+            print("Input exception, exiting scons.\n")
             sys.exit(1)
         shutil.copyfile(hgrc.abspath, hgrc_old.abspath)
         re_style_hook = re.compile(r"^([^=#]+)\.style\s*=\s*([^#\s]+).*")
@@ -111,10 +112,10 @@ def install_style_hooks(env):
             if m_hook:
                 hook, check = m_hook.groups()
                 if check != "python:style.check_style":
-                    print "Warning: %s.style is using a non-default " \
-                        "checker: %s" % (hook, check)
+                    print("Warning: %s.style is using a non-default " \
+                        "checker: %s" % (hook, check))
                 if hook not in ("pretxncommit", "pre-qrefresh"):
-                    print "Warning: Updating unknown style hook: %s" % hook
+                    print("Warning: Updating unknown style hook: %s" % hook)
 
                 l = "%s.style = python:hgstyle.check_style\n" % hook
             elif m_ext and m_ext.group(1) == style_extension:
@@ -122,20 +123,20 @@ def install_style_hooks(env):
 
             new.write(l)
     elif not style_hook:
-        print mercurial_style_message,
+        print(mercurial_style_message, end=' ')
         # continue unless user does ctrl-c/ctrl-d etc.
         try:
             raw_input()
         except:
-            print "Input exception, exiting scons.\n"
+            print("Input exception, exiting scons.\n")
             sys.exit(1)
         hgrc_path = '%s/.hg/hgrc' % env.root.abspath
-        print "Adding style hook to", hgrc_path, "\n"
+        print("Adding style hook to", hgrc_path, "\n")
         try:
             with open(hgrc_path, 'a') as f:
                 f.write(mercurial_style_hook_template % env.root.abspath)
         except:
-            print "Error updating", hgrc_path
+            print("Error updating", hgrc_path)
             sys.exit(1)
 
 def generate(env):