Repository: spack/spack

Issue:
Odd error w/ setuptools
My automated build crashed this afternoon.  I haven't looked into it too far yet and nothing is leaping to mind that I might have done to trigger it.

Wanted to see if other folks have seen something similar.

Here's a bit of of the spack console output:

```
==> Installing xauth
==> Installing libxmu
==> xextproto is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/xextproto-7.3.0-nfkynq6cleptouse343hivi4xwl5kak6
==> libx11 is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libx11-1.6.3-ihmkqyd6oz4ort65qx56znwvyfddm55o
==> util-macros is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/util-macros-1.19.1-z3eppjubpl4o2rz4v5gwaqjxpl753ck3
==> libxt is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libxt-1.1.5-jn2hctxcxdyg2wb4chvwb62buck6l5oj
==> libxext is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libxext-1.3.3-2nrss6okir5cg4224ucksyire37shtmr
==> pkg-config is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/pkg-config-0.29.1-ld3i7xv7jtacp7nt7k3aimjleiiuhpdg
Error processing line 1 of /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/python-2.7.13-74s7b4tu4uwvadfh2qrkgjv2tluagiaw/lib/python2.7/site-packages/easy-install.pth:

  Traceback (most recent call last):
    File "/home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/python-2.7.13-74s7b4tu4uwvadfh2qrkgjv2tluagiaw/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1
      import sys; sys.__plen = len(sys.path)./setuptools-34.2.0-py2.7.egg
                                             ^
  SyntaxError: invalid syntax

Remainder of file ignored
==> Fetching file:///home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack-mirror/mirror/libxmu/libxmu-1.1.2.tar.gz
==> Staging archive: /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/var/spack/stage/libxmu-1.1.2-5hax5nh5c5djicjxoltm6ldqdszh6g6u/libXmu-1.1.2.tar.gz
==> Created stage in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/var/spack/stage/libxmu-1.1.2-5hax5nh5c5djicjxoltm6ldqdszh6g6u
==> Ran patch() for libxmu
==> Building libxmu [AutotoolsPackage]
==> Successfully installed libxmu
  Fetch: 0.03s.  Build: 13.81s.  Total: 13.83s.
[+] /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libxmu-1.1.2-5hax5nh5c5djicjxoltm6ldqdszh6g6u
==> xproto is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/xproto-7.0.29-gpst7ep5db3dkdq5olsvs7df7yo3yjk2
==> libx11 is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libx11-1.6.3-ihmkqyd6oz4ort65qx56znwvyfddm55o
==> libxau is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libxau-1.0.8-stdwg7fygz6f6ro6xlktsc5hjymncwsv
==> util-macros is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/util-macros-1.19.1-z3eppjubpl4o2rz4v5gwaqjxpl753ck3
==> libxext is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/libxext-1.3.3-2nrss6okir5cg4224ucksyire37shtmr
==> pkg-config is already installed in /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/pkg-config-0.29.1-ld3i7xv7jtacp7nt7k3aimjleiiuhpdg
Error processing line 1 of /home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/python-2.7.13-74s7b4tu4uwvadfh2qrkgjv2tluagiaw/lib/python2.7/site-packages/easy-install.pth:

  Traceback (most recent call last):
    File "/home/bar/tmp/spack-cime-foo-working-dir/workspace/foo-daily-build/spack/opt/spack/linux-centos7-x86_64/gcc-5.4.0/python-2.7.13-74s7b4tu4uwvadfh2qrkgjv2tluagiaw/lib/python2.7/site.py", line 152, in addpackage
      exec line
    File "<string>", line 1
      import sys; sys.__plen = len(sys.path)./setuptools-34.2.0-py2.7.egg
                                             ^
  SyntaxError: invalid syntax

Remainder of file ignored
```


Discussion:
@lee218llnl 

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py
--- a/var/spack/repos/builtin/packages/python/package.py
+++ b/var/spack/repos/builtin/packages/python/package.py
@@ -470,10 +470,14 @@ def write_easy_install_pth(self, exts):
 
         else:
             with closing(open(main_pth, 'w')) as f:
-                f.write("import sys; sys.__plen = len(sys.path)")
+                f.write("import sys; sys.__plen = len(sys.path)\n")
                 for path in paths:
                     f.write("{0}\n".format(path))
-                f.write("import sys; new = sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p = getattr(sys, '__egginsert', 0); sys.path[p:p] = new; sys.__egginsert = p + len(new)")  # noqa: E501
+                f.write("import sys; new=sys.path[sys.__plen:]; "
+                        "del sys.path[sys.__plen:]; "
+                        "p=getattr(sys,'__egginsert',0); "
+                        "sys.path[p:p]=new; "
+                        "sys.__egginsert = p+len(new)\n")
 
     def activate(self, ext_pkg, **args):
         ignore = self.python_ignore(ext_pkg, args)


Test patch: