From 5ccb3b3526b82356b78edc9a36942bb63b3cf12c Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 24 Feb 2026 17:21:29 +0100 Subject: [PATCH 1/2] Add support for non-path variables in `module_load_environment` Useful for simple values. Using existing logic. If the value is a list elements are joined using the delimiter. --- easybuild/framework/easyblock.py | 12 ++++-------- test/framework/easyblock.py | 11 +++++------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/easybuild/framework/easyblock.py b/easybuild/framework/easyblock.py index ed6aa0af5d..90537d9b19 100644 --- a/easybuild/framework/easyblock.py +++ b/easybuild/framework/easyblock.py @@ -1770,14 +1770,6 @@ def make_module_req(self): if envar_val.is_path } self.log.debug(f"Tentative module environment requirements before path expansion: {env_var_requirements}") - # TODO: handle non-path variables in make_module_extra - # in the meantime, just report if any is found - non_path_envars = set(self.module_load_environment) - set(env_var_requirements) - if non_path_envars: - self.log.warning( - f"Non-path variables found in module load environment: {non_path_envars}." - "This is not yet supported by this version of EasyBuild." - ) mod_lines = ['\n'] @@ -1802,6 +1794,10 @@ def make_module_req(self): delim=search_paths.delimiter) mod_lines.append(extra_mod_lines) + for env_var, value in sorted(self.module_load_environment.items()): + if env_var not in env_var_requirements: + mod_lines.append(self.module_generator.set_environment(env_var, value.delimiter.join(value.contents))) + if self.dry_run: self.dry_run_msg('') diff --git a/test/framework/easyblock.py b/test/framework/easyblock.py index c9f6d321d5..b7833b5ef3 100644 --- a/test/framework/easyblock.py +++ b/test/framework/easyblock.py @@ -652,7 +652,6 @@ def test_make_module_req(self): r'prepend_path\("PATH", pathJoin\(root, "%s"\)\)\n' % sub_path_path, re.M)) # Module load environement may contain non-path variables - # TODO: remove whenever this is properly supported, in the meantime check warning eb.module_load_environment.NONPATH = {'contents': 'non_path', 'var_type': "STRING"} eb.module_load_environment.PATH = ['bin'] with self.mocked_stdout_stderr(): @@ -661,16 +660,16 @@ def test_make_module_req(self): self.assertEqual(list(eb.module_load_environment), ['PATH', 'LD_LIBRARY_PATH', 'NONPATH']) if get_module_syntax() == 'Tcl': - self.assertTrue(re.match(r"^\nprepend-path\s+PATH\s+\$root/bin\n$", txt, re.M)) - self.assertFalse(re.match(r"^\nprepend-path\s+NONPATH\s+\$root/non_path\n$", txt, re.M)) + self.assertRegex(txt, re.compile(r"^\nprepend-path\s+PATH\s+\$root/bin\n", re.M)) + self.assertRegex(txt, re.compile(r'^setenv\s+NONPATH\s+"non_path"\s*$', re.M)) elif get_module_syntax() == 'Lua': - self.assertTrue(re.match(r'^\nprepend_path\("PATH", pathJoin\(root, "bin"\)\)\n$', txt, re.M)) - self.assertFalse(re.match(r'^\nprepend_path\("NONPATH", pathJoin\(root, "non_path"\)\)\n$', txt, re.M)) + self.assertRegex(txt, re.compile(r'^prepend_path\("PATH", pathJoin\(root, "bin"\)\)$', re.M)) + self.assertRegex(txt, re.compile(r'^setenv\("NONPATH", "non_path"\)$', re.M)) else: self.fail("Unknown module syntax: %s" % get_module_syntax()) logtxt = read_file(eb.logfile) - self.assertRegex(logtxt, r"WARNING Non-path variables found in module load env.*NONPATH") + self.assertNotRegex(logtxt, r"WARNING Non-path variables found in module load env.*NONPATH") eb.module_load_environment.remove('NONPATH') From 708fd52b95b83a3c4d0e66f700f719c0239752a4 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 8 Apr 2026 16:03:39 +0200 Subject: [PATCH 2/2] Remove outdated test --- test/framework/easyblock.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/framework/easyblock.py b/test/framework/easyblock.py index b7833b5ef3..51c7c31a89 100644 --- a/test/framework/easyblock.py +++ b/test/framework/easyblock.py @@ -668,9 +668,6 @@ def test_make_module_req(self): else: self.fail("Unknown module syntax: %s" % get_module_syntax()) - logtxt = read_file(eb.logfile) - self.assertNotRegex(logtxt, r"WARNING Non-path variables found in module load env.*NONPATH") - eb.module_load_environment.remove('NONPATH') # make sure that entries that symlink to another directory are retained;