summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/modules.py27
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index ba220291a0..885f2197ef 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -438,13 +438,20 @@ class EnvModule(object):
def module_specific_content(self, configuration):
return tuple()
+ # Subclasses can return a fragment of module code that prints out
+ # a warning that modules are being autoloaded.
+ def autoload_warner(self):
+ return ''
+
def autoload(self, spec):
if not isinstance(spec, str):
m = type(self)(spec)
module_file = m.use_name
else:
module_file = spec
- return self.autoload_format.format(module_file=module_file)
+ return self.autoload_format.format(
+ module_file=module_file,
+ warner=self.autoload_warner().format(module_file=module_file))
def prerequisite(self, spec):
m = type(self)(spec)
@@ -486,6 +493,10 @@ class EnvModule(object):
# removedirs throws OSError on first non-empty directory found
pass
+ def verbose_autoload(self):
+ configuration = _module_config.get(self.name, {})
+ return configuration.get('verbose_autoload', True)
+
class Dotkit(EnvModule):
name = 'dotkit'
@@ -537,8 +548,13 @@ class TclModule(EnvModule):
path = canonicalize_path(
_roots.get(name, join_path(spack.share_path, 'modules')))
+ def autoload_warner(self):
+ if self.verbose_autoload():
+ return 'puts stderr "Autoloading {module_file}"\n'
+ return ''
+
autoload_format = ('if ![ is-loaded {module_file} ] {{\n'
- ' puts stderr "Autoloading {module_file}"\n'
+ ' {warner}'
' module load {module_file}\n'
'}}\n\n')
@@ -665,8 +681,13 @@ class LmodModule(EnvModule):
UnsetEnv: 'unsetenv("{name}")\n'
}
+ def autoload_warner(self):
+ if self.verbose_autoload():
+ return 'LmodMessage("Autoloading {module_file}")\n'
+ return ''
+
autoload_format = ('if not isloaded("{module_file}") then\n'
- ' LmodMessage("Autoloading {module_file}")\n'
+ ' {warner}'
' load("{module_file}")\n'
'end\n\n')