[Scons-dev] scons-python3 bootstrap.py broken

Neal Becker ndbecker2 at gmail.com
Tue Apr 12 11:00:52 EDT 2016


Neal Becker wrote:

> Attempting to run via bootstrap.py:
> 
>  python3 ~/scons-py3/bootstrap.py
> /home/nbecker/anaconda3/envs/py35/bin/python3 /home/nbecker/scons-
> py3/bootstrap/src/script/scons.py
> Import failed. Unable to find SCons files in:
>   /home/nbecker/scons-py3/bootstrap/src/engine
>   /home/nbecker/scons-py3/bootstrap/src/script/../engine
>   /home/nbecker/scons-py3/bootstrap/src/script/scons-local-__VERSION__
>   /home/nbecker/scons-py3/bootstrap/src/script/scons-local
>   /home/nbecker/anaconda3/envs/py35/lib/scons-__VERSION__
>   /home/nbecker/anaconda3/envs/py35/lib/python3.5/site-packages/scons-
> __VERSION__
>   /home/nbecker/anaconda3/envs/py35/lib/scons-__VERSION__
>   /home/nbecker/anaconda3/envs/py35/lib/scons
>   /home/nbecker/anaconda3/envs/py35/lib/python3.5/site-packages/scons
>   /home/nbecker/anaconda3/envs/py35/lib/scons
> Traceback (most recent call last):
>   File "/home/nbecker/scons-py3/bootstrap/src/script/scons.py", line 190,
>   in
> <module>
>     import SCons.Script
>   File "/home/nbecker/scons-
> py3/bootstrap/src/engine/SCons/Script/__init__.py", line 88, in <module>
>     from . import Main
>   File
>   "/home/nbecker/scons-py3/bootstrap/src/engine/SCons/Script/Main.py",
> line 370
>     except OSError, e:
>                   ^
> SyntaxError: invalid syntax
> 
> Something is rewriting Main.py.  If I manually fix it, then re-run
> bootstrap.py Main.py gets re-written with syntax errors.

OK, I found it.  Needed to fix src/engine/SCons/Script/Main.py, and run 2to3 
on it:

hg diff 
diff -r 0741afd71a7a src/engine/SCons/Script/Main.py
--- a/src/engine/SCons/Script/Main.py	Sat Aug 23 16:28:44 2014 -0400
+++ b/src/engine/SCons/Script/Main.py	Tue Apr 12 10:59:37 2016 -0400
@@ -13,6 +13,7 @@
 # Would affect exec()'d site_init.py:
 ## from __future__ import print_function
 from SCons.compat.six import print_
+import collections
 
 unsupported_python_version = (2, 3, 0)
 deprecated_python_version = (2, 7, 0)
@@ -113,7 +114,7 @@
         self.interval = interval
         self.overwrite = overwrite
 
-        if callable(obj):
+        if isinstance(obj, collections.Callable):
             self.func = obj
         elif SCons.Util.is_List(obj):
             self.func = self.spinner
@@ -233,7 +234,7 @@
                     self.exception_set()
                 self.do_failed()
             else:
-                print("scons: Nothing to be done for `%s'." % t)
+                print(("scons: Nothing to be done for `%s'." % t))
                 SCons.Taskmaster.OutOfDateTask.executed(self)
         else:
             SCons.Taskmaster.OutOfDateTask.executed(self)
@@ -367,13 +368,13 @@
         for t in self._get_files_to_clean():
             try:
                 removed = t.remove()
-            except OSError, e:
+            except OSError as e:
                 # An OSError may indicate something like a permissions
                 # issue, an IOError would indicate something like
                 # the file not existing.  In either case, print a
                 # message and keep going to try to remove as many
                 # targets aa possible.
-                print(("scons: Could not remove '%s':" % str(t), 
e.strerror)
+                print(("scons: Could not remove '%s':" % str(t), 
e.strerror))
             else:
                 if removed:
                     display("Removed " + str(t))
@@ -734,7 +735,7 @@
                     modname = os.path.basename(pathname)[:-len(sfx)]
                     site_m = {"__file__": pathname, "__name__": modname, 
"__doc__": None}
                     re_special = re.compile("__[^_]+__")
-                    for k in m.__dict__.keys():
+                    for k in list(m.__dict__.keys()):
                         if not re_special.match(k):
                             site_m[k] = m.__dict__[k]
 
@@ -1421,10 +1422,10 @@
             else:
                 ct = last_command_end - first_command_start
         scons_time = total_time - sconscript_time - ct
-        print("Total build time: %f seconds"%total_time)
-        print("Total SConscript file execution time: %f 
seconds"%sconscript_time)
-        print("Total SCons execution time: %f seconds"%scons_time)
-        print("Total command execution time: %f seconds"%ct)
+        print(("Total build time: %f seconds"%total_time))
+        print(("Total SConscript file execution time: %f 
seconds"%sconscript_time))
+        print(("Total SCons execution time: %f seconds"%scons_time))
+        print(("Total command execution time: %f seconds"%ct))
 
     sys.exit(exit_status)
 



More information about the Scons-dev mailing list