Skip to content

Commit 2e61f32

Browse files
authoredAug 28, 2024··
Merge pull request #4501 from Micket/modextensionstrue
enable `--module-extensions` by default (+ resolve template values used in extension version)
2 parents f8c9913 + ac9ddea commit 2e61f32

File tree

5 files changed

+21
-42
lines changed

5 files changed

+21
-42
lines changed
 

‎easybuild/framework/easyblock.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,8 @@ def _make_extension_list(self):
17531753
if isinstance(ext, str):
17541754
exts_list.append((resolve_template(ext, self.cfg.template_values), ))
17551755
else:
1756-
exts_list.append((resolve_template(ext[0], self.cfg.template_values), ext[1]))
1756+
exts_list.append((resolve_template(ext[0], self.cfg.template_values),
1757+
resolve_template(ext[1], self.cfg.template_values)))
17571758
return exts_list
17581759

17591760
def make_extension_string(self, name_version_sep='-', ext_sep=', ', sort=True):

‎easybuild/tools/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
294294
'install_latest_eb_release',
295295
'logtostdout',
296296
'minimal_toolchains',
297-
'module_extensions',
298297
'module_only',
299298
'package',
300299
'parallel_extensions_install',
@@ -330,6 +329,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
330329
'lib64_fallback_sanity_check',
331330
'lib64_lib_symlink',
332331
'map_toolchains',
332+
'module_extensions',
333333
'modules_tool_version_check',
334334
'mpi_tests',
335335
'pre_create_installdir',

‎easybuild/tools/module_generator.py

+15-38
Original file line numberDiff line numberDiff line change
@@ -826,19 +826,20 @@ def get_description(self, conflict=True):
826826
"""
827827
Generate a description.
828828
"""
829-
txt = '\n'.join([
829+
lines = [
830830
"proc ModulesHelp { } {",
831831
" puts stderr {%s" % re.sub(r'([{}\[\]])', r'\\\1', self._generate_help_text()),
832832
" }",
833833
'}',
834834
'',
835+
]
836+
837+
lines.extend([
838+
"module-whatis {%s}" % re.sub(r'([{}\[\]])', r'\\\1', line)
839+
for line in self._generate_whatis_lines()
835840
])
836841

837-
lines = [
838-
'%(whatis_lines)s',
839-
'',
840-
"set root %(installdir)s",
841-
]
842+
lines.extend(['', "set root " + self.app.installdir])
842843

843844
if self.app.cfg['moduleloadnoconflict']:
844845
cond_unload = self.conditional_statement(self.is_loaded('%(name)s'), "module unload %(name)s")
@@ -855,18 +856,7 @@ def get_description(self, conflict=True):
855856
# - 'conflict Compiler/GCC/4.8.2/OpenMPI' for 'Compiler/GCC/4.8.2/OpenMPI/1.6.4'
856857
lines.extend(['', "conflict %s" % os.path.dirname(self.app.short_mod_name)])
857858

858-
whatis_lines = [
859-
"module-whatis {%s}" % re.sub(r'([{}\[\]])', r'\\\1', line)
860-
for line in self._generate_whatis_lines()
861-
]
862-
txt += '\n'.join([''] + lines + ['']) % {
863-
'name': self.app.name,
864-
'version': self.app.version,
865-
'whatis_lines': '\n'.join(whatis_lines),
866-
'installdir': self.app.installdir,
867-
}
868-
869-
return txt
859+
return '\n'.join(lines + [''])
870860

871861
def getenv_cmd(self, envvar, default=None):
872862
"""
@@ -1273,29 +1263,24 @@ def get_description(self, conflict=True):
12731263
"""
12741264
Generate a description.
12751265
"""
1276-
txt = '\n'.join([
1266+
lines = [
12771267
'help(%s%s' % (self.START_STR, self.check_str(self._generate_help_text())),
12781268
'%s)' % self.END_STR,
12791269
'',
1280-
])
1281-
1282-
lines = [
1283-
"%(whatis_lines)s",
1284-
'',
1285-
'local root = "%(installdir)s"',
12861270
]
12871271

1272+
for line in self._generate_whatis_lines():
1273+
lines.append("whatis(%s%s%s)" % (self.START_STR, self.check_str(line), self.END_STR))
1274+
1275+
lines.extend(['', 'local root = "%s"' % self.app.installdir])
1276+
12881277
if self.app.cfg['moduleloadnoconflict']:
12891278
self.log.info("Nothing to do to ensure no conflicts can occur on load when using Lua modules files/Lmod")
12901279

12911280
elif conflict:
12921281
# conflict on 'name' part of module name (excluding version part at the end)
12931282
lines.extend(['', 'conflict("%s")' % os.path.dirname(self.app.short_mod_name)])
12941283

1295-
whatis_lines = []
1296-
for line in self._generate_whatis_lines():
1297-
whatis_lines.append("whatis(%s%s%s)" % (self.START_STR, self.check_str(line), self.END_STR))
1298-
12991284
if build_option('module_extensions'):
13001285
extensions_list = self._generate_extensions_list()
13011286

@@ -1306,15 +1291,7 @@ def get_description(self, conflict=True):
13061291
# https://github.com/TACC/Lmod/issues/428
13071292
lines.extend(['', self.conditional_statement(self.check_version("8", "2", "8"), extensions_stmt)])
13081293

1309-
txt += '\n'.join([''] + lines + ['']) % {
1310-
'name': self.app.name,
1311-
'version': self.app.version,
1312-
'whatis_lines': '\n'.join(whatis_lines),
1313-
'installdir': self.app.installdir,
1314-
'homepage': self.app.cfg['homepage'],
1315-
}
1316-
1317-
return txt
1294+
return '\n'.join(lines + [''])
13181295

13191296
def getenv_cmd(self, envvar, default=None):
13201297
"""

‎easybuild/tools/options.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def config_options(self):
584584
"(implies recursive unloading of modules).",
585585
None, 'store_true', False),
586586
'module-extensions': ("Include 'extensions' statement in generated module file (Lua syntax only)",
587-
None, 'store_true', False),
587+
None, 'store_true', True),
588588
'module-naming-scheme': ("Module naming scheme to use", None, 'store', DEFAULT_MNS),
589589
'module-syntax': ("Syntax to be used for module files", 'choice', 'store', DEFAULT_MODULE_SYNTAX,
590590
sorted(avail_module_generators().keys())),

‎test/framework/easyconfig.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,8 @@ def test_exts_list(self):
533533
with self.mocked_stdout_stderr():
534534
modfile = os.path.join(eb.make_module_step(), 'PI', '3.14' + eb.module_generator.MODULE_FILE_EXTENSION)
535535
modtxt = read_file(modfile)
536-
regex = re.compile('EBEXTSLISTPI.*ext1-1.0,ext2-2.0')
536+
# verify that templates used for extensions are resolved as they should
537+
regex = re.compile('EBEXTSLISTPI.*"ext1-1.0,ext2-2.0,ext-PI-3.14,ext-pi-3.0')
537538
self.assertTrue(regex.search(modtxt), "Pattern '%s' found in: %s" % (regex.pattern, modtxt))
538539

539540
def test_extensions_templates(self):

0 commit comments

Comments
 (0)
Please sign in to comment.