Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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('')

Expand Down
12 changes: 4 additions & 8 deletions test/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -661,17 +660,14 @@ 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")

eb.module_load_environment.remove('NONPATH')

# make sure that entries that symlink to another directory are retained;
Expand Down
Loading