summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJordan Galby <67924449+Jordan474@users.noreply.github.com>2024-10-21 09:08:59 +0200
committerGitHub <noreply@github.com>2024-10-21 09:08:59 +0200
commite5a602c1bb39555a5e1440bbe1268fc7aea08459 (patch)
tree6f9eff13ce5b3c31d6ab9f10549642a1317211c2 /lib
parent37fe3b498430ae9c11b60166ed04f5eb602acd5b (diff)
downloadspack-e5a602c1bb39555a5e1440bbe1268fc7aea08459.tar.gz
spack-e5a602c1bb39555a5e1440bbe1268fc7aea08459.tar.bz2
spack-e5a602c1bb39555a5e1440bbe1268fc7aea08459.tar.xz
spack-e5a602c1bb39555a5e1440bbe1268fc7aea08459.zip
Modules suffixes config are now spec format strings (#38411)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/docs/module_file_support.rst6
-rw-r--r--lib/spack/spack/modules/common.py3
-rw-r--r--lib/spack/spack/test/data/modules/tcl/suffix-format.yaml9
-rw-r--r--lib/spack/spack/test/modules/tcl.py8
4 files changed, 22 insertions, 4 deletions
diff --git a/lib/spack/docs/module_file_support.rst b/lib/spack/docs/module_file_support.rst
index fad1e414fc..80e3c2ee66 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 7875ab5561..c770564edd 100644
--- a/lib/spack/spack/modules/common.py
+++ b/lib/spack/spack/modules/common.py
@@ -527,7 +527,8 @@ class BaseFileLayout:
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 0000000000..00328cb001
--- /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 6e0fd5c1a5..d2a8b18b67 100644
--- a/lib/spack/spack/test/modules/tcl.py
+++ b/lib/spack/spack/test/modules/tcl.py
@@ -377,6 +377,14 @@ class TestTcl:
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."""