diff --git a/lib/spack/docs/module_file_support.rst b/lib/spack/docs/module_file_support.rst index fad1e414fca..80e3c2ee668 100644 --- a/lib/spack/docs/module_file_support.rst +++ b/lib/spack/docs/module_file_support.rst @@ -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. diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py index 7875ab55616..c770564eddd 100644 --- a/lib/spack/spack/modules/common.py +++ b/lib/spack/spack/modules/common.py @@ -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 diff --git a/lib/spack/spack/test/data/modules/tcl/suffix-format.yaml b/lib/spack/spack/test/data/modules/tcl/suffix-format.yaml new file mode 100644 index 00000000000..00328cb0019 --- /dev/null +++ b/lib/spack/spack/test/data/modules/tcl/suffix-format.yaml @@ -0,0 +1,9 @@ +enable: + - tcl +tcl: + all: + autoload: none + mpileaks: + suffixes: + mpileaks: 'debug={variants.debug.value}' + '^mpi': 'mpi={^mpi.name}-v{^mpi.version}' diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py index 6e0fd5c1a54..d2a8b18b67a 100644 --- a/lib/spack/spack/test/modules/tcl.py +++ b/lib/spack/spack/test/modules/tcl.py @@ -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."""