Skip to content

Commit f297d32

Browse files
committed
Setenv value may be enclosed in curly braces on EnvironmentModules
Starting Environment Modules 4.2, value of setenv statement in "module show" output is enclosed in curly braces if it contains spaces. This change helps to pass "test_get_setenv_value_from_modulefile" test with Environment Modules v4.2+
1 parent 94ff50f commit f297d32

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

easybuild/tools/modules.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,27 @@ def check_module_output(self, cmd, stdout, stderr):
13581358
else:
13591359
self.log.debug("No errors detected when running module command '%s'", cmd)
13601360

1361+
def get_setenv_value_from_modulefile(self, mod_name, var_name):
1362+
"""
1363+
Get value for specific 'setenv' statement from module file for the specified module.
1364+
1365+
:param mod_name: module name
1366+
:param var_name: name of the variable being set for which value should be returned
1367+
"""
1368+
# Tcl-based module tools produce "module show" output with setenv statements like:
1369+
# "setenv GCC_PATH /opt/gcc/8.3.0"
1370+
# "setenv VAR {some text}
1371+
# - line starts with 'setenv'
1372+
# - whitespace (spaces & tabs) around variable name
1373+
# - curly braces around value if it contain spaces
1374+
value = super(EnvironmentModules, self).get_setenv_value_from_modulefile(mod_name=mod_name,
1375+
var_name=var_name)
1376+
1377+
if value:
1378+
value = value.strip('{}')
1379+
1380+
return value
1381+
13611382

13621383
class Lmod(ModulesTool):
13631384
"""Interface to Lmod."""

0 commit comments

Comments
 (0)