Repository: spack/spack

Issue:
build dependencies are loading in environment module files
I have the following in my `modules.yaml` file:

```
modules:
  tcl:
    naming_scheme: '{name}/{version}-{compiler.name}-{compiler.version}'
    all:
      autoload: 'direct'
```

When loading a module all `build` dependencies are loaded as well. This is not a huge issue but I think the desired behavior is to _not_ load build-only dependencies.



Discussion:
@alalazo @mathstuf : maybe the module code wasn't updated to ignore build-only deps?

Definitely. I'll have a look asap (most likely tomorrow)

@tgamblin Do you mind assigning this issue to me ? It's just easier to find if it is in my list :blush: 

I really wish there was an "assign to yourself" option. Maybe I'll propose that to GitHub.

@adamjstewart @alalazo How about I give you guys write access.  GitHub seems to have grown sufficient permissions on `develop` and `master` that I'm ok with doing this.  This would enable you to push other branches, assign issues, and such, but not to merge PRs or push to develop or master.

@tgamblin Cool ! That would also help if we need to work in small teams on some features.

@alalazo @adamjstewart: done!  I'm super happy because this helps tremendously w/scaling the project.

@tgamblin Maybe in a few months we will have for free a Scrum board... :smile: 


Resolving patch:
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -120,7 +120,7 @@ def dependencies(spec, request='all'):
         return []
 
     if request == 'direct':
-        return spec.dependencies()
+        return spec.dependencies(deptype=('link', 'run'))
 
     # FIXME : during module file creation nodes seem to be visited multiple
     # FIXME : times even if cover='nodes' is given. This work around permits
@@ -133,6 +133,7 @@ def dependencies(spec, request='all'):
              spec.traverse(order='post',
                            depth=True,
                            cover='nodes',
+                           deptype=('link', 'run'),
                            root=False),
              reverse=True)]
     return [xx for ii, xx in l if not (xx in seen or seen_add(xx))]


Test patch:
diff --git a/lib/spack/spack/test/modules.py b/lib/spack/spack/test/modules.py
--- a/lib/spack/spack/test/modules.py
+++ b/lib/spack/spack/test/modules.py
@@ -229,6 +229,28 @@ def test_autoload(self):
         self.assertEqual(len([x for x in content if 'is-loaded' in x]), 5)
         self.assertEqual(len([x for x in content if 'module load ' in x]), 5)
 
+        # dtbuild1 has
+        # - 1 ('run',) dependency
+        # - 1 ('build','link') dependency
+        # - 1 ('build',) dependency
+        # Just make sure the 'build' dependency is not there
+        spack.modules.CONFIGURATION = configuration_autoload_direct
+        spec = spack.spec.Spec('dtbuild1')
+        content = self.get_modulefile_content(spec)
+        self.assertEqual(len([x for x in content if 'is-loaded' in x]), 2)
+        self.assertEqual(len([x for x in content if 'module load ' in x]), 2)
+
+        # dtbuild1 has
+        # - 1 ('run',) dependency
+        # - 1 ('build','link') dependency
+        # - 1 ('build',) dependency
+        # Just make sure the 'build' dependency is not there
+        spack.modules.CONFIGURATION = configuration_autoload_all
+        spec = spack.spec.Spec('dtbuild1')
+        content = self.get_modulefile_content(spec)
+        self.assertEqual(len([x for x in content if 'is-loaded' in x]), 2)
+        self.assertEqual(len([x for x in content if 'module load ' in x]), 2)
+
     def test_prerequisites(self):
         spack.modules.CONFIGURATION = configuration_prerequisites_direct
         spec = spack.spec.Spec('mpileaks arch=x86-linux')