Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable --module-extensions by default (+ resolve template values used in extension version) #4501

Merged
merged 6 commits into from
Aug 28, 2024
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
3 changes: 2 additions & 1 deletion easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,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 @@ -292,7 +292,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 @@ -328,6 +327,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 @@ -816,19 +816,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 @@ -845,18 +846,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 @@ -1261,29 +1251,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 @@ -1294,15 +1279,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 @@ -581,7 +581,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 @@ -522,7 +522,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
Loading