Skip to content

Commit 70b86fa

Browse files
author
ocaisa
authored
Merge pull request #3324 from kelseymh/3323_dependency_search_in_EC
New variable 'moddependpaths' to resolve dependencies at load time.
2 parents 1064122 + 3f61876 commit 70b86fa

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

easybuild/framework/easyblock.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,25 @@ def make_devel_module(self, create_in_builddir=False):
10141014
# cleanup: unload fake module, remove fake module dir
10151015
self.clean_up_fake_module(fake_mod_data)
10161016

1017+
def make_module_deppaths(self):
1018+
"""
1019+
Add specific 'module use' actions to module file, in order to find
1020+
dependencies outside the end user's MODULEPATH.
1021+
"""
1022+
deppaths = self.cfg['moddependpaths']
1023+
if not deppaths:
1024+
return ''
1025+
elif not isinstance(deppaths, (str, list, tuple)):
1026+
raise EasyBuildError("moddependpaths value %s (type: %s) is not a string, list or tuple",
1027+
deppaths, type(deppaths))
1028+
1029+
if isinstance(deppaths, str):
1030+
txt = self.module_generator.use([deppaths], guarded=True)
1031+
else:
1032+
txt = self.module_generator.use(deppaths, guarded=True)
1033+
1034+
return txt
1035+
10171036
def make_module_dep(self, unload_info=None):
10181037
"""
10191038
Make the dependencies for the module file.
@@ -2771,6 +2790,7 @@ def make_module_step(self, fake=False):
27712790

27722791
txt += self.make_module_description()
27732792
txt += self.make_module_group_check()
2793+
txt += self.make_module_deppaths()
27742794
txt += self.make_module_dep()
27752795
txt += self.make_module_extend_modpath()
27762796
txt += self.make_module_req()

easybuild/framework/easyconfig/default.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
'multi_deps': [{}, "Dict of lists of dependency versions over which to iterate", DEPENDENCIES],
155155
'multi_deps_load_default': [True, "Load module for first version listed in multi_deps by default", DEPENDENCIES],
156156
'osdependencies': [[], "OS dependencies that should be present on the system", DEPENDENCIES],
157+
'moddependpaths': [None, "Absolute path(s) to prepend to MODULEPATH before loading dependencies", DEPENDENCIES],
157158

158159
# LICENSE easyconfig parameters
159160
'group': [None, "Name of the user group for which the software should be available; "

test/framework/easyblock.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,48 @@ def test_make_module_extra(self):
516516
for pattern in patterns:
517517
self.assertTrue(re.search(pattern, txt, re.M), "Pattern '%s' found in: %s" % (pattern, txt))
518518

519+
def test_make_module_deppaths(self):
520+
"""Test for make_module_deppaths"""
521+
init_config(build_options={'silent': True})
522+
523+
self.contents = '\n'.join([
524+
'easyblock = "ConfigureMake"',
525+
'name = "pi"',
526+
'version = "3.14"',
527+
'homepage = "http://example.com"',
528+
'description = "test easyconfig"',
529+
"toolchain = {'name': 'gompi', 'version': '2018a'}",
530+
'moddependpaths = "/path/to/mods"',
531+
'dependencies = [',
532+
" ('FFTW', '3.3.7'),",
533+
']',
534+
])
535+
self.writeEC()
536+
eb = EasyBlock(EasyConfig(self.eb_file))
537+
538+
eb.installdir = os.path.join(config.install_path(), 'pi', '3.14')
539+
eb.check_readiness_step()
540+
eb.make_builddir()
541+
eb.prepare_step()
542+
543+
if get_module_syntax() == 'Tcl':
544+
use_load = '\n'.join([
545+
'if { [ file isdirectory "/path/to/mods" ] } {',
546+
' module use "/path/to/mods"',
547+
'}',
548+
])
549+
elif get_module_syntax() == 'Lua':
550+
use_load = '\n'.join([
551+
'if isDir("/path/to/mods") then',
552+
' prepend_path("MODULEPATH", "/path/to/mods")',
553+
'end',
554+
])
555+
else:
556+
self.assertTrue(False, "Unknown module syntax: %s" % get_module_syntax())
557+
558+
expected = use_load
559+
self.assertEqual(eb.make_module_deppaths().strip(), expected)
560+
519561
def test_make_module_dep(self):
520562
"""Test for make_module_dep"""
521563
init_config(build_options={'silent': True})

0 commit comments

Comments
 (0)