Skip to content

Commit 9bebaae

Browse files
committed
Limit extensions to lua modules only
We need a Lmod version check and it's simple a complete pain in Tcl.
1 parent 399bbd2 commit 9bebaae

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

easybuild/tools/module_generator.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,6 @@ def is_loaded(self, mod_names):
334334

335335
return res
336336

337-
def check_version(self, minimal_version):
338-
"""
339-
Check the minimal version of the moduletool in the module file
340-
"""
341-
return self.VERSION_CHECK % minimal_version
342-
343337
def det_installdir(self, modfile):
344338
"""
345339
Determine installation directory used by given module file
@@ -656,8 +650,6 @@ class ModuleGeneratorTcl(ModuleGenerator):
656650
LOAD_TEMPLATE_DEPENDS_ON = "depends-on %(mod_name)s"
657651
IS_LOADED_TEMPLATE = 'is-loaded %s'
658652

659-
MODTOOL_VERSION_CHECK = ''
660-
661653
def check_group(self, group, error_msg=None):
662654
"""
663655
Generate a check of the software group and the current user, and refuse to load the module if the user don't
@@ -754,10 +746,6 @@ def get_description(self, conflict=True):
754746
# - 'conflict Compiler/GCC/4.8.2/OpenMPI' for 'Compiler/GCC/4.8.2/OpenMPI/1.6.4'
755747
lines.extend(['', "conflict %s" % os.path.dirname(self.app.short_mod_name)])
756748

757-
provide_list = self._generate_provides_list()
758-
if self.modules_tool.supports_extensions and provide_list:
759-
lines.extend(['', 'extensions %s' % ', '.join(provide_list)])
760-
761749
whatis_lines = ["module-whatis {%s}" % re.sub(r'([{}\[\]])', r'\\\1', l) for l in self._generate_whatis_lines()]
762750
txt += '\n'.join([''] + lines + ['']) % {
763751
'name': self.app.name,
@@ -1005,7 +993,7 @@ class ModuleGeneratorLua(ModuleGenerator):
1005993
LOAD_TEMPLATE_DEPENDS_ON = 'depends_on("%(mod_name)s")'
1006994
IS_LOADED_TEMPLATE = 'isloaded("%s")'
1007995

1008-
VERSION_CHECK = 'convertToCanonical(LmodVersion()) > convertToCanonical("%s")'
996+
VERSION_CHECK = 'convertToCanonical(LmodVersion()) > convertToCanonical("%(ver_maj)s.%(ver_min)s")'
1009997

1010998
PATH_JOIN_TEMPLATE = 'pathJoin(root, "%s")'
1011999
UPDATE_PATH_TEMPLATE = '%s_path("%s", %s)'
@@ -1021,6 +1009,15 @@ def __init__(self, *args, **kwargs):
10211009
if self.modules_tool.version and LooseVersion(self.modules_tool.version) >= LooseVersion('7.7.38'):
10221010
self.DOT_MODULERC = '.modulerc.lua'
10231011

1012+
def check_version(self, minimal_version_maj, minimal_version_min):
1013+
"""
1014+
Check the minimal version of the moduletool in the module file
1015+
"""
1016+
return self.VERSION_CHECK % {
1017+
'ver_maj': minimal_version_maj,
1018+
'ver_min': minimal_version_min,
1019+
}
1020+
10241021
def check_group(self, group, error_msg=None):
10251022
"""
10261023
Generate a check of the software group and the current user, and refuse to load the module if the user don't
@@ -1137,7 +1134,7 @@ def get_description(self, conflict=True):
11371134

11381135
if provide_list:
11391136
provide_list_mod = 'extensions(%s)' % ', '.join(['"%s"' % x for x in provide_list])
1140-
lines.extend(['', self.conditional_statement(self.check_version("8.2.0"), provide_list_mod)])
1137+
lines.extend(['', self.conditional_statement(self.check_version("8", "2"), provide_list_mod)])
11411138

11421139
txt += '\n'.join([''] + lines + ['']) % {
11431140
'name': self.app.name,

test/framework/module_generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,8 @@ def test_append_paths(self):
563563

564564
def test_module_extensions(self):
565565
"""test the extensions() for extensions"""
566-
if not self.modtool.supports_extensions:
566+
# not supported for Tcl modules
567+
if self.MODULE_GENERATOR_CLASS == ModuleGeneratorTcl:
567568
return
568569

569570
test_dir = os.path.abspath(os.path.dirname(__file__))
@@ -574,12 +575,11 @@ def test_module_extensions(self):
574575
eb = EasyBlock(ec)
575576
modgen = self.MODULE_GENERATOR_CLASS(eb)
576577
desc = modgen.get_description()
578+
print(desc)
577579

578580
patterns = []
579581
if self.MODULE_GENERATOR_CLASS == ModuleGeneratorLua:
580-
patterns.append(r'^extensions\("bar/0.0", "barbar/0.0", "l/s", "toy/0.0"\)')
581-
elif self.MODULE_GENERATOR_CLASS == ModuleGeneratorTcl:
582-
patterns.append('^extensions bar/0.0, barbar/0.0, l/s, toy/0.0')
582+
patterns.append(r'^\s*extensions\("bar/0.0", "barbar/0.0", "l/s", "toy/0.0"\)')
583583

584584
for pattern in patterns:
585585
self.assertTrue(re.search(pattern, desc, re.M), "Pattern '%s' found in: %s" % (pattern, desc))

0 commit comments

Comments
 (0)