Repository: spack/spack

Issue:
ncurses fails to build on Cray Cori at NERSC 
Problem:  On NERSC CRAY Cori using PrgEnv-gnu with no special packages.yaml or modules involved.
When trying to do this install:  **spack install cbtf-krell +runtime os=CNL**

**I get this failure:**
```
==> Installing ncurses
==> Error: SyntaxError: invalid syntax (<string>, line 425)
SyntaxError: SyntaxError: invalid syntax (<string>, line 425)
/global/u2/j/jgalaro/spack/lib/spack/spack/build_environment.py:684, in child_process:
     27    
     28                # build up some context from the offending package so we can
     29                # show that, too.
  >> 30                package_context = get_package_context(tb)
     31    
     32                build_log = None
     33                if hasattr(pkg, 'log_path'):

I have patches to cbtf-krell, but they don't effect this issue.

**This is the full output:**

==> Installing libsigsegv
==> Using cached archive: /global/u2/j/jgalaro/spack/var/spack/cache/libsigsegv/libsigsegv-2.11.tar.gz
==> Staging archive: /global/u2/j/jgalaro/spack/var/spack/stage/libsigsegv-2.11-uvqwq5ce34balpvfluh7uvfspnbln7op/libsigsegv-2.11.tar.gz
==> Created stage in /global/u2/j/jgalaro/spack/var/spack/stage/libsigsegv-2.11-uvqwq5ce34balpvfluh7uvfspnbln7op
==> No patches needed for libsigsegv
==> Building libsigsegv [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed libsigsegv
  Fetch: 0.00s.  Build: 9.99s.  Total: 9.99s.
[+] /global/u2/j/jgalaro/spack/opt/spack/cray-CNL-haswell/gcc-7.2.0/libsigsegv-2.11-uvqwq5ce34balpvfluh7uvfspnbln7op
==> Installing m4
==> Using cached archive: /global/u2/j/jgalaro/spack/var/spack/cache/m4/m4-1.4.18.tar.gz
==> Staging archive: /global/u2/j/jgalaro/spack/var/spack/stage/m4-1.4.18-c5kdyscyrgyzgfsp26ktuyxxz6u5u2jf/m4-1.4.18.tar.gz
==> Created stage in /global/u2/j/jgalaro/spack/var/spack/stage/m4-1.4.18-c5kdyscyrgyzgfsp26ktuyxxz6u5u2jf
==> Applied patch gnulib-pgi.patch
==> Building m4 [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed m4
  Fetch: 0.01s.  Build: 44.15s.  Total: 44.15s.
[+] /global/u2/j/jgalaro/spack/opt/spack/cray-CNL-haswell/gcc-7.2.0/m4-1.4.18-c5kdyscyrgyzgfsp26ktuyxxz6u5u2jf
==> Installing bison
==> Using cached archive: /global/u2/j/jgalaro/spack/var/spack/cache/bison/bison-3.0.4.tar.gz
==> Staging archive: /global/u2/j/jgalaro/spack/var/spack/stage/bison-3.0.4-3x3txvairczgd3q33uksf3b5qbm6kiic/bison-3.0.4.tar.gz
==> Created stage in /global/u2/j/jgalaro/spack/var/spack/stage/bison-3.0.4-3x3txvairczgd3q33uksf3b5qbm6kiic
==> Applied patch pgi.patch
==> Building bison [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed bison
  Fetch: 0.01s.  Build: 1m 2.01s.  Total: 1m 2.02s.
[+] /global/u2/j/jgalaro/spack/opt/spack/cray-CNL-haswell/gcc-7.2.0/bison-3.0.4-3x3txvairczgd3q33uksf3b5qbm6kiic
==> Installing bzip2
==> Using cached archive: /global/u2/j/jgalaro/spack/var/spack/cache/bzip2/bzip2-1.0.6.tar.gz
==> Staging archive: /global/u2/j/jgalaro/spack/var/spack/stage/bzip2-1.0.6-4yersr6oakvbug3tid6d2q4xz6jjclwr/bzip2-1.0.6.tar.gz
==> Created stage in /global/u2/j/jgalaro/spack/var/spack/stage/bzip2-1.0.6-4yersr6oakvbug3tid6d2q4xz6jjclwr
==> Ran patch() for bzip2
==> Building bzip2 [Package]
==> Executing phase: 'install'
==> Successfully installed bzip2
  Fetch: 0.00s.  Build: 3.15s.  Total: 3.15s.
[+] /global/u2/j/jgalaro/spack/opt/spack/cray-CNL-haswell/gcc-7.2.0/bzip2-1.0.6-4yersr6oakvbug3tid6d2q4xz6jjclwr
==> Installing pkgconf
==> Using cached archive: /global/u2/j/jgalaro/spack/var/spack/cache/pkgconf/pkgconf-1.4.0.tar.xz
==> Staging archive: /global/u2/j/jgalaro/spack/var/spack/stage/pkgconf-1.4.0-yr3p25ycrld2ctyp2gpsnt4q7okbr74d/pkgconf-1.4.0.tar.xz
==> Created stage in /global/u2/j/jgalaro/spack/var/spack/stage/pkgconf-1.4.0-yr3p25ycrld2ctyp2gpsnt4q7okbr74d
==> No patches needed for pkgconf
==> Building pkgconf [AutotoolsPackage]
==> Executing phase: 'autoreconf'
==> Executing phase: 'configure'
==> Executing phase: 'build'
==> Executing phase: 'install'
==> Successfully installed pkgconf
  Fetch: 0.00s.  Build: 10.08s.  Total: 10.08s.
[+] /global/u2/j/jgalaro/spack/opt/spack/cray-CNL-haswell/gcc-7.2.0/pkgconf-1.4.0-yr3p25ycrld2ctyp2gpsnt4q7okbr74d
==> Installing ncurses
==> Error: SyntaxError: invalid syntax (<string>, line 425)
SyntaxError: SyntaxError: invalid syntax (<string>, line 425)

/global/u2/j/jgalaro/spack/lib/spack/spack/build_environment.py:684, in child_process:
     27    
     28                # build up some context from the offending package so we can
     29                # show that, too.
  >> 30                package_context = get_package_context(tb)
     31    
     32                build_log = None
     33                if hasattr(pkg, 'log_path'):
```










Discussion:
Is this with spack -d install ... ? If not mind pasting the output of that?

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/pkgconf/package.py b/var/spack/repos/builtin/packages/pkgconf/package.py
--- a/var/spack/repos/builtin/packages/pkgconf/package.py
+++ b/var/spack/repos/builtin/packages/pkgconf/package.py
@@ -40,6 +40,19 @@ class Pkgconf(AutotoolsPackage):
 
     provides('pkgconfig')
 
+    def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
+        """spack built pkg-config on cray's requires adding /usr/local/
+        and /usr/lib64/  to PKG_CONFIG_PATH in order to access cray '.pc'
+        files.
+        Adds the ACLOCAL path for autotools."""
+        spack_env.append_path('ACLOCAL_PATH',
+                              join_path(self.prefix.share, 'aclocal'))
+        if 'platform=cray' in self.spec:
+            spack_env.append_path('PKG_CONFIG_PATH',
+                                  '/usr/lib64/pkgconfig')
+            spack_env.append_path('PKG_CONFIG_PATH',
+                                  '/usr/local/lib64/pkgconfig')
+
     @run_after('install')
     def link_pkg_config(self):
         symlink('pkgconf', '{0}/pkg-config'.format(self.prefix.bin))


Test patch: