Skip to content
Merged
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
20 changes: 20 additions & 0 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,25 @@ def make_devel_module(self, create_in_builddir=False):
# cleanup: unload fake module, remove fake module dir
self.clean_up_fake_module(fake_mod_data)

def make_module_deppaths(self):
"""
Add specific 'module use' actions to module file, in order to find
dependencies outside the end user's MODULEPATH.
"""
deppaths = self.cfg['moddependpaths']
if not deppaths:
return ''
elif not isinstance(deppaths, (str, list, tuple)):
raise EasyBuildError("moddependpaths value %s (type: %s) is not a string, list or tuple",
deppaths, type(deppaths))

if isinstance(deppaths, str):
txt = self.module_generator.use([deppaths], guarded=True)
else:
txt = self.module_generator.use(deppaths, guarded=True)

return txt

def make_module_dep(self, unload_info=None):
"""
Make the dependencies for the module file.
Expand Down Expand Up @@ -2771,6 +2790,7 @@ def make_module_step(self, fake=False):

txt += self.make_module_description()
txt += self.make_module_group_check()
txt += self.make_module_deppaths()
txt += self.make_module_dep()
txt += self.make_module_extend_modpath()
txt += self.make_module_req()
Expand Down
1 change: 1 addition & 0 deletions easybuild/framework/easyconfig/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
'multi_deps': [{}, "Dict of lists of dependency versions over which to iterate", DEPENDENCIES],
'multi_deps_load_default': [True, "Load module for first version listed in multi_deps by default", DEPENDENCIES],
'osdependencies': [[], "OS dependencies that should be present on the system", DEPENDENCIES],
'moddependpaths': [None, "Absolute path(s) to prepend to MODULEPATH before loading dependencies", DEPENDENCIES],

# LICENSE easyconfig parameters
'group': [None, "Name of the user group for which the software should be available; "
Expand Down
42 changes: 42 additions & 0 deletions test/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,48 @@ def test_make_module_extra(self):
for pattern in patterns:
self.assertTrue(re.search(pattern, txt, re.M), "Pattern '%s' found in: %s" % (pattern, txt))

def test_make_module_deppaths(self):
"""Test for make_module_deppaths"""
init_config(build_options={'silent': True})

self.contents = '\n'.join([
'easyblock = "ConfigureMake"',
'name = "pi"',
'version = "3.14"',
'homepage = "http://example.com"',
'description = "test easyconfig"',
"toolchain = {'name': 'gompi', 'version': '2018a'}",
'moddependpaths = "/path/to/mods"',
'dependencies = [',
" ('FFTW', '3.3.7'),",
']',
])
self.writeEC()
eb = EasyBlock(EasyConfig(self.eb_file))

eb.installdir = os.path.join(config.install_path(), 'pi', '3.14')
eb.check_readiness_step()
eb.make_builddir()
eb.prepare_step()

if get_module_syntax() == 'Tcl':
use_load = '\n'.join([
'if { [ file isdirectory "/path/to/mods" ] } {',
' module use "/path/to/mods"',
'}',
])
elif get_module_syntax() == 'Lua':
use_load = '\n'.join([
'if isDir("/path/to/mods") then',
' prepend_path("MODULEPATH", "/path/to/mods")',
'end',
])
else:
self.assertTrue(False, "Unknown module syntax: %s" % get_module_syntax())

expected = use_load
self.assertEqual(eb.make_module_deppaths().strip(), expected)

def test_make_module_dep(self):
"""Test for make_module_dep"""
init_config(build_options={'silent': True})
Expand Down