Repository: spack/spack

Issue:
Scalasca missing a depend otf2
Scalasca depends on otf2, but is missing a depend clause. On a machine that provides an older version of otf, the configure phase fails with error about otf not providing version 6 or 7. 

Simply fixed by hand issuing a spack load otf2, but that should happen automatically. 


Discussion:
If you want, you can open a PR that adds:
```python
depends_on('otf2')
```
to the `scalasca` package. If you know it needs `otf2` version 6+, you can encode this as well:
```python
depends_on('otf2@6:')
```
I digged a bit more into this and it seems more complicated than simply adding otf2 to the depends: 

Scalasca depends on Scorep; it should inherit cube, otf2 and other  things from the scorep, which itself depends on otf2. So in theory all should be loading, but it is not happening. 

I see in scorep that the otf2 appears as a build/link depend, but not a run depend. That may be the reason why otf2-config does not get in the path, but I'm not sure. 


@daboehme: can you take a look at this?
The Scalasca package shouldn't depend on Score-P (if anything, it's a run dependency, and even that is debatable). Spack doesn't "forward" dependencies, so while the Score-P package depends on otf2 and cube, the PATH for those isn't added to the Scalasca build. That's probably why otf2 wasn't found. 

Will fix by explicitly adding otf2 (and cube) dependencies.
> Spack doesn't "forward" dependencies, so while the Score-P package depends on otf2 and cube, the PATH for those isn't added to the Scalasca build.

For the record, Spack doesn't forward _build_ dependencies (it does forward _link_ dependencies though). `otf2` will still be added to the link line by the compiler wrappers, but unless it is explicitly marked as a _build_ dependency of `scalasca`, it won't be added to the `PATH`.
Ok, that make sense. However the configure will need the correct otf2-config in PATH. 
Yep, just add it as a direct dependency. The default deptype if you don't specify one is `build/link`, which sounds like what you want.
And don't worry, deptypes are fairly complicated and confuse everyone (myself included). See https://github.com/LLNL/spack/issues/3768 for a decent summary of what they imply.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/cube/package.py b/var/spack/repos/builtin/packages/cube/package.py
--- a/var/spack/repos/builtin/packages/cube/package.py
+++ b/var/spack/repos/builtin/packages/cube/package.py
@@ -25,7 +25,7 @@
 from spack import *
 
 
-class Cube(Package):
+class Cube(AutotoolsPackage):
     """Cube the profile viewer for Score-P and Scalasca profiles. It displays a
     multi-dimensional performance space consisting of the dimensions:
     - performance metric
@@ -36,26 +36,31 @@ class Cube(Package):
     homepage = "http://www.scalasca.org/software/cube-4.x/download.html"
     url = "http://apps.fz-juelich.de/scalasca/releases/cube/4.2/dist/cube-4.2.3.tar.gz"
 
-    version('4.3.4', '50f73060f55311cb12c5b3cb354d59fa',
-            url='http://apps.fz-juelich.de/scalasca/releases/cube/4.3/dist/cube-4.3.4.tar.gz')
-    version('4.3.3', '07e109248ed8ffc7bdcce614264a2909',
-            url='http://apps.fz-juelich.de/scalasca/releases/cube/4.3/dist/cube-4.3.3.tar.gz')
-    version('4.2.3', '8f95b9531f5a8f8134f279c2767c9b20',
-            url="http://apps.fz-juelich.de/scalasca/releases/cube/4.2/dist/cube-4.2.3.tar.gz")
+    # Some versions fail with parallel builds/installs
+    parallel = False
+
+    version('4.3.5', 'e5dce986e3c6381ea3a5fcb66c553adc')
+    version('4.3.4', '50f73060f55311cb12c5b3cb354d59fa')
+    version('4.3.3', '07e109248ed8ffc7bdcce614264a2909')
+
+    version('4.2.3', '8f95b9531f5a8f8134f279c2767c9b20')
 
     variant('gui', default=False, description='Build CUBE GUI')
 
     depends_on('zlib')
-    depends_on('qt@4.6:', when='+gui')
 
-    def install(self, spec, prefix):
-        configure_args = ["--prefix=%s" % prefix,
-                          "--without-paraver"]
+    depends_on('qt@5:', when='@4.3.0:4.3.999 +gui')
+    depends_on('qt@4.8:', when='@4.2.0:4.2.999 +gui')
+
+    def url_for_version(self, version):
+        return 'http://apps.fz-juelich.de/scalasca/releases/cube/{0}/dist/cube-{1}.tar.gz'.format(version.up_to(2), version)
+
+    def configure_args(self):
+        spec = self.spec
+
+        configure_args = ['--enable-shared']
 
-        # TODO : need to handle cross compiling build
         if '+gui' not in spec:
             configure_args.append('--without-gui')
 
-        configure(*configure_args)
-        make()
-        make("install", parallel=False)
+        return configure_args
diff --git a/var/spack/repos/builtin/packages/scalasca/package.py b/var/spack/repos/builtin/packages/scalasca/package.py
--- a/var/spack/repos/builtin/packages/scalasca/package.py
+++ b/var/spack/repos/builtin/packages/scalasca/package.py
@@ -43,19 +43,14 @@ class Scalasca(AutotoolsPackage):
     version('2.1',   'bab9c2b021e51e2ba187feec442b96e6')
 
     depends_on("mpi")
-    ##########
-    # Hard-code dependencies for Scalasca according to what stated in the
-    # release page
-    # The OTF2 library path should be detected automatically from SCOREP
-    # SCALASCA 2.2.2
-    depends_on("scorep@1.4:", when='@2.2.2:')
-    # Use same cube as scorep does
-    # -> depends_on("cube@4.3:", when='@2.2.2:')
-    # SCALASCA 2.1
-    depends_on("scorep@1.3", when='@2.1')
-    # Use same cube as scorep does
-    # -> depends_on("cube@4.2:", when='@2.1')
-    ##########
+
+    # version 2.3
+    depends_on('cube@4.3:', when='@2.3:')
+    depends_on('otf2@2:', when='@2.3:')
+
+    # version 2.1+
+    depends_on('cube@4.2', when='@2.1:2.2.999')
+    depends_on('otf2@1.4', when='@2.1:2.2.999')
 
     def url_for_version(self, version):
         return 'http://apps.fz-juelich.de/scalasca/releases/scalasca/{0}/dist/scalasca-{1}.tar.gz'.format(version.up_to(2), version)
@@ -65,7 +60,7 @@ def configure_args(self):
 
         config_args = ["--enable-shared"]
 
-        if 'cube' in spec:  # From scorep dependency
-            config_args.append("--with-cube=%s" % spec['cube'].prefix.bin)
+        config_args.append("--with-cube=%s" % spec['cube'].prefix.bin)
+        config_args.append("--with-otf2=%s" % spec['otf2'].prefix.bin)
 
         return config_args
diff --git a/var/spack/repos/builtin/packages/scorep/package.py b/var/spack/repos/builtin/packages/scorep/package.py
--- a/var/spack/repos/builtin/packages/scorep/package.py
+++ b/var/spack/repos/builtin/packages/scorep/package.py
@@ -34,6 +34,7 @@ class Scorep(AutotoolsPackage):
     homepage = "http://www.vi-hps.org/projects/score-p"
     url      = "http://www.vi-hps.org/upload/packages/scorep/scorep-2.0.2.tar.gz"
 
+    version('3.1',   '065bf8eb08398e8146c895718ddb9145')
     version('3.0',   '44da8beaa3f71436a5f6fe51938aab2f')
     version('2.0.2', '8f00e79e1b5b96e511c5ebecd10b2888')
     version('1.4.2', '3b9a042b13bdd5836452354e6567f71e')


Test patch: