module_file_support: update format for configuration (#27598)

This commit is contained in:
Maxim Belkin 2021-11-25 01:41:32 -06:00 committed by GitHub
parent 90b4f55001
commit 6e095a9741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -273,29 +273,30 @@ of the installed software. For instance, in the snippet below:
.. code-block:: yaml .. code-block:: yaml
modules: modules:
tcl: default:
# The keyword `all` selects every package tcl:
all: # The keyword `all` selects every package
environment: all:
set: environment:
BAR: 'bar' set:
# This anonymous spec selects any package that BAR: 'bar'
# depends on openmpi. The double colon at the # This anonymous spec selects any package that
# end clears the set of rules that matched so far. # depends on openmpi. The double colon at the
^openmpi:: # end clears the set of rules that matched so far.
environment: ^openmpi::
set: environment:
BAR: 'baz' set:
# Selects any zlib package BAR: 'baz'
zlib: # Selects any zlib package
environment: zlib:
prepend_path: environment:
LD_LIBRARY_PATH: 'foo' prepend_path:
# Selects zlib compiled with gcc@4.8 LD_LIBRARY_PATH: 'foo'
zlib%gcc@4.8: # Selects zlib compiled with gcc@4.8
environment: zlib%gcc@4.8:
unset: environment:
- FOOBAR unset:
- FOOBAR
you are instructing Spack to set the environment variable ``BAR=bar`` for every module, you are instructing Spack to set the environment variable ``BAR=bar`` for every module,
unless the associated spec satisfies ``^openmpi`` in which case ``BAR=baz``. unless the associated spec satisfies ``^openmpi`` in which case ``BAR=baz``.
@ -322,9 +323,10 @@ your system. If you write a configuration file like:
.. code-block:: yaml .. code-block:: yaml
modules: modules:
tcl: default:
whitelist: ['gcc', 'llvm'] # Whitelist will have precedence over blacklist tcl:
blacklist: ['%gcc@4.4.7'] # Assuming gcc@4.4.7 is the system compiler whitelist: ['gcc', 'llvm'] # Whitelist will have precedence over blacklist
blacklist: ['%gcc@4.4.7'] # Assuming gcc@4.4.7 is the system compiler
you will prevent the generation of module files for any package that you will prevent the generation of module files for any package that
is compiled with ``gcc@4.4.7``, with the only exception of any ``gcc`` is compiled with ``gcc@4.4.7``, with the only exception of any ``gcc``
@ -349,8 +351,9 @@ shows how to set hash length in the module file names:
.. code-block:: yaml .. code-block:: yaml
modules: modules:
tcl: default:
hash_length: 7 tcl:
hash_length: 7
To help make module names more readable, and to help alleviate name conflicts To help make module names more readable, and to help alleviate name conflicts
with a short hash, one can use the ``suffixes`` option in the modules with a short hash, one can use the ``suffixes`` option in the modules
@ -360,11 +363,12 @@ For instance, the following config options,
.. code-block:: yaml .. code-block:: yaml
modules: modules:
tcl: default:
all: tcl:
suffixes: all:
^python@2.7.12: 'python-2.7.12' suffixes:
^openblas: 'openblas' ^python@2.7.12: 'python-2.7.12'
^openblas: 'openblas'
will add a ``python-2.7.12`` version string to any packages compiled with will add a ``python-2.7.12`` version string to any packages compiled with
python matching the spec, ``python@2.7.12``. This is useful to know which python matching the spec, ``python@2.7.12``. This is useful to know which
@ -379,10 +383,11 @@ covered in :ref:`adding_projections_to_views`.
.. code-block:: yaml .. code-block:: yaml
modules: modules:
tcl: default:
projections: tcl:
all: '{name}/{version}-{compiler.name}-{compiler.version}-module' projections:
^mpi: '{name}/{version}-{^mpi.name}-{^mpi.version}-{compiler.name}-{compiler.version}-module' all: '{name}/{version}-{compiler.name}-{compiler.version}-module'
^mpi: '{name}/{version}-{^mpi.name}-{^mpi.version}-{compiler.name}-{compiler.version}-module'
will create module files that are nested in directories by package will create module files that are nested in directories by package
name, contain the version and compiler name and version, and have the name, contain the version and compiler name and version, and have the
@ -403,15 +408,16 @@ that are already in the LMod hierarchy.
.. code-block:: yaml .. code-block:: yaml
modules: modules:
enable: default:
- tcl enable:
tcl: - tcl
projections: tcl:
all: '{name}/{version}-{compiler.name}-{compiler.version}' projections:
all: all: '{name}/{version}-{compiler.name}-{compiler.version}'
conflict: all:
- '{name}' conflict:
- 'intel/14.0.1' - '{name}'
- 'intel/14.0.1'
will create module files that will conflict with ``intel/14.0.1`` and with the will create module files that will conflict with ``intel/14.0.1`` and with the
base directory of the same module, effectively preventing the possibility to base directory of the same module, effectively preventing the possibility to
@ -431,16 +437,17 @@ that are already in the LMod hierarchy.
.. code-block:: yaml .. code-block:: yaml
modules: modules:
enable: default:
- lmod enable:
lmod: - lmod
core_compilers: lmod:
- 'gcc@4.8' core_compilers:
core_specs: - 'gcc@4.8'
- 'python' core_specs:
hierarchy: - 'python'
- 'mpi' hierarchy:
- 'lapack' - 'mpi'
- 'lapack'
that will generate a hierarchy in which the ``lapack`` and ``mpi`` layer can be switched that will generate a hierarchy in which the ``lapack`` and ``mpi`` layer can be switched
independently. This allows a site to build the same libraries or applications against different independently. This allows a site to build the same libraries or applications against different
@ -591,11 +598,12 @@ do so by using the environment blacklist:
.. code-block:: yaml .. code-block:: yaml
modules: modules:
tcl: default:
all: tcl:
filter: all:
# Exclude changes to any of these variables filter:
environment_blacklist: ['CPATH', 'LIBRARY_PATH'] # Exclude changes to any of these variables
environment_blacklist: ['CPATH', 'LIBRARY_PATH']
The configuration above will generate module files that will not contain The configuration above will generate module files that will not contain
modifications to either ``CPATH`` or ``LIBRARY_PATH``. modifications to either ``CPATH`` or ``LIBRARY_PATH``.
@ -614,9 +622,10 @@ activated using ``spack activate``:
.. code-block:: yaml .. code-block:: yaml
modules: modules:
tcl: default:
^python: tcl:
autoload: 'direct' ^python:
autoload: 'direct'
The configuration file above will produce module files that will The configuration file above will produce module files that will
load their direct dependencies if the package installed depends on ``python``. load their direct dependencies if the package installed depends on ``python``.
@ -633,9 +642,10 @@ The allowed values for the ``autoload`` statement are either ``none``,
.. code-block:: yaml .. code-block:: yaml
modules: modules:
lmod: default:
all: lmod:
autoload: 'direct' all:
autoload: 'direct'
.. note:: .. note::
TCL prerequisites TCL prerequisites