Merge pull request #617 from epfl-scitas/features/disable_modules

feature : module file generation may be disabled via configuration file
This commit is contained in:
Todd Gamblin 2016-03-24 02:52:45 -07:00
commit f031bdfbc9
3 changed files with 37 additions and 4 deletions

8
etc/spack/modules.yaml Normal file
View File

@ -0,0 +1,8 @@
# -------------------------------------------------------------------------
# This is the default spack module files generation configuration.
#
# Changes to this file will affect all users of this spack install,
# although users can override these settings in their ~/.spack/modules.yaml.
# -------------------------------------------------------------------------
modules:
enable: ['tcl', 'dotkit']

View File

@ -237,7 +237,29 @@
'type' : 'object',
'default' : {},
}
},},},},},}
},},},},},},
'modules': {
'$schema': 'http://json-schema.org/schema#',
'title': 'Spack module file configuration file schema',
'type': 'object',
'additionalProperties': False,
'patternProperties': {
r'modules:?': {
'type': 'object',
'default': {},
'additionalProperties': False,
'properties': {
'enable': {
'type': 'array',
'default': [],
'items': {
'type': 'string'
}
}
}
},
},
},
}
"""OrderedDict of config scopes keyed by name.
@ -405,11 +427,11 @@ def _read_config_file(filename, schema):
validate_section(data, schema)
return data
except MarkedYAMLError, e:
except MarkedYAMLError as e:
raise ConfigFileError(
"Error parsing yaml%s: %s" % (str(e.context_mark), e.problem))
except IOError, e:
except IOError as e:
raise ConfigFileError(
"Error reading configuration file %s: %s" % (filename, str(e)))

View File

@ -48,6 +48,7 @@
import llnl.util.tty as tty
import spack
import spack.config
from llnl.util.filesystem import join_path, mkdirp
from spack.environment import *
@ -56,6 +57,8 @@
# Registry of all types of modules. Entries created by EnvModule's metaclass
module_types = {}
CONFIGURATION = spack.config.get_config('modules')
def print_help():
"""For use by commands to tell user how to activate shell support."""
@ -115,7 +118,7 @@ class EnvModule(object):
class __metaclass__(type):
def __init__(cls, name, bases, dict):
type.__init__(cls, name, bases, dict)
if cls.name != 'env_module':
if cls.name != 'env_module' and cls.name in CONFIGURATION['enable']:
module_types[cls.name] = cls
def __init__(self, spec=None):