Skip to content

Commit

Permalink
Merge pull request #4501 from Micket/modextensionstrue
Browse files Browse the repository at this point in the history
enable `--module-extensions` by default (+ resolve template values used in extension version)
  • Loading branch information
boegel authored Aug 28, 2024
2 parents f8c9913 + ac9ddea commit 2e61f32
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 42 deletions.
3 changes: 2 additions & 1 deletion easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,8 @@ def _make_extension_list(self):
if isinstance(ext, str):
exts_list.append((resolve_template(ext, self.cfg.template_values), ))
else:
exts_list.append((resolve_template(ext[0], self.cfg.template_values), ext[1]))
exts_list.append((resolve_template(ext[0], self.cfg.template_values),
resolve_template(ext[1], self.cfg.template_values)))
return exts_list

def make_extension_string(self, name_version_sep='-', ext_sep=', ', sort=True):
Expand Down
2 changes: 1 addition & 1 deletion easybuild/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
'install_latest_eb_release',
'logtostdout',
'minimal_toolchains',
'module_extensions',
'module_only',
'package',
'parallel_extensions_install',
Expand Down Expand Up @@ -330,6 +329,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
'lib64_fallback_sanity_check',
'lib64_lib_symlink',
'map_toolchains',
'module_extensions',
'modules_tool_version_check',
'mpi_tests',
'pre_create_installdir',
Expand Down
53 changes: 15 additions & 38 deletions easybuild/tools/module_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,19 +826,20 @@ def get_description(self, conflict=True):
"""
Generate a description.
"""
txt = '\n'.join([
lines = [
"proc ModulesHelp { } {",
" puts stderr {%s" % re.sub(r'([{}\[\]])', r'\\\1', self._generate_help_text()),
" }",
'}',
'',
]

lines.extend([
"module-whatis {%s}" % re.sub(r'([{}\[\]])', r'\\\1', line)
for line in self._generate_whatis_lines()
])

lines = [
'%(whatis_lines)s',
'',
"set root %(installdir)s",
]
lines.extend(['', "set root " + self.app.installdir])

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

whatis_lines = [
"module-whatis {%s}" % re.sub(r'([{}\[\]])', r'\\\1', line)
for line in self._generate_whatis_lines()
]
txt += '\n'.join([''] + lines + ['']) % {
'name': self.app.name,
'version': self.app.version,
'whatis_lines': '\n'.join(whatis_lines),
'installdir': self.app.installdir,
}

return txt
return '\n'.join(lines + [''])

def getenv_cmd(self, envvar, default=None):
"""
Expand Down Expand Up @@ -1273,29 +1263,24 @@ def get_description(self, conflict=True):
"""
Generate a description.
"""
txt = '\n'.join([
lines = [
'help(%s%s' % (self.START_STR, self.check_str(self._generate_help_text())),
'%s)' % self.END_STR,
'',
])

lines = [
"%(whatis_lines)s",
'',
'local root = "%(installdir)s"',
]

for line in self._generate_whatis_lines():
lines.append("whatis(%s%s%s)" % (self.START_STR, self.check_str(line), self.END_STR))

lines.extend(['', 'local root = "%s"' % self.app.installdir])

if self.app.cfg['moduleloadnoconflict']:
self.log.info("Nothing to do to ensure no conflicts can occur on load when using Lua modules files/Lmod")

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

whatis_lines = []
for line in self._generate_whatis_lines():
whatis_lines.append("whatis(%s%s%s)" % (self.START_STR, self.check_str(line), self.END_STR))

if build_option('module_extensions'):
extensions_list = self._generate_extensions_list()

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

txt += '\n'.join([''] + lines + ['']) % {
'name': self.app.name,
'version': self.app.version,
'whatis_lines': '\n'.join(whatis_lines),
'installdir': self.app.installdir,
'homepage': self.app.cfg['homepage'],
}

return txt
return '\n'.join(lines + [''])

def getenv_cmd(self, envvar, default=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def config_options(self):
"(implies recursive unloading of modules).",
None, 'store_true', False),
'module-extensions': ("Include 'extensions' statement in generated module file (Lua syntax only)",
None, 'store_true', False),
None, 'store_true', True),
'module-naming-scheme': ("Module naming scheme to use", None, 'store', DEFAULT_MNS),
'module-syntax': ("Syntax to be used for module files", 'choice', 'store', DEFAULT_MODULE_SYNTAX,
sorted(avail_module_generators().keys())),
Expand Down
3 changes: 2 additions & 1 deletion test/framework/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,8 @@ def test_exts_list(self):
with self.mocked_stdout_stderr():
modfile = os.path.join(eb.make_module_step(), 'PI', '3.14' + eb.module_generator.MODULE_FILE_EXTENSION)
modtxt = read_file(modfile)
regex = re.compile('EBEXTSLISTPI.*ext1-1.0,ext2-2.0')
# verify that templates used for extensions are resolved as they should
regex = re.compile('EBEXTSLISTPI.*"ext1-1.0,ext2-2.0,ext-PI-3.14,ext-pi-3.0')
self.assertTrue(regex.search(modtxt), "Pattern '%s' found in: %s" % (regex.pattern, modtxt))

def test_extensions_templates(self):
Expand Down

0 comments on commit 2e61f32

Please sign in to comment.