Skip to content

Commit

Permalink
Setenv value may be enclosed in curly braces on EnvironmentModules
Browse files Browse the repository at this point in the history
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+
  • Loading branch information
xdelaruelle committed Oct 29, 2023
1 parent 94ff50f commit f297d32
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions easybuild/tools/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,27 @@ def check_module_output(self, cmd, stdout, stderr):
else:
self.log.debug("No errors detected when running module command '%s'", cmd)

def get_setenv_value_from_modulefile(self, mod_name, var_name):
"""
Get value for specific 'setenv' statement from module file for the specified module.
:param mod_name: module name
:param var_name: name of the variable being set for which value should be returned
"""
# Tcl-based module tools produce "module show" output with setenv statements like:
# "setenv GCC_PATH /opt/gcc/8.3.0"
# "setenv VAR {some text}
# - line starts with 'setenv'
# - whitespace (spaces & tabs) around variable name
# - curly braces around value if it contain spaces
value = super(EnvironmentModules, self).get_setenv_value_from_modulefile(mod_name=mod_name,
var_name=var_name)

if value:
value = value.strip('{}')

return value


class Lmod(ModulesTool):
"""Interface to Lmod."""
Expand Down

0 comments on commit f297d32

Please sign in to comment.