Modules suffixes config are now spec format strings (#38411)

This commit is contained in:
Jordan Galby 2024-10-21 09:08:59 +02:00 committed by GitHub
parent 37fe3b4984
commit e5a602c1bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 4 deletions

View File

@ -457,11 +457,11 @@ For instance, the following config options,
tcl:
all:
suffixes:
^python@3.12: 'python-3.12'
^python@3: 'python{^python.version}'
^openblas: 'openblas'
will add a ``python-3.12`` version string to any packages compiled with
Python matching the spec, ``python@3.12``. This is useful to know which
will add a ``python-3.12.1`` version string to any packages compiled with
Python matching the spec, ``python@3``. This is useful to know which
version of Python a set of Python extensions is associated with. Likewise, the
``openblas`` string is attached to any program that has openblas in the spec,
most likely via the ``+blas`` variant specification.

View File

@ -527,7 +527,8 @@ def use_name(self):
parts = name.split("/")
name = os.path.join(*parts)
# Add optional suffixes based on constraints
path_elements = [name] + self.conf.suffixes
path_elements = [name]
path_elements.extend(map(self.spec.format, self.conf.suffixes))
return "-".join(path_elements)
@property

View File

@ -0,0 +1,9 @@
enable:
- tcl
tcl:
all:
autoload: none
mpileaks:
suffixes:
mpileaks: 'debug={variants.debug.value}'
'^mpi': 'mpi={^mpi.name}-v{^mpi.version}'

View File

@ -377,6 +377,14 @@ def test_suffixes(self, module_configuration, factory):
writer, spec = factory("mpileaks~debug+opt target=x86_64")
assert "baz-foo-bar" in writer.layout.use_name
def test_suffixes_format(self, module_configuration, factory):
"""Tests adding suffixes as spec format string to module file name."""
module_configuration("suffix-format")
writer, spec = factory("mpileaks +debug target=x86_64 ^mpich@3.0.4")
assert "debug=True" in writer.layout.use_name
assert "mpi=mpich-v3.0.4" in writer.layout.use_name
def test_setup_environment(self, modulefile_content, module_configuration):
"""Tests the internal set-up of run-time environment."""