summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoralalazo <massimiliano.culpo@googlemail.com>2016-04-11 18:10:06 +0200
committeralalazo <massimiliano.culpo@googlemail.com>2016-04-11 18:10:06 +0200
commit3959ca627046ff7d6519da9c5375a0ae6da50b74 (patch)
tree57538b1afc0c9be73e8da3e53fc4b48913001a66 /lib
parent0e2b1359e32e2948dc3ef831b83ae34483909fd0 (diff)
downloadspack-3959ca627046ff7d6519da9c5375a0ae6da50b74.tar.gz
spack-3959ca627046ff7d6519da9c5375a0ae6da50b74.tar.bz2
spack-3959ca627046ff7d6519da9c5375a0ae6da50b74.tar.xz
spack-3959ca627046ff7d6519da9c5375a0ae6da50b74.zip
modules : added possibility to blacklist or whitelist module files
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/module.py1
-rw-r--r--lib/spack/spack/config.py17
-rw-r--r--lib/spack/spack/modules.py32
3 files changed, 40 insertions, 10 deletions
diff --git a/lib/spack/spack/cmd/module.py b/lib/spack/spack/cmd/module.py
index a67f5c0c13..f996f4eb84 100644
--- a/lib/spack/spack/cmd/module.py
+++ b/lib/spack/spack/cmd/module.py
@@ -89,7 +89,6 @@ def module_refresh():
shutil.rmtree(cls.path, ignore_errors=False)
mkdirp(cls.path)
for spec in specs:
- tty.debug(" Writing file for %s" % spec)
cls(spec).write()
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index e696a62e96..da4e787f18 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -292,12 +292,17 @@ section_schemas = {
'module_type_configuration': {
'type': 'object',
'default': {},
- 'properties': {
- 'all': {'$ref': '#/definitions/module_file_configuration'}
- },
- 'patternProperties': {
- r'\w[\w-]*': {'$ref': '#/definitions/module_file_configuration'}
- }
+ 'oneOf': [
+ {
+ 'properties': {
+ 'whitelist': {'$ref': '#/definitions/array_of_strings'},
+ 'blacklist': {'$ref': '#/definitions/array_of_strings'},
+ }
+ },
+ {
+ 'patternProperties': {r'\w[\w-]*': {'$ref': '#/definitions/module_file_configuration'}}
+ }
+ ]
}
},
'patternProperties': {
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index 8a96d49144..04f43b9605 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -40,17 +40,15 @@ various shell-support files in $SPACK/share/spack/setup-env.*.
Each hook in hooks/ implements the logic for writing its specific type of module file.
"""
+import copy
import os
import os.path
import re
-import shutil
import textwrap
-import copy
import llnl.util.tty as tty
import spack
import spack.config
-
from llnl.util.filesystem import join_path, mkdirp
from spack.build_environment import parent_class_modules, set_module_variables_for_package
from spack.environment import *
@@ -225,6 +223,30 @@ class EnvModule(object):
# Not very descriptive fallback
return 'spack installed package'
+ @property
+ def blacklisted(self):
+ configuration = CONFIGURATION.get(self.name, {})
+ whitelist_matches = [x for x in configuration.get('whitelist', []) if self.spec.satisfies(x)]
+ blacklist_matches = [x for x in configuration.get('blacklist', []) if self.spec.satisfies(x)]
+ if whitelist_matches:
+ message = '\t%s is whitelisted [matches : ' % self.spec.cshort_spec
+ for rule in whitelist_matches:
+ message += '%s ' % rule
+ message += ' ]'
+ tty.debug(message)
+
+ if blacklist_matches:
+ message = '\t%s is blacklisted [matches : ' % self.spec.cshort_spec
+ for rule in blacklist_matches:
+ message += '%s ' % rule
+ message += ' ]'
+ tty.debug(message)
+
+ if not whitelist_matches and blacklist_matches:
+ return True
+
+ return False
+
def write(self):
"""
Writes out a module file for this object.
@@ -233,6 +255,10 @@ class EnvModule(object):
- override the header property
- provide formats for autoload, prerequisites and environment changes
"""
+ if self.blacklisted:
+ return
+ tty.debug("\t%s : writing module file" % self.spec.cshort_spec)
+
module_dir = os.path.dirname(self.file_name)
if not os.path.exists(module_dir):
mkdirp(module_dir)