From f297d321b276730a6a5b806e60e266342012b999 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 29 Oct 2023 11:35:32 +0100 Subject: [PATCH] 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+ --- easybuild/tools/modules.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/easybuild/tools/modules.py b/easybuild/tools/modules.py index aa739f7563..e0eda91aeb 100644 --- a/easybuild/tools/modules.py +++ b/easybuild/tools/modules.py @@ -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."""