Repository: spack/spack

Issue:
espresso : no module or dotkit file is created
Originally posted on the mailing list. Installing espresso everything seems to go fine:

```
$ spack install -j 4 espresso + mpi ^ openblas
==> Installing espresso
==> Installing netlib-scalapack
==> mpich is already installed in /home/culpo/github/spack/opt/spack/x86_E5v2_IntelIB/gcc-4.4.7/mpich-3.2-nrn7n3mmfanakidvf2wincyv3ufml5k6.
==> openblas is already installed in /home/culpo/github/spack/opt/spack/x86_E5v2_IntelIB/gcc-4.4.7/openblas-0.2.15-mpo65vvesylmxza7v5w5ahghvcbchnxd.
==> Already downloaded /home/culpo/github/spack/var/spack/stage/netlib-scalapack-2.0.2-rhdi75kxexltc7ejtes5oopne4uu7lpc/netlib-scalapack-2.0.2.tgz.
==> Already staged netlib-scalapack-2.0.2-rhdi75kxexltc7ejtes5oopne4uu7lpc in /home/culpo/github/spack/var/spack/stage/netlib-scalapack-2.0.2-rhdi75kxexltc7ejtes5oopne4uu7lpc.
==> No patches needed for netlib-scalapack.
==> Building netlib-scalapack.
==> Successfully installed netlib-scalapack.
  Fetch: 0.01s.  Build: 1m 48.54s.  Total: 1m 48.55s.
[+] /home/culpo/github/spack/opt/spack/x86_E5v2_IntelIB/gcc-4.4.7/netlib-scalapack-2.0.2-rhdi75kxexltc7ejtes5oopne4uu7lpc
==> mpich is already installed in /home/culpo/github/spack/opt/spack/x86_E5v2_IntelIB/gcc-4.4.7/mpich-3.2-nrn7n3mmfanakidvf2wincyv3ufml5k6.
==> Installing fftw
==> mpich is already installed in /home/culpo/github/spack/opt/spack/x86_E5v2_IntelIB/gcc-4.4.7/mpich-3.2-nrn7n3mmfanakidvf2wincyv3ufml5k6.
==> Trying to fetch from file:///ssoft/E5v3/downloads/fftw/fftw-3.3.4.tar.gz
curl: (37) Couldn't open file /ssoft/E5v3/downloads/fftw/fftw-3.3.4.tar.gz
==> Fetching from file:///ssoft/E5v3/downloads/fftw/fftw-3.3.4.tar.gz failed.
==> Trying to fetch from file:///home/culpo/mirror/download/fftw/fftw-3.3.4.tar.gz
######################################################################## 100,0%
==> Staging archive: /home/culpo/github/spack/var/spack/stage/fftw-3.3.4-bljkqbojgol5dequk3b6kbcyhzyeskkm/fftw-3.3.4.tar.gz
==> Created stage in /home/culpo/github/spack/var/spack/stage/fftw-3.3.4-bljkqbojgol5dequk3b6kbcyhzyeskkm.
==> No patches needed for fftw.
==> Building fftw.
==> Successfully installed fftw.
  Fetch: 0.09s.  Build: 1m 44.79s.  Total: 1m 44.88s.
[+] /home/culpo/github/spack/opt/spack/x86_E5v2_IntelIB/gcc-4.4.7/fftw-3.3.4-bljkqbojgol5dequk3b6kbcyhzyeskkm
==> openblas is already installed in /home/culpo/github/spack/opt/spack/x86_E5v2_IntelIB/gcc-4.4.7/openblas-0.2.15-mpo65vvesylmxza7v5w5ahghvcbchnxd.
==> Trying to fetch from file:///ssoft/E5v3/downloads/espresso/espresso-5.3.0.tar.gz
curl: (37) Couldn't open file /ssoft/E5v3/downloads/espresso/espresso-5.3.0.tar.gz
==> Fetching from file:///ssoft/E5v3/downloads/espresso/espresso-5.3.0.tar.gz failed.
==> Trying to fetch from file:///home/culpo/mirror/download/espresso/espresso-5.3.0.tar.gz
######################################################################## 100,0%
==> Staging archive: /home/culpo/github/spack/var/spack/stage/espresso-5.3.0-h7wtev4x2iudd3kfvxdx6bj4baqxauvj/espresso-5.3.0.tar.gz
==> Created stage in /home/culpo/github/spack/var/spack/stage/espresso-5.3.0-h7wtev4x2iudd3kfvxdx6bj4baqxauvj.
==> No patches needed for espresso.
==> Building espresso.
==> Successfully installed espresso.
  Fetch: 0.19s.  Build: 2m 21.25s.  Total: 2m 21.44s.
[+] /home/culpo/github/spack/opt/spack/x86_E5v2_IntelIB/gcc-4.4.7/espresso-5.3.0-h7wtev4x2iudd3kfvxdx6bj4baqxauvj
```

except that no module or dotkit file gets created:

```
$ ls share/spack/{dotkit,modules}/x86_E5v2_IntelIB/ | grep "^e"
elpa-2015.11.001-gcc-4.9.3-2b3uaudbffhggtjde6mbvim54cl7shkv.dk
elpa-2015.11.001-gcc-4.9.3-2b3uaudbffhggtjde6mbvim54cl7shkv
```



Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/espresso/package.py b/var/spack/repos/builtin/packages/espresso/package.py
--- a/var/spack/repos/builtin/packages/espresso/package.py
+++ b/var/spack/repos/builtin/packages/espresso/package.py
@@ -24,7 +24,7 @@ class Espresso(Package):
     depends_on('fftw~mpi', when='~mpi')
     depends_on('fftw+mpi', when='+mpi')
     depends_on('scalapack', when='+scalapack+mpi')  # TODO : + mpi needed to avoid false dependencies installation
-    
+
     def check_variants(self, spec):
         error = 'you cannot ask for \'+{variant}\' when \'+mpi\' is not active'
         if '+scalapack' in spec and '~mpi' in spec:
@@ -32,14 +32,11 @@ def check_variants(self, spec):
         if '+elpa' in spec and ('~mpi' in spec or '~scalapack' in spec):
             raise RuntimeError(error.format(variant='elpa'))
 
-    def setup_environment(self, spack_env, run_env):
-        # Espresso copies every executable in prefix without creating sub-folders
-        run_env.prepend_path('PATH', self.prefix)
-
     def install(self, spec, prefix):
+        from glob import glob
         self.check_variants(spec)
 
-        options = ['-prefix=%s' % prefix]
+        options = ['-prefix=%s' % prefix.bin]
 
         if '+mpi' in spec:
             options.append('--enable-parallel')
@@ -65,5 +62,11 @@ def install(self, spec, prefix):
 
         configure(*options)
         make('all')
-        make('install')        
+
+        if spec.architecture.startswith('darwin'):
+            mkdirp(prefix.bin)
+            for filename in glob("bin/*.x"):
+                install(filename, prefix.bin)
+        else:
+            make('install')
 


Test patch: