modules : changed syntax for environment modifications

This commit is contained in:
alalazo 2016-05-10 15:48:37 +02:00
parent f8f71b1c2c
commit 0b7c673205
3 changed files with 29 additions and 10 deletions

View File

@ -251,6 +251,14 @@
'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 @@
'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'}
}
}
}

View File

@ -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

View File

@ -47,7 +47,7 @@ def mock_open(filename, mode):
'filter': {'environment_blacklist': ['CMAKE_PREFIX_PATH']}
},
'=x86-linux': {
'environment': {'set': ['FOO,foo'], 'unset': ['BAR']}
'environment': {'set': {'FOO': 'foo'}, 'unset': ['BAR']}
}
}
}
@ -99,7 +99,6 @@ def test_simple_case(self):
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