diff options
author | alalazo <massimiliano.culpo@googlemail.com> | 2016-05-10 15:48:37 +0200 |
---|---|---|
committer | alalazo <massimiliano.culpo@googlemail.com> | 2016-05-10 15:48:37 +0200 |
commit | 0b7c673205049565a95707fd55d2c086dd601b35 (patch) | |
tree | c32740c506cdb1d1a3137a1cb4597e05e544278a /lib | |
parent | f8f71b1c2c456210b64a90eb5b21484a8265cfa6 (diff) | |
download | spack-0b7c673205049565a95707fd55d2c086dd601b35.tar.gz spack-0b7c673205049565a95707fd55d2c086dd601b35.tar.bz2 spack-0b7c673205049565a95707fd55d2c086dd601b35.tar.xz spack-0b7c673205049565a95707fd55d2c086dd601b35.zip |
modules : changed syntax for environment modifications
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/config.py | 14 | ||||
-rw-r--r-- | lib/spack/spack/modules.py | 22 | ||||
-rw-r--r-- | lib/spack/spack/test/modules.py | 3 |
3 files changed, 29 insertions, 10 deletions
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index d008a513e7..6ddf07776b 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -251,6 +251,14 @@ section_schemas = { 'type': 'string' } }, + 'dictionary_of_strings': { + 'type': 'object', + 'patternProperties': { + r'\w[\w-]*': { # key + 'type': 'string' + } + } + }, 'dependency_selection': { 'type': 'string', 'enum': ['none', 'direct', 'all'] @@ -282,10 +290,10 @@ section_schemas = { 'default': {}, 'additionalProperties': False, 'properties': { - 'set': {'$ref': '#/definitions/array_of_strings'}, + 'set': {'$ref': '#/definitions/dictionary_of_strings'}, 'unset': {'$ref': '#/definitions/array_of_strings'}, - 'prepend_path': {'$ref': '#/definitions/array_of_strings'}, - 'append_path': {'$ref': '#/definitions/array_of_strings'} + 'prepend_path': {'$ref': '#/definitions/dictionary_of_strings'}, + 'append_path': {'$ref': '#/definitions/dictionary_of_strings'} } } } diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py index f1c0bd87de..19bd1993a7 100644 --- a/lib/spack/spack/modules.py +++ b/lib/spack/spack/modules.py @@ -185,14 +185,26 @@ def parse_config_options(module_generator): # Environment modifications environment_actions = module_file_actions.pop('environment', {}) env = EnvironmentModifications() + + def process_arglist(arglist): + if method == 'unset': + for x in arglist: + yield (x,) + else: + for x in arglist.iteritems(): + yield x + for method, arglist in environment_actions.items(): - for item in arglist: - if method == 'unset': - args = [item] - else: - args = item.split(',') + for args in process_arglist(arglist): getattr(env, method)(*args) + # for item in arglist: + # if method == 'unset': + # args = [item] + # else: + # args = item.split(',') + # getattr(env, method)(*args) + return module_file_actions, env diff --git a/lib/spack/spack/test/modules.py b/lib/spack/spack/test/modules.py index 704700417b..b8b0d6fc6a 100644 --- a/lib/spack/spack/test/modules.py +++ b/lib/spack/spack/test/modules.py @@ -47,7 +47,7 @@ configuration_alter_environment = { 'filter': {'environment_blacklist': ['CMAKE_PREFIX_PATH']} }, '=x86-linux': { - 'environment': {'set': ['FOO,foo'], 'unset': ['BAR']} + 'environment': {'set': {'FOO': 'foo'}, 'unset': ['BAR']} } } } @@ -99,7 +99,6 @@ class TclTests(MockPackagesTest): spec = spack.spec.Spec('mpich@3.0.4=x86-linux') content = self.get_modulefile_content(spec) self.assertTrue('module-whatis "mpich @3.0.4"' in content ) - self.assertEqual(len([x for x in content if x.startswith('prepend-path CMAKE_PREFIX_PATH')]), 1) def test_autoload(self): spack.modules.CONFIGURATION = configuration_autoload_direct |