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

Ivan Van Laningham ivanlan9 at gmail.com
Tue Apr 12 11:38:19 EDT 2016


I don't know anything about futurize, but yes, 2to3 assumes all prints must
be turned into functions and will always add parens, regardless.  Which is
why I stopped using it.

Metta,
Ivan

On Tue, Apr 12, 2016 at 9:34 AM, Tim Jenness <tjenness at lsst.org> wrote:

>
> On Apr 12, 2016, at 08:00 , Neal Becker <ndbecker2 at gmail.com> wrote:
>
> 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:
>
>
> I don’t think 2to3 did the right thing there in some cases. It doubled up
> parentheses on all the print statements and did not fix the for loop.
>
> This: for k in list(m.__dict__.keys()):
>
> Needs to be: “for k in m.__dict__:” (ie no need to make it a list and no
> need for the keys() as dicts already do that in for loops.
> Does 2to3 assume that all prints are not already print functions? I’m
> pretty sure futurize handles this fine (because in most cases in my
> codebase where I use futurize we are already importing __future__).
>
>> Tim Jenness
>
> 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 <http://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)
>
>
> _______________________________________________
> Scons-dev mailing list
> Scons-dev at scons.org
> https://pairlist2.pair.net/mailman/listinfo/scons-dev
>
>
>
> _______________________________________________
> Scons-dev mailing list
> Scons-dev at scons.org
> https://pairlist2.pair.net/mailman/listinfo/scons-dev
>
>


-- 
Ivan Van Laningham
God N Locomotive Works
http://www.pauahtun.org/
http://www.python.org/workshops/1998-11/proceedings/papers/laningham/laningham.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20160412/50be4ccb/attachment-0001.html>


More information about the Scons-dev mailing list