Updates to Configuration Files docs for SC18 (#9801)

Scopes added with -C are now referred to as "custom scopes"
rather than "command line scopes". "command line scope" now refers
to specific config options that are set on the command line (like
"--insecure")
This commit is contained in:
Adam J. Stewart 2018-11-11 12:57:46 -06:00 committed by Peter Scheibel
parent 6141ae49fd
commit d366e642e4
2 changed files with 137 additions and 138 deletions

View File

@ -5,9 +5,9 @@
.. _configuration: .. _configuration:
============================== ===================
Configuration Files in Spack Configuration Files
============================== ===================
Spack has many configuration files. Here is a quick list of them, in Spack has many configuration files. Here is a quick list of them, in
case you want to skip directly to specific docs: case you want to skip directly to specific docs:
@ -19,9 +19,9 @@ case you want to skip directly to specific docs:
* :ref:`packages.yaml <build-settings>` * :ref:`packages.yaml <build-settings>`
* :ref:`repos.yaml <repositories>` * :ref:`repos.yaml <repositories>`
------------------------- -----------
YAML Format YAML Format
------------------------- -----------
Spack configuration files are written in YAML. We chose YAML because Spack configuration files are written in YAML. We chose YAML because
it's human readable, but also versatile in that it supports dictionaries, it's human readable, but also versatile in that it supports dictionaries,
@ -39,45 +39,47 @@ Here is an example ``config.yaml`` file:
- $tempdir - $tempdir
- /nfs/tmp2/$user - /nfs/tmp2/$user
Each spack configuration files is nested under a top-level section Each Spack configuration file is nested under a top-level section
corresponding to its name. So, ``config.yaml`` starts with ``config:``, corresponding to its name. So, ``config.yaml`` starts with ``config:``,
and ``mirrors.yaml`` starts with ``mirrors:``, etc. ``mirrors.yaml`` starts with ``mirrors:``, etc.
.. _configuration-scopes: .. _configuration-scopes:
------------------------- --------------------
Configuration Scopes Configuration Scopes
------------------------- --------------------
Spack pulls configuration data from files in several directories. There Spack pulls configuration data from files in several directories. There
are four configuration scopes. From lowest to highest: are six configuration scopes. From lowest to highest:
#. **defaults**: Stored in ``$(prefix)/etc/spack/defaults/``. These are #. **defaults**: Stored in ``$(prefix)/etc/spack/defaults/``. These are
the "factory" settings. Users should generally not modify the settings the "factory" settings. Users should generally not modify the settings
here, but should override them in other configuration scopes. The here, but should override them in other configuration scopes. The
defaults here will change from version to version of Spack. defaults here will change from version to version of Spack.
#. **system**: Stored in ``/etc/spack``. These are settings for this #. **system**: Stored in ``/etc/spack/``. These are settings for this
machine, or for all machines on which this file system is machine, or for all machines on which this file system is
mounted. The site scope can be used for settings idiosyncratic to a mounted. The site scope can be used for settings idiosyncratic to a
particular machine, such as the locations of compilers or external particular machine, such as the locations of compilers or external
packages. These settings are presumably controlled by someone with packages. These settings are presumably controlled by someone with
root access on the machine. root access on the machine. They override the defaults scope.
#. **site**: Stored in ``$(prefix)/etc/spack/``. Settings here affect #. **site**: Stored in ``$(prefix)/etc/spack/``. Settings here affect
only *this instance* of Spack, and they override defaults. The site only *this instance* of Spack, and they override the defaults and system
scope can can be used for per-project settings (one spack instance per scopes. The site scope can can be used for per-project settings (one
project) or for site-wide settings on a multi-user machine (e.g., for Spack instance per project) or for site-wide settings on a multi-user
a common spack instance). machine (e.g., for a common Spack instance).
3. **user**: Stored in the home directory: ``~/.spack/``. These settings #. **user**: Stored in the home directory: ``~/.spack/``. These settings
affect all instances of Spack and take higher precedence than site or affect all instances of Spack and take higher precedence than site,
default scopes. system, or defaults scopes.
3. **command line**: Optionally specified by the user on the command #. **custom**: Stored in a custom directory specified by ``--config-scope``.
line. These settings take the highest precedence. If multiple If multiple scopes are listed on the command line, they are ordered
scopes are listed on the command line, they are ordered from lowest from lowest to highest precedence.
to highest precedence.
#. **command line**: Build settings specified on the command line take
precedence over all other scopes.
Each configuration directory may contain several configuration files, Each configuration directory may contain several configuration files,
such as ``config.yaml``, ``compilers.yaml``, or ``mirrors.yaml``. When such as ``config.yaml``, ``compilers.yaml``, or ``mirrors.yaml``. When
@ -86,49 +88,48 @@ lower-precedence settings.
Commands that modify scopes (e.g., ``spack compilers``, ``spack repo``, Commands that modify scopes (e.g., ``spack compilers``, ``spack repo``,
etc.) take a ``--scope=<name>`` parameter that you can use to control etc.) take a ``--scope=<name>`` parameter that you can use to control
which scope is modified. By default they modify the highest-precedence which scope is modified. By default, they modify the highest-precedence
scope. scope.
.. _command-line-scopes: .. _custom-scopes:
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^
Command-line Scopes Custom scopes
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^
In addition to the ``system``, ``site``, and ``user`` scopes, you may add In addition to the ``defaults``, ``system``, ``site``, and ``user``
configuration scopes directly on the command line with the scopes, you may add configuration scopes directly on the command
``--config-scope`` argument, or ``-C`` for short. line with the ``--config-scope`` argument, or ``-C`` for short.
For example, the following adds two configuration scopes, named `scopea` For example, the following adds two configuration scopes, named
and `scopeb`, to a `spack spec` command: ``scopea`` and ``scopeb``, to a ``spack spec`` command:
.. code-block:: console .. code-block:: console
$ spack -C ~/myscopes/scopea -C ~/myscopes/scopeb spec ncurses $ spack -C ~/myscopes/scopea -C ~/myscopes/scopeb spec ncurses
Command-line scopes come *after* the ``spack`` command and *before* the Custom scopes come *after* the ``spack`` command and *before* the
subcommand, and they specify a single path to a directory full of subcommand, and they specify a single path to a directory full of
configuration files. You can add the same configuration files to that configuration files. You can add the same configuration files to that
directory that you can add to any other sope (``config.yaml``, directory that you can add to any other scope (``config.yaml``,
``packages.yaml``, etc.). ``packages.yaml``, etc.).
If multiple scopes are provided: If multiple scopes are provided:
1. each must be preceded with the ``--config-scope`` or ``-C`` flag. #. Each must be preceded with the ``--config-scope`` or ``-C`` flag.
2. they must be ordered from lowest to highest precedence. #. They must be ordered from lowest to highest precedence.
""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""
Example: scopes for release and development Example: scopes for release and development
""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""
suppose that you need to support simultaneous building of release and Suppose that you need to support simultaneous building of release and
development versions of a `mypackage`, where `mypackage` -> `A` -> `B`. development versions of ``mypackage``, where ``mypackage`` -> ``A`` -> ``B``.
You could create The following files: You could create The following files:
.. code-block:: yaml .. code-block:: yaml
:caption: ~/myscopes/release/packages.yaml
~/myscopes/release/packages.yaml
--------------------------------
packages: packages:
mypackage: mypackage:
version: [1.7] version: [1.7]
@ -138,9 +139,8 @@ You could create The following files:
version: [0.8] version: [0.8]
.. code-block:: yaml .. code-block:: yaml
:caption: ~/myscopes/develop/packages.yaml
~/myscopes/develop/packages.yaml
--------------------------------
packages: packages:
mypackage: mypackage:
version: [develop] version: [develop]
@ -159,16 +159,15 @@ you want to build all of these packages at the ``develop`` version.
Example: swapping MPI providers Example: swapping MPI providers
""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""
Suppose that you need to build two software packages, `packagea` and Suppose that you need to build two software packages, ``packagea`` and
`packageb`. PackageA is Python2-based and PackageB is Python3-based. ``packageb``. ``packagea`` is Python 2-based and ``packageb`` is Python
PackageA only builds with OpenMPI and PackageB only builds with MPICH. 3-based. ``packagea`` only builds with OpenMPI and ``packageb`` only builds
You can create different configuration scopes for use with Package A and with MPICH. You can create different configuration scopes for use with
B: ``packagea`` and ``packageb``:
.. code-block:: yaml .. code-block:: yaml
:caption: ~/myscopes/packgea/packages.yaml
~/myscopes/packgea/packages.yaml
--------------------------------
packages: packages:
python: python:
version: [2.7.11] version: [2.7.11]
@ -177,9 +176,8 @@ B:
mpi: [openmpi] mpi: [openmpi]
.. code-block:: yaml .. code-block:: yaml
:caption: ~/myscopes/packageb/packages.yaml
~/myscopes/packageb/packages.yaml
--------------------------------
packages: packages:
python: python:
version: [3.5.2] version: [3.5.2]
@ -188,39 +186,40 @@ B:
mpi: [mpich] mpi: [mpich]
.. _platform-scopes: .. _platform-scopes:
------------------------- ------------------------
Platform-specific scopes Platform-specific Scopes
------------------------- ------------------------
For each scope above, there can *also* be platform-specific settings. For each scope above, there can also be platform-specific settings.
For example, on Blue Gene/Q machines, Spack needs to know the location For example, on most platforms, GCC is the preferred compiler.
of cross-compilers for the compute nodes. This configuration is in However, on macOS (darwin), Clang often works for more packages,
``etc/spack/defaults/bgq/compilers.yaml``. It will take precedence and is set as the default compiler. This configuration is set in
over settings in the ``defaults`` scope, but can still be overridden ``$(prefix)/etc/spack/defaults/darwin/packages.yaml``. It will take
by settings in ``system``, ``system/bgq``, ``site``, ``site/bgq``, precedence over settings in the ``defaults`` scope, but can still be
``user``, or ``user/bgq``. So, the full scope precedence is: overridden by settings in ``system``, ``system/darwin``, ``site``,
``site/darwin``, ``user``, ``user/darwin``, ``custom``, or
``custom/darwin``. So, the full scope precedence is:
1. ``defaults`` #. ``defaults``
2. ``defaults/<platform>`` #. ``defaults/<platform>``
3. ``system`` #. ``system``
4. ``system/<platform>`` #. ``system/<platform>``
5. ``site`` #. ``site``
6. ``site/<platform>`` #. ``site/<platform>``
7. ``user`` #. ``user``
8. ``user/<platform>`` #. ``user/<platform>``
9. ``command-line`` #. ``custom``
10. ``command-line/<platform>`` #. ``custom/<platform>``
You can get the name to use for ``<platform>`` by running ``spack arch You can get the name to use for ``<platform>`` by running ``spack arch
--platform``. The system config scope has a ``<platform>`` section for --platform``. The system config scope has a ``<platform>`` section for
sites at which ``/etc`` is mounted on multiple heterogeneous machines. sites at which ``/etc`` is mounted on multiple heterogeneous machines.
------------------------- ----------------
Scope precedence Scope Precedence
------------------------- ----------------
When spack queries for configuration parameters, it searches in When spack queries for configuration parameters, it searches in
higher-precedence scopes first. So, settings in a higher-precedence file higher-precedence scopes first. So, settings in a higher-precedence file
@ -230,16 +229,15 @@ lower-precedence settings. Completely ignoring higher-level configuration
options is supported with the ``::`` notation for keys (see options is supported with the ``::`` notation for keys (see
:ref:`config-overrides` below). :ref:`config-overrides` below).
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^
Simple keys Simple keys
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^
Let's look at an example of overriding a single key in a Spack file. If Let's look at an example of overriding a single key in a Spack file. If
your configurations look like this: your configurations look like this:
**defaults** scope:
.. code-block:: yaml .. code-block:: yaml
:caption: $(prefix)/etc/spack/defaults/config.yaml
config: config:
install_tree: $spack/opt/spack install_tree: $spack/opt/spack
@ -249,13 +247,14 @@ your configurations look like this:
- $tempdir - $tempdir
- /nfs/tmp2/$user - /nfs/tmp2/$user
**site** scope:
.. code-block:: yaml .. code-block:: yaml
:caption: ~/.spack/config.yaml
config: config:
install_tree: /some/other/directory install_tree: /some/other/directory
Spack will only override ``install_tree`` in the ``config`` section, and Spack will only override ``install_tree`` in the ``config`` section, and
will take the site preferences for other settings. You can see the will take the site preferences for other settings. You can see the
final, combined configuration with the ``spack config get <configtype>`` final, combined configuration with the ``spack config get <configtype>``
@ -272,7 +271,7 @@ command:
build_stage: build_stage:
- $tempdir - $tempdir
- /nfs/tmp2/$user - /nfs/tmp2/$user
$ _
.. _config-overrides: .. _config-overrides:
@ -280,14 +279,14 @@ command:
Overriding entire sections Overriding entire sections
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
Above, the site ``config.yaml`` only overrides specific settings in the Above, the user ``config.yaml`` only overrides specific settings in the
default ``config.yaml``. Sometimes, it is useful to *completely* default ``config.yaml``. Sometimes, it is useful to *completely*
override lower-precedence settings. To do this, you can use *two* colons override lower-precedence settings. To do this, you can use *two* colons
at the end of a key in a configuration file. For example, if the at the end of a key in a configuration file. For example:
**site** ``config.yaml`` above looks like this:
.. code-block:: yaml .. code-block:: yaml
:emphasize-lines: 1 :emphasize-lines: 1
:caption: ~/.spack/config.yaml
config:: config::
install_tree: /some/other/directory install_tree: /some/other/directory
@ -301,33 +300,34 @@ Spack will ignore all lower-precedence configuration under the
config: config:
install_tree: /some/other/directory install_tree: /some/other/directory
^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^
List-valued settings List-valued settings
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
Let's revisit the ``config.yaml`` example one more time. The Let's revisit the ``config.yaml`` example one more time. The
``build_stage`` setting's value is an ordered list of directories: ``build_stage`` setting's value is an ordered list of directories:
**defaults**
.. code-block:: yaml .. code-block:: yaml
:caption: $(prefix)/etc/spack/defaults/config.yaml
build_stage: build_stage:
- $tempdir - $tempdir
- /nfs/tmp2/$user - /nfs/tmp2/$user
Suppose the user configuration adds its *own* list of ``build_stage`` Suppose the user configuration adds its *own* list of ``build_stage``
paths: paths:
**user**
.. code-block:: yaml .. code-block:: yaml
:caption: ~/.spack/config.yaml
build_stage: build_stage:
- /lustre-scratch/$user - /lustre-scratch/$user
- ~/mystage - ~/mystage
Spack will first look at the paths in the site ``config.yaml``, then the
Spack will first look at the paths in the defaults ``config.yaml``, then the
paths in the user's ``~/.spack/config.yaml``. The list in the paths in the user's ``~/.spack/config.yaml``. The list in the
higher-precedence scope is *prepended* to the defaults. ``spack config higher-precedence scope is *prepended* to the defaults. ``spack config
get config`` shows the result: get config`` shows the result:
@ -345,21 +345,21 @@ get config`` shows the result:
- ~/mystage - ~/mystage
- $tempdir - $tempdir
- /nfs/tmp2/$user - /nfs/tmp2/$user
$ _
As in :ref:`config-overrides`, the higher-precedence scope can As in :ref:`config-overrides`, the higher-precedence scope can
*completely* override the lower-precedence scope using `::`. So if the *completely* override the lower-precedence scope using ``::``. So if the
user config looked like this: user config looked like this:
**user**
.. code-block:: yaml .. code-block:: yaml
:emphasize-lines: 1 :emphasize-lines: 1
:caption: ~/.spack/config.yaml
build_stage:: build_stage::
- /lustre-scratch/$user - /lustre-scratch/$user
- ~/mystage - ~/mystage
The merged configuration would look like this: The merged configuration would look like this:
.. code-block:: console .. code-block:: console
@ -373,21 +373,20 @@ The merged configuration would look like this:
build_stage: build_stage:
- /lustre-scratch/$user - /lustre-scratch/$user
- ~/mystage - ~/mystage
$ _
.. _config-file-variables: .. _config-file-variables:
------------------------------ ---------------------
Config file variables Config File Variables
------------------------------ ---------------------
Spack understands several variables which can be used in config file Spack understands several variables which can be used in config file
paths wherever they appear. There are three sets of these variables, paths wherever they appear. There are three sets of these variables:
Spack specific variables, environment variables, and user path Spack-specific variables, environment variables, and user path
variables. Spack specific variables and environment variables both are variables. Spack-specific variables and environment variables are both
indicated by prefixing the variable name with ``$``. User path variables indicated by prefixing the variable name with ``$``. User path variables
are indicated at the start of the path with ``~`` or ``~user``. See below are indicated at the start of the path with ``~`` or ``~user``.
for more details.
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
Spack-specific variables Spack-specific variables
@ -395,7 +394,7 @@ Spack-specific variables
Spack understands several special variables. These are: Spack understands several special variables. These are:
* ``$spack``: path to the prefix of this spack installation * ``$spack``: path to the prefix of this Spack installation
* ``$tempdir``: default system temporary directory (as specified in * ``$tempdir``: default system temporary directory (as specified in
Python's `tempfile.tempdir Python's `tempfile.tempdir
<https://docs.python.org/2/library/tempfile.html#tempfile.tempdir>`_ <https://docs.python.org/2/library/tempfile.html#tempfile.tempdir>`_
@ -413,8 +412,8 @@ not be used.
Environment variables Environment variables
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
After spack-specific variables are evaluated, environment variables are After Spack-specific variables are evaluated, environment variables are
expanded. These are formatted like spack-specific variables, e.g., expanded. These are formatted like Spack-specific variables, e.g.,
``${varname}``. You can use this to insert environment variables in your ``${varname}``. You can use this to insert environment variables in your
Spack configuration. Spack configuration.
@ -422,14 +421,14 @@ Spack configuration.
User home directories User home directories
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
Spack performs unix-style tilde expansion on paths in configuration Spack performs Unix-style tilde expansion on paths in configuration
files. This means that tilde (``~``) will expand to the current user's files. This means that tilde (``~``) will expand to the current user's
home directory, and ``~user`` will expand to a specified user's home home directory, and ``~user`` will expand to a specified user's home
directory. The ``~`` must appear at the beginning of the path, or Spack directory. The ``~`` must appear at the beginning of the path, or Spack
will not expand it. will not expand it.
---------------------------- ----------------------------
Seeing Spack's configuration Seeing Spack's Configuration
---------------------------- ----------------------------
With so many scopes overriding each other, it can sometimes be difficult With so many scopes overriding each other, it can sometimes be difficult
@ -527,6 +526,6 @@ down the problem:
You can see above that the ``build_jobs`` and ``debug`` settings are You can see above that the ``build_jobs`` and ``debug`` settings are
built in and are not overridden by a configuration file. The built in and are not overridden by a configuration file. The
``verify_ssl`` setting comes from the ``--insceure`` option on the ``verify_ssl`` setting comes from the ``--insceure`` option on the
command line. ``dirty`` and ``install_tree`` come from the command-line command line. ``dirty`` and ``install_tree`` come from the custom
scopes ``./my-scope`` and ``./my-scope-2``, and all other configuration scopes ``./my-scope`` and ``./my-scope-2``, and all other configuration
options come from the default configuration files that ship with Spack. options come from the default configuration files that ship with Spack.

View File

@ -325,7 +325,7 @@ def make_argument_parser(**kwargs):
help="when to colorize output (default: auto)") help="when to colorize output (default: auto)")
parser.add_argument( parser.add_argument(
'-C', '--config-scope', dest='config_scopes', action='append', '-C', '--config-scope', dest='config_scopes', action='append',
metavar='DIR', help="use an additional configuration scope") metavar='DIR', help="add a custom configuration scope")
parser.add_argument( parser.add_argument(
'-d', '--debug', action='store_true', '-d', '--debug', action='store_true',
help="write out debug logs during compile") help="write out debug logs during compile")