modules : changed syntax for environment modifications
This commit is contained in:
parent
f8f71b1c2c
commit
0b7c673205
@ -251,6 +251,14 @@
|
|||||||
'type': 'string'
|
'type': 'string'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'dictionary_of_strings': {
|
||||||
|
'type': 'object',
|
||||||
|
'patternProperties': {
|
||||||
|
r'\w[\w-]*': { # key
|
||||||
|
'type': 'string'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
'dependency_selection': {
|
'dependency_selection': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'enum': ['none', 'direct', 'all']
|
'enum': ['none', 'direct', 'all']
|
||||||
@ -282,10 +290,10 @@
|
|||||||
'default': {},
|
'default': {},
|
||||||
'additionalProperties': False,
|
'additionalProperties': False,
|
||||||
'properties': {
|
'properties': {
|
||||||
'set': {'$ref': '#/definitions/array_of_strings'},
|
'set': {'$ref': '#/definitions/dictionary_of_strings'},
|
||||||
'unset': {'$ref': '#/definitions/array_of_strings'},
|
'unset': {'$ref': '#/definitions/array_of_strings'},
|
||||||
'prepend_path': {'$ref': '#/definitions/array_of_strings'},
|
'prepend_path': {'$ref': '#/definitions/dictionary_of_strings'},
|
||||||
'append_path': {'$ref': '#/definitions/array_of_strings'}
|
'append_path': {'$ref': '#/definitions/dictionary_of_strings'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,14 +185,26 @@ def parse_config_options(module_generator):
|
|||||||
# Environment modifications
|
# Environment modifications
|
||||||
environment_actions = module_file_actions.pop('environment', {})
|
environment_actions = module_file_actions.pop('environment', {})
|
||||||
env = EnvironmentModifications()
|
env = EnvironmentModifications()
|
||||||
for method, arglist in environment_actions.items():
|
|
||||||
for item in arglist:
|
def process_arglist(arglist):
|
||||||
if method == 'unset':
|
if method == 'unset':
|
||||||
args = [item]
|
for x in arglist:
|
||||||
|
yield (x,)
|
||||||
else:
|
else:
|
||||||
args = item.split(',')
|
for x in arglist.iteritems():
|
||||||
|
yield x
|
||||||
|
|
||||||
|
for method, arglist in environment_actions.items():
|
||||||
|
for args in process_arglist(arglist):
|
||||||
getattr(env, method)(*args)
|
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
|
return module_file_actions, env
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ def mock_open(filename, mode):
|
|||||||
'filter': {'environment_blacklist': ['CMAKE_PREFIX_PATH']}
|
'filter': {'environment_blacklist': ['CMAKE_PREFIX_PATH']}
|
||||||
},
|
},
|
||||||
'=x86-linux': {
|
'=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')
|
spec = spack.spec.Spec('mpich@3.0.4=x86-linux')
|
||||||
content = self.get_modulefile_content(spec)
|
content = self.get_modulefile_content(spec)
|
||||||
self.assertTrue('module-whatis "mpich @3.0.4"' in content )
|
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):
|
def test_autoload(self):
|
||||||
spack.modules.CONFIGURATION = configuration_autoload_direct
|
spack.modules.CONFIGURATION = configuration_autoload_direct
|
||||||
|
Loading…
Reference in New Issue
Block a user