2023-01-19 06:30:17 +08:00
|
|
|
.. Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
|
2019-03-29 10:23:16 +08:00
|
|
|
Spack Project Developers. See the top-level COPYRIGHT file for details.
|
|
|
|
|
|
|
|
SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
|
|
|
|
.. _environments:
|
|
|
|
|
2022-04-20 21:00:43 +08:00
|
|
|
=========================
|
|
|
|
Environments (spack.yaml)
|
|
|
|
=========================
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
An environment is used to group together a set of specs for the
|
|
|
|
purpose of building, rebuilding and deploying in a coherent fashion.
|
2019-07-24 06:42:16 +08:00
|
|
|
Environments provide a number of advantages over the *à la carte*
|
2019-03-29 10:23:16 +08:00
|
|
|
approach of building and loading individual Spack modules:
|
|
|
|
|
|
|
|
#. Environments separate the steps of (a) choosing what to
|
|
|
|
install, (b) concretizing, and (c) installing. This allows
|
|
|
|
Environments to remain stable and repeatable, even if Spack packages
|
|
|
|
are upgraded: specs are only re-concretized when the user
|
2019-07-24 06:42:16 +08:00
|
|
|
explicitly asks for it. It is even possible to reliably
|
2019-03-29 10:23:16 +08:00
|
|
|
transport environments between different computers running
|
|
|
|
different versions of Spack!
|
|
|
|
#. Environments allow several specs to be built at once; a more robust
|
|
|
|
solution than ad-hoc scripts making multiple calls to ``spack
|
|
|
|
install``.
|
|
|
|
#. An Environment that is built as a whole can be loaded as a whole
|
2019-07-24 06:42:16 +08:00
|
|
|
into the user environment. An Environment can be built to maintain
|
2019-03-29 10:23:16 +08:00
|
|
|
a filesystem view of its packages, and the environment can load
|
|
|
|
that view into the user environment at activation time. Spack can
|
|
|
|
also generate a script to load all modules related to an
|
|
|
|
environment.
|
|
|
|
|
|
|
|
Other packaging systems also provide environments that are similar in
|
|
|
|
some ways to Spack environments; for example, `Conda environments
|
|
|
|
<https://conda.io/docs/user-guide/tasks/manage-environments.html>`_ or
|
|
|
|
`Python Virtual Environments
|
|
|
|
<https://docs.python.org/3/tutorial/venv.html>`_. Spack environments
|
|
|
|
provide some distinctive features:
|
|
|
|
|
|
|
|
#. A spec installed "in" an environment is no different from the same
|
|
|
|
spec installed anywhere else in Spack. Environments are assembled
|
|
|
|
simply by collecting together a set of specs.
|
|
|
|
#. Spack Environments may contain more than one spec of the same
|
|
|
|
package.
|
|
|
|
|
|
|
|
Spack uses a "manifest and lock" model similar to `Bundler gemfiles
|
|
|
|
<https://bundler.io/man/gemfile.5.html>`_ and other package
|
|
|
|
managers. The user input file is named ``spack.yaml`` and the lock
|
|
|
|
file is named ``spack.lock``
|
|
|
|
|
2020-01-31 09:19:55 +08:00
|
|
|
.. _environments-using:
|
|
|
|
|
2019-03-29 10:23:16 +08:00
|
|
|
------------------
|
|
|
|
Using Environments
|
|
|
|
------------------
|
|
|
|
|
|
|
|
Here we follow a typical use case of creating, concretizing,
|
|
|
|
installing and loading an environment.
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Creating a named Environment
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
An environment is created by:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack env create myenv
|
|
|
|
|
|
|
|
Spack then creates the directory ``var/spack/environments/myenv``.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
All named environments are stored in the ``var/spack/environments`` folder.
|
|
|
|
|
|
|
|
In the ``var/spack/environments/myenv`` directory, Spack creates the
|
|
|
|
file ``spack.yaml`` and the hidden directory ``.spack-env``.
|
|
|
|
|
|
|
|
Spack stores metadata in the ``.spack-env`` directory. User
|
|
|
|
interaction will occur through the ``spack.yaml`` file and the Spack
|
|
|
|
commands that affect it. When the environment is concretized, Spack
|
|
|
|
will create a file ``spack.lock`` with the concrete information for
|
|
|
|
the environment.
|
|
|
|
|
|
|
|
In addition to being the default location for the view associated with
|
|
|
|
an Environment, the ``.spack-env`` directory also contains:
|
|
|
|
|
|
|
|
* ``repo/``: A repo consisting of the Spack packages used in this
|
|
|
|
environment. This allows the environment to build the same, in
|
2019-07-24 06:42:16 +08:00
|
|
|
theory, even on different versions of Spack with different
|
2019-03-29 10:23:16 +08:00
|
|
|
packages!
|
|
|
|
* ``logs/``: A directory containing the build logs for the packages
|
|
|
|
in this Environment.
|
|
|
|
|
|
|
|
Spack Environments can also be created from either a ``spack.yaml``
|
|
|
|
manifest or a ``spack.lock`` lockfile. To create an Environment from a
|
|
|
|
``spack.yaml`` manifest:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack env create myenv spack.yaml
|
|
|
|
|
|
|
|
To create an Environment from a ``spack.lock`` lockfile:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack env create myenv spack.lock
|
|
|
|
|
|
|
|
Either of these commands can also take a full path to the
|
|
|
|
initialization file.
|
|
|
|
|
|
|
|
A Spack Environment created from a ``spack.yaml`` manifest is
|
|
|
|
guaranteed to have the same root specs as the original Environment,
|
|
|
|
but may concretize differently. A Spack Environment created from a
|
|
|
|
``spack.lock`` lockfile is guaranteed to have the same concrete specs
|
|
|
|
as the original Environment. Either may obviously then differ as the
|
|
|
|
user modifies it.
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Activating an Environment
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
To activate an environment, use the following command:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack env activate myenv
|
|
|
|
|
|
|
|
By default, the ``spack env activate`` will load the view associated
|
|
|
|
with the Environment into the user environment. The ``-v,
|
|
|
|
--with-view`` argument ensures this behavior, and the ``-V,
|
2020-04-20 09:13:44 +08:00
|
|
|
--without-view`` argument activates the environment without changing
|
2019-03-29 10:23:16 +08:00
|
|
|
the user environment variables.
|
|
|
|
|
|
|
|
The ``-p`` option to the ``spack env activate`` command modifies the
|
|
|
|
user's prompt to begin with the environment name in brackets.
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack env activate -p myenv
|
|
|
|
[myenv] $ ...
|
|
|
|
|
|
|
|
To deactivate an environment, use the command:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack env deactivate
|
|
|
|
|
|
|
|
or the shortcut alias
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ despacktivate
|
|
|
|
|
|
|
|
If the environment was activated with its view, deactivating the
|
|
|
|
environment will remove the view from the user environment.
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Anonymous Environments
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
Any directory can be treated as an environment if it contains a file
|
|
|
|
``spack.yaml``. To load an anonymous environment, use:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack env activate -d /path/to/directory
|
|
|
|
|
|
|
|
Anonymous specs can be created in place using the command:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack env create -d .
|
|
|
|
|
|
|
|
In this case Spack simply creates a spack.yaml file in the requested
|
|
|
|
directory.
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Environment Sensitive Commands
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
Spack commands are environment sensitive. For example, the ``find``
|
|
|
|
command shows only the specs in the active Environment if an
|
|
|
|
Environment has been activated. Similarly, the ``install`` and
|
|
|
|
``uninstall`` commands act on the active environment.
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack find
|
|
|
|
==> 0 installed packages
|
|
|
|
|
|
|
|
$ spack install zlib@1.2.11
|
Support parallel environment builds (#18131)
As of #13100, Spack installs the dependencies of a _single_ spec in parallel.
Environments, when installed, can only get parallelism from each individual
spec, as they're installed in order. This PR makes entire environments build
in parallel by extending Spack's package installer to accept multiple root
specs. The install command and Environment class have been updated to use
the new parallel install method.
The specs and kwargs for each *uninstalled* package (when not force-replacing
installations) of an environment are collected, passed to the `PackageInstaller`,
and processed using a single build queue.
This introduces a `BuildRequest` class to track install arguments, and it
significantly cleans up the code used to track package ids during installation.
Package ids in the build queue are now just DAG hashes as you would expect,
Other tasks:
- [x] Finish updating the unit tests based on `PackageInstaller`'s use of
`BuildRequest` and the associated changes
- [x] Change `environment.py`'s `install_all` to use the `PackageInstaller` directly
- [x] Change the `install` command to leverage the new installation process for multiple specs
- [x] Change install output messages for external packages, e.g.:
`[+] /usr` -> `[+] /usr (external bzip2-1.0.8-<dag-hash>`
- [x] Fix incomplete environment install's view setup/update and not confirming all
packages are installed (?)
- [x] Ensure externally installed package dependencies are properly accounted for in
remaining build tasks
- [x] Add tests for coverage (if insufficient and can identity the appropriate, uncovered non-comment lines)
- [x] Add documentation
- [x] Resolve multi-compiler environment install issues
- [x] Fix issue with environment installation reporting (restore CDash/JUnit reports)
2020-11-17 18:41:07 +08:00
|
|
|
==> Installing zlib-1.2.11-q6cqrdto4iktfg6qyqcc5u4vmfmwb7iv
|
|
|
|
==> No binary for zlib-1.2.11-q6cqrdto4iktfg6qyqcc5u4vmfmwb7iv found: installing from source
|
|
|
|
==> zlib: Executing phase: 'install'
|
|
|
|
[+] ~/spack/opt/spack/linux-rhel7-broadwell/gcc-8.1.0/zlib-1.2.11-q6cqrdto4iktfg6qyqcc5u4vmfmwb7iv
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
$ spack env activate myenv
|
|
|
|
|
|
|
|
$ spack find
|
|
|
|
==> In environment myenv
|
|
|
|
==> No root specs
|
|
|
|
==> 0 installed packages
|
|
|
|
|
|
|
|
$ spack install zlib@1.2.8
|
Support parallel environment builds (#18131)
As of #13100, Spack installs the dependencies of a _single_ spec in parallel.
Environments, when installed, can only get parallelism from each individual
spec, as they're installed in order. This PR makes entire environments build
in parallel by extending Spack's package installer to accept multiple root
specs. The install command and Environment class have been updated to use
the new parallel install method.
The specs and kwargs for each *uninstalled* package (when not force-replacing
installations) of an environment are collected, passed to the `PackageInstaller`,
and processed using a single build queue.
This introduces a `BuildRequest` class to track install arguments, and it
significantly cleans up the code used to track package ids during installation.
Package ids in the build queue are now just DAG hashes as you would expect,
Other tasks:
- [x] Finish updating the unit tests based on `PackageInstaller`'s use of
`BuildRequest` and the associated changes
- [x] Change `environment.py`'s `install_all` to use the `PackageInstaller` directly
- [x] Change the `install` command to leverage the new installation process for multiple specs
- [x] Change install output messages for external packages, e.g.:
`[+] /usr` -> `[+] /usr (external bzip2-1.0.8-<dag-hash>`
- [x] Fix incomplete environment install's view setup/update and not confirming all
packages are installed (?)
- [x] Ensure externally installed package dependencies are properly accounted for in
remaining build tasks
- [x] Add tests for coverage (if insufficient and can identity the appropriate, uncovered non-comment lines)
- [x] Add documentation
- [x] Resolve multi-compiler environment install issues
- [x] Fix issue with environment installation reporting (restore CDash/JUnit reports)
2020-11-17 18:41:07 +08:00
|
|
|
==> Installing zlib-1.2.8-yfc7epf57nsfn2gn4notccaiyxha6z7x
|
|
|
|
==> No binary for zlib-1.2.8-yfc7epf57nsfn2gn4notccaiyxha6z7x found: installing from source
|
|
|
|
==> zlib: Executing phase: 'install'
|
|
|
|
[+] ~/spack/opt/spack/linux-rhel7-broadwell/gcc-8.1.0/zlib-1.2.8-yfc7epf57nsfn2gn4notccaiyxha6z7x
|
|
|
|
==> Updating view at ~/spack/var/spack/environments/myenv/.spack-env/view
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
$ spack find
|
|
|
|
==> In environment myenv
|
|
|
|
==> Root specs
|
|
|
|
zlib@1.2.8
|
|
|
|
|
|
|
|
==> 1 installed package
|
Support parallel environment builds (#18131)
As of #13100, Spack installs the dependencies of a _single_ spec in parallel.
Environments, when installed, can only get parallelism from each individual
spec, as they're installed in order. This PR makes entire environments build
in parallel by extending Spack's package installer to accept multiple root
specs. The install command and Environment class have been updated to use
the new parallel install method.
The specs and kwargs for each *uninstalled* package (when not force-replacing
installations) of an environment are collected, passed to the `PackageInstaller`,
and processed using a single build queue.
This introduces a `BuildRequest` class to track install arguments, and it
significantly cleans up the code used to track package ids during installation.
Package ids in the build queue are now just DAG hashes as you would expect,
Other tasks:
- [x] Finish updating the unit tests based on `PackageInstaller`'s use of
`BuildRequest` and the associated changes
- [x] Change `environment.py`'s `install_all` to use the `PackageInstaller` directly
- [x] Change the `install` command to leverage the new installation process for multiple specs
- [x] Change install output messages for external packages, e.g.:
`[+] /usr` -> `[+] /usr (external bzip2-1.0.8-<dag-hash>`
- [x] Fix incomplete environment install's view setup/update and not confirming all
packages are installed (?)
- [x] Ensure externally installed package dependencies are properly accounted for in
remaining build tasks
- [x] Add tests for coverage (if insufficient and can identity the appropriate, uncovered non-comment lines)
- [x] Add documentation
- [x] Resolve multi-compiler environment install issues
- [x] Fix issue with environment installation reporting (restore CDash/JUnit reports)
2020-11-17 18:41:07 +08:00
|
|
|
-- linux-rhel7-broadwell / gcc@8.1.0 ----------------------------
|
2019-03-29 10:23:16 +08:00
|
|
|
zlib@1.2.8
|
|
|
|
|
|
|
|
$ despacktivate
|
Support parallel environment builds (#18131)
As of #13100, Spack installs the dependencies of a _single_ spec in parallel.
Environments, when installed, can only get parallelism from each individual
spec, as they're installed in order. This PR makes entire environments build
in parallel by extending Spack's package installer to accept multiple root
specs. The install command and Environment class have been updated to use
the new parallel install method.
The specs and kwargs for each *uninstalled* package (when not force-replacing
installations) of an environment are collected, passed to the `PackageInstaller`,
and processed using a single build queue.
This introduces a `BuildRequest` class to track install arguments, and it
significantly cleans up the code used to track package ids during installation.
Package ids in the build queue are now just DAG hashes as you would expect,
Other tasks:
- [x] Finish updating the unit tests based on `PackageInstaller`'s use of
`BuildRequest` and the associated changes
- [x] Change `environment.py`'s `install_all` to use the `PackageInstaller` directly
- [x] Change the `install` command to leverage the new installation process for multiple specs
- [x] Change install output messages for external packages, e.g.:
`[+] /usr` -> `[+] /usr (external bzip2-1.0.8-<dag-hash>`
- [x] Fix incomplete environment install's view setup/update and not confirming all
packages are installed (?)
- [x] Ensure externally installed package dependencies are properly accounted for in
remaining build tasks
- [x] Add tests for coverage (if insufficient and can identity the appropriate, uncovered non-comment lines)
- [x] Add documentation
- [x] Resolve multi-compiler environment install issues
- [x] Fix issue with environment installation reporting (restore CDash/JUnit reports)
2020-11-17 18:41:07 +08:00
|
|
|
|
2019-03-29 10:23:16 +08:00
|
|
|
$ spack find
|
|
|
|
==> 2 installed packages
|
Support parallel environment builds (#18131)
As of #13100, Spack installs the dependencies of a _single_ spec in parallel.
Environments, when installed, can only get parallelism from each individual
spec, as they're installed in order. This PR makes entire environments build
in parallel by extending Spack's package installer to accept multiple root
specs. The install command and Environment class have been updated to use
the new parallel install method.
The specs and kwargs for each *uninstalled* package (when not force-replacing
installations) of an environment are collected, passed to the `PackageInstaller`,
and processed using a single build queue.
This introduces a `BuildRequest` class to track install arguments, and it
significantly cleans up the code used to track package ids during installation.
Package ids in the build queue are now just DAG hashes as you would expect,
Other tasks:
- [x] Finish updating the unit tests based on `PackageInstaller`'s use of
`BuildRequest` and the associated changes
- [x] Change `environment.py`'s `install_all` to use the `PackageInstaller` directly
- [x] Change the `install` command to leverage the new installation process for multiple specs
- [x] Change install output messages for external packages, e.g.:
`[+] /usr` -> `[+] /usr (external bzip2-1.0.8-<dag-hash>`
- [x] Fix incomplete environment install's view setup/update and not confirming all
packages are installed (?)
- [x] Ensure externally installed package dependencies are properly accounted for in
remaining build tasks
- [x] Add tests for coverage (if insufficient and can identity the appropriate, uncovered non-comment lines)
- [x] Add documentation
- [x] Resolve multi-compiler environment install issues
- [x] Fix issue with environment installation reporting (restore CDash/JUnit reports)
2020-11-17 18:41:07 +08:00
|
|
|
-- linux-rhel7-broadwell / gcc@8.1.0 ----------------------------
|
2019-03-29 10:23:16 +08:00
|
|
|
zlib@1.2.8 zlib@1.2.11
|
|
|
|
|
Support parallel environment builds (#18131)
As of #13100, Spack installs the dependencies of a _single_ spec in parallel.
Environments, when installed, can only get parallelism from each individual
spec, as they're installed in order. This PR makes entire environments build
in parallel by extending Spack's package installer to accept multiple root
specs. The install command and Environment class have been updated to use
the new parallel install method.
The specs and kwargs for each *uninstalled* package (when not force-replacing
installations) of an environment are collected, passed to the `PackageInstaller`,
and processed using a single build queue.
This introduces a `BuildRequest` class to track install arguments, and it
significantly cleans up the code used to track package ids during installation.
Package ids in the build queue are now just DAG hashes as you would expect,
Other tasks:
- [x] Finish updating the unit tests based on `PackageInstaller`'s use of
`BuildRequest` and the associated changes
- [x] Change `environment.py`'s `install_all` to use the `PackageInstaller` directly
- [x] Change the `install` command to leverage the new installation process for multiple specs
- [x] Change install output messages for external packages, e.g.:
`[+] /usr` -> `[+] /usr (external bzip2-1.0.8-<dag-hash>`
- [x] Fix incomplete environment install's view setup/update and not confirming all
packages are installed (?)
- [x] Ensure externally installed package dependencies are properly accounted for in
remaining build tasks
- [x] Add tests for coverage (if insufficient and can identity the appropriate, uncovered non-comment lines)
- [x] Add documentation
- [x] Resolve multi-compiler environment install issues
- [x] Fix issue with environment installation reporting (restore CDash/JUnit reports)
2020-11-17 18:41:07 +08:00
|
|
|
|
2019-03-29 10:23:16 +08:00
|
|
|
Note that when we installed the abstract spec ``zlib@1.2.8``, it was
|
|
|
|
presented as a root of the Environment. All explicitly installed
|
|
|
|
packages will be listed as roots of the Environment.
|
|
|
|
|
|
|
|
All of the Spack commands that act on the list of installed specs are
|
|
|
|
Environment-sensitive in this way, including ``install``,
|
remove activate/deactivate support in favor of environments (#29317)
Environments and environment views have taken over the role of `spack activate/deactivate`, and we should deprecate these commands for several reasons:
- Global activation is a really poor idea:
- Install prefixes should be immutable; since they can have multiple, unrelated dependents; see below
- Added complexity elsewhere: verification of installations, tarballs for build caches, creation of environment views of packages with unrelated extensions "globally activated"... by removing the feature, it gets easier for people to contribute, and we'd end up with fewer bugs due to edge cases.
- Environment accomplish the same thing for non-global "activation" i.e. `spack view`, but better.
Also we write in the docs:
```
However, Spack global activations have two potential drawbacks:
#. Activated packages that involve compiled C extensions may still
need their dependencies to be loaded manually. For example,
``spack load openblas`` might be required to make ``py-numpy``
work.
#. Global activations "break" a core feature of Spack, which is that
multiple versions of a package can co-exist side-by-side. For example,
suppose you wish to run a Python package in two different
environments but the same basic Python --- one with
``py-numpy@1.7`` and one with ``py-numpy@1.8``. Spack extensions
will not support this potential debugging use case.
```
Now that environments are established and views can take over the role of activation
non-destructively, we can remove global activation/deactivation.
2022-11-11 16:50:07 +08:00
|
|
|
``uninstall``, ``find``, ``extensions``, and more. In the
|
|
|
|
:ref:`environment-configuration` section we will discuss
|
2019-03-29 10:23:16 +08:00
|
|
|
Environment-sensitive commands further.
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Adding Abstract Specs
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
An abstract spec is the user-specified spec before Spack has applied
|
|
|
|
any defaults or dependency information.
|
|
|
|
|
|
|
|
Users can add abstract specs to an Environment using the ``spack add``
|
|
|
|
command. The most important component of an Environment is a list of
|
|
|
|
abstract specs.
|
|
|
|
|
2021-04-23 21:29:19 +08:00
|
|
|
Adding a spec adds to the manifest (the ``spack.yaml`` file), which is
|
|
|
|
used to define the roots of the Environment, but does not affect the
|
|
|
|
concrete specs in the lockfile, nor does it install the spec.
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
The ``spack add`` command is environment aware. It adds to the
|
|
|
|
currently active environment. All environment aware commands can also
|
2020-04-23 04:04:17 +08:00
|
|
|
be called using the ``spack -e`` flag to specify the environment.
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2020-04-07 00:54:22 +08:00
|
|
|
$ spack env activate myenv
|
2019-03-29 10:23:16 +08:00
|
|
|
$ spack add mpileaks
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2020-04-23 04:04:17 +08:00
|
|
|
$ spack -e myenv add python
|
2019-03-29 10:23:16 +08:00
|
|
|
|
2019-10-08 00:53:23 +08:00
|
|
|
.. _environments_concretization:
|
|
|
|
|
2019-03-29 10:23:16 +08:00
|
|
|
^^^^^^^^^^^^
|
|
|
|
Concretizing
|
|
|
|
^^^^^^^^^^^^
|
|
|
|
|
Best effort co-concretization (iterative algorithm) (#28941)
Currently, environments can either be concretized fully together or fully separately. This works well for users who create environments for interoperable software and can use `concretizer:unify:true`. It does not allow environments with conflicting software to be concretized for maximal interoperability.
The primary use-case for this is facilities providing system software. Facilities provide multiple MPI implementations, but all software built against a given MPI ought to be interoperable.
This PR adds a concretization option `concretizer:unify:when_possible`. When this option is used, Spack will concretize specs in the environment separately, but will optimize for minimal differences in overlapping packages.
* Add a level of indirection to root specs
This commit introduce the "literal" atom, which comes with
a few different "arities". The unary "literal" contains an
integer that id the ID of a spec literal. Other "literals"
contain information on the requests made by literal ID. For
instance zlib@1.2.11 generates the following facts:
literal(0,"root","zlib").
literal(0,"node","zlib").
literal(0,"node_version_satisfies","zlib","1.2.11").
This should help with solving large environments "together
where possible" since later literals can be now solved
together in batches.
* Add a mechanism to relax the number of literals being solved
* Modify spack solve to display the new criteria
Since the new criteria is above all the build criteria,
we need to modify the way we display the output.
Originally done by Greg in #27964 and cherry-picked
to this branch by the co-author of the commit.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
* Inject reusable specs into the solve
Instead of coupling the PyclingoDriver() object with
spack.config, inject the concrete specs that can be
reused.
A method level function takes care of reading from
the store and the buildcache.
* spack solve: show output of multi-rounds
* add tests for best-effort coconcretization
* Enforce having at least a literal being solved
Co-authored-by: Greg Becker <becker33@llnl.gov>
2022-05-25 03:13:28 +08:00
|
|
|
Once some user specs have been added to an environment, they can be concretized.
|
|
|
|
There are at the moment three different modes of operation to concretize an environment,
|
|
|
|
which are explained in details in :ref:`environments_concretization_config`.
|
2019-10-08 00:53:23 +08:00
|
|
|
Regardless of which mode of operation has been chosen, the following
|
|
|
|
command will ensure all the root specs are concretized according to the
|
|
|
|
constraints that are prescribed in the configuration:
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
[myenv]$ spack concretize
|
|
|
|
|
2019-10-08 00:53:23 +08:00
|
|
|
In the case of specs that are not concretized together, the command
|
|
|
|
above will concretize only the specs that were added and not yet
|
|
|
|
concretized. Forcing a re-concretization of all the specs can be done
|
|
|
|
instead with this command:
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
[myenv]$ spack concretize -f
|
|
|
|
|
|
|
|
When the ``-f`` flag is not used to reconcretize all specs, Spack
|
|
|
|
guarantees that already concretized specs are unchanged in the
|
|
|
|
environment.
|
|
|
|
|
|
|
|
The ``concretize`` command does not install any packages. For packages
|
|
|
|
that have already been installed outside of the environment, the
|
|
|
|
process of adding the spec and concretizing is identical to installing
|
|
|
|
the spec assuming it concretizes to the exact spec that was installed
|
2019-07-24 06:42:16 +08:00
|
|
|
outside of the environment.
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
The ``spack find`` command can show concretized specs separately from
|
|
|
|
installed specs using the ``-c`` (``--concretized``) flag.
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
[myenv]$ spack add zlib
|
|
|
|
[myenv]$ spack concretize
|
|
|
|
[myenv]$ spack find -c
|
|
|
|
==> In environment myenv
|
|
|
|
==> Root specs
|
|
|
|
zlib
|
|
|
|
|
|
|
|
==> Concretized roots
|
|
|
|
-- linux-rhel7-x86_64 / gcc@4.9.3 -------------------------------
|
|
|
|
zlib@1.2.11
|
|
|
|
|
|
|
|
==> 0 installed packages
|
|
|
|
|
Support parallel environment builds (#18131)
As of #13100, Spack installs the dependencies of a _single_ spec in parallel.
Environments, when installed, can only get parallelism from each individual
spec, as they're installed in order. This PR makes entire environments build
in parallel by extending Spack's package installer to accept multiple root
specs. The install command and Environment class have been updated to use
the new parallel install method.
The specs and kwargs for each *uninstalled* package (when not force-replacing
installations) of an environment are collected, passed to the `PackageInstaller`,
and processed using a single build queue.
This introduces a `BuildRequest` class to track install arguments, and it
significantly cleans up the code used to track package ids during installation.
Package ids in the build queue are now just DAG hashes as you would expect,
Other tasks:
- [x] Finish updating the unit tests based on `PackageInstaller`'s use of
`BuildRequest` and the associated changes
- [x] Change `environment.py`'s `install_all` to use the `PackageInstaller` directly
- [x] Change the `install` command to leverage the new installation process for multiple specs
- [x] Change install output messages for external packages, e.g.:
`[+] /usr` -> `[+] /usr (external bzip2-1.0.8-<dag-hash>`
- [x] Fix incomplete environment install's view setup/update and not confirming all
packages are installed (?)
- [x] Ensure externally installed package dependencies are properly accounted for in
remaining build tasks
- [x] Add tests for coverage (if insufficient and can identity the appropriate, uncovered non-comment lines)
- [x] Add documentation
- [x] Resolve multi-compiler environment install issues
- [x] Fix issue with environment installation reporting (restore CDash/JUnit reports)
2020-11-17 18:41:07 +08:00
|
|
|
|
|
|
|
.. _installing-environment:
|
|
|
|
|
2019-03-29 10:23:16 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Installing an Environment
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
In addition to installing individual specs into an Environment, one
|
|
|
|
can install the entire Environment at once using the command
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
[myenv]$ spack install
|
|
|
|
|
|
|
|
If the Environment has been concretized, Spack will install the
|
|
|
|
concretized specs. Otherwise, ``spack install`` will first concretize
|
|
|
|
the Environment and then install the concretized specs.
|
|
|
|
|
Makefile generator for parallel spack install of environments (#30254)
`make` solves a lot of headaches that would otherwise have to be implemented in Spack:
1. Parallelism over packages through multiple `spack install` processes
2. Orderly output of parallel package installs thanks to `make --sync-output=recurse` or `make -Orecurse` (works well in GNU Make 4.3; macOS is unfortunately on a 16 years old 3.x version, but it's one `spack install gmake` away...)
3. Shared jobserver across packages, which means a single `-j` to rule them all, instead of manually finding a balance between `#spack install processes` & `#jobs per package` (See #30302).
This pr adds the `spack env depfile` command that generates a Makefile with dag hashes as
targets, and dag hashes of dependencies as prerequisites, and a command
along the lines of `spack install --only=packages /hash` to just install
a single package.
It exposes two convenient phony targets: `all`, `fetch-all`. The former installs the environment, the latter just fetches all sources. So one can either use `make all -j16` directly or run `make fetch-all -j16` on a login node and `make all -j16` on a compute node.
Example:
```yaml
spack:
specs: [perl]
view: false
```
running
```
$ spack -e . env depfile --make-target-prefix env | tee Makefile
```
generates
```Makefile
SPACK ?= spack
.PHONY: env/all env/fetch-all env/clean
env/all: env/env
env/fetch-all: env/fetch
env/env: env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww
@touch $@
env/fetch: env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc
@touch $@
env/dirs:
@mkdir -p env/.fetch env/.install
env/.fetch/%: | env/dirs
$(info Fetching $(SPEC))
$(SPACK) -e '/tmp/tmp.7PHPSIRACv' fetch $(SPACK_FETCH_FLAGS) /$(notdir $@) && touch $@
env/.install/%: env/.fetch/%
$(info Installing $(SPEC))
+$(SPACK) -e '/tmp/tmp.7PHPSIRACv' install $(SPACK_INSTALL_FLAGS) --only-concrete --only=package --no-add /$(notdir $@) && touch $@
# Set the human-readable spec for each target
env/%/cdqldivylyxocqymwnfzmzc5sx2zwvww: SPEC = perl@5.34.1%gcc@10.3.0+cpanm+shared+threads arch=linux-ubuntu20.04-zen2
env/%/gv5kin2xnn33uxyfte6k4a3bynhmtxze: SPEC = berkeley-db@18.1.40%gcc@10.3.0+cxx~docs+stl patches=b231fcc arch=linux-ubuntu20.04-zen2
env/%/cuymc7e5gupwyu7vza5d4vrbuslk277p: SPEC = bzip2@1.0.8%gcc@10.3.0~debug~pic+shared arch=linux-ubuntu20.04-zen2
env/%/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: SPEC = diffutils@3.8%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws: SPEC = libiconv@1.16%gcc@10.3.0 libs=shared,static arch=linux-ubuntu20.04-zen2
env/%/yfz2agazed7ohevqvnrmm7jfkmsgwjao: SPEC = gdbm@1.19%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/73t7ndb5w72hrat5hsax4caox2sgumzu: SPEC = readline@8.1%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/trvdyncxzfozxofpm3cwgq4vecpxixzs: SPEC = ncurses@6.2%gcc@10.3.0~symlinks+termlib abi=none arch=linux-ubuntu20.04-zen2
env/%/sbzszb7v557ohyd6c2ekirx2t3ctxfxp: SPEC = pkgconf@1.8.0%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/c4go4gxlcznh5p5nklpjm644epuh3pzc: SPEC = zlib@1.2.12%gcc@10.3.0+optimize+pic+shared patches=0d38234 arch=linux-ubuntu20.04-zen2
# Install dependencies
env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww: env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p: env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk
env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws
env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao: env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu
env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu: env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs
env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs: env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp
env/clean:
rm -f -- env/env env/fetch env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
```
Then with `make -O` you get very nice orderly output when packages are built in parallel:
```console
$ make -Orecurse -j16
spack -e . install --only-concrete --only=package /c4go4gxlcznh5p5nklpjm644epuh3pzc && touch c4go4gxlcznh5p5nklpjm644epuh3pzc
==> Installing zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
...
Fetch: 0.00s. Build: 0.88s. Total: 0.88s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
spack -e . install --only-concrete --only=package /sbzszb7v557ohyd6c2ekirx2t3ctxfxp && touch sbzszb7v557ohyd6c2ekirx2t3ctxfxp
==> Installing pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
...
Fetch: 0.00s. Build: 3.96s. Total: 3.96s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
```
For Perl, at least for me, using `make -j16` versus `spack -e . install -j16` speeds up the builds from 3m32.623s to 2m22.775s, as some configure scripts run in parallel.
Another nice feature is you can do Makefile "metaprogramming" and depend on packages built by Spack. This example fetches all sources (in parallel) first, print a message, and only then build packages (in parallel).
```Makefile
SPACK ?= spack
.PHONY: env
all: env
spack.lock: spack.yaml
$(SPACK) -e . concretize -f
env.mk: spack.lock
$(SPACK) -e . env depfile -o $@ --make-target-prefix spack
fetch: spack/fetch
@echo Fetched all packages && touch $@
env: fetch spack/env
@echo This executes after the environment has been installed
clean:
rm -rf spack/ env.mk spack.lock
ifeq (,$(filter clean,$(MAKECMDGOALS)))
include env.mk
endif
```
2022-05-06 01:45:21 +08:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
Every ``spack install`` process builds one package at a time with multiple build
|
|
|
|
jobs, controlled by the ``-j`` flag and the ``config:build_jobs`` option
|
|
|
|
(see :ref:`build-jobs`). To speed up environment builds further, independent
|
|
|
|
packages can be installed in parallel by launching more Spack instances. For
|
|
|
|
example, the following will build at most four packages in parallel using
|
|
|
|
three background jobs:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
[myenv]$ spack install & spack install & spack install & spack install
|
|
|
|
|
|
|
|
Another option is to generate a ``Makefile`` and run ``make -j<N>`` to control
|
|
|
|
the number of parallel install processes. See :ref:`env-generate-depfile`
|
|
|
|
for details.
|
|
|
|
|
|
|
|
|
2019-03-29 10:23:16 +08:00
|
|
|
As it installs, ``spack install`` creates symbolic links in the
|
|
|
|
``logs/`` directory in the Environment, allowing for easy inspection
|
|
|
|
of build logs related to that environment. The ``spack install``
|
|
|
|
command also stores a Spack repo containing the ``package.py`` file
|
|
|
|
used at install time for each package in the ``repos/`` directory in
|
|
|
|
the Environment.
|
|
|
|
|
2021-05-01 06:51:43 +08:00
|
|
|
The ``--no-add`` option can be used in a concrete environment to tell
|
|
|
|
spack to install specs already present in the environment but not to
|
|
|
|
add any new root specs to the environment. For root specs provided
|
|
|
|
to ``spack install`` on the command line, ``--no-add`` is the default,
|
|
|
|
while for dependency specs on the other hand, it is optional. In other
|
|
|
|
words, if there is an unambiguous match in the active concrete environment
|
|
|
|
for a root spec provided to ``spack install`` on the command line, spack
|
2021-06-08 01:05:09 +08:00
|
|
|
does not require you to specify the ``--no-add`` option to prevent the spec
|
2021-05-01 06:51:43 +08:00
|
|
|
from being added again. At the same time, a spec that already exists in the
|
|
|
|
environment, but only as a dependency, will be added to the environment as a
|
|
|
|
root spec without the ``--no-add`` option.
|
|
|
|
|
2022-08-05 04:20:33 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Developing Packages in a Spack Environment
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
The ``spack develop`` command allows one to develop Spack packages in
|
|
|
|
an environment. It requires a spec containing a concrete version, and
|
|
|
|
will configure Spack to install the package from local source. By
|
|
|
|
default, it will also clone the package to a subdirectory in the
|
|
|
|
environment. This package will have a special variant ``dev_path``
|
|
|
|
set, and Spack will ensure the package and its dependents are rebuilt
|
|
|
|
any time the environment is installed if the package's local source
|
|
|
|
code has been modified. Spack ensures that all instances of a
|
|
|
|
developed package in the environment are concretized to match the
|
|
|
|
version (and other constraints) passed as the spec argument to the
|
|
|
|
``spack develop`` command.
|
|
|
|
|
|
|
|
For packages with ``git`` attributes, git branches, tags, and commits can
|
|
|
|
also be used as valid concrete versions (see :ref:`version-specifier`).
|
|
|
|
This means that for a package ``foo``, ``spack develop foo@git.main`` will clone
|
|
|
|
the ``main`` branch of the package, and ``spack install`` will install from
|
|
|
|
that git clone if ``foo`` is in the environment.
|
|
|
|
Further development on ``foo`` can be tested by reinstalling the environment,
|
|
|
|
and eventually committed and pushed to the upstream git repo.
|
|
|
|
|
2019-03-29 10:23:16 +08:00
|
|
|
^^^^^^^
|
|
|
|
Loading
|
|
|
|
^^^^^^^
|
|
|
|
|
2020-01-28 12:49:53 +08:00
|
|
|
Once an environment has been installed, the following creates a load
|
|
|
|
script for it:
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2020-01-28 12:49:53 +08:00
|
|
|
$ spack env loads -r
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
This creates a file called ``loads`` in the environment directory.
|
|
|
|
Sourcing that file in Bash will make the environment available to the
|
|
|
|
user; and can be included in ``.bashrc`` files, etc. The ``loads``
|
|
|
|
file may also be copied out of the environment, renamed, etc.
|
|
|
|
|
|
|
|
.. _environment-configuration:
|
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
------------------------
|
2019-03-29 10:23:16 +08:00
|
|
|
Configuring Environments
|
2022-03-18 17:41:27 +08:00
|
|
|
------------------------
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
A variety of Spack behaviors are changed through Spack configuration
|
|
|
|
files, covered in more detail in the :ref:`configuration`
|
|
|
|
section.
|
|
|
|
|
|
|
|
Spack Environments provide an additional level of configuration scope
|
|
|
|
between the custom scope and the user scope discussed in the
|
|
|
|
configuration documentation.
|
|
|
|
|
|
|
|
There are two ways to include configuration information in a Spack Environment:
|
|
|
|
|
|
|
|
#. Inline in the ``spack.yaml`` file
|
|
|
|
|
|
|
|
#. Included in the ``spack.yaml`` file from another file.
|
|
|
|
|
2021-03-21 18:14:13 +08:00
|
|
|
Many Spack commands also affect configuration information in files
|
|
|
|
automatically. Those commands take a ``--scope`` argument, and the
|
|
|
|
environment can be specified by ``env:NAME`` (to affect environment
|
|
|
|
``foo``, set ``--scope env:foo``). These commands will automatically
|
|
|
|
manipulate configuration inline in the ``spack.yaml`` file.
|
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
2019-03-29 10:23:16 +08:00
|
|
|
Inline configurations
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
Inline Environment-scope configuration is done using the same yaml
|
|
|
|
format as standard Spack configuration scopes, covered in the
|
|
|
|
:ref:`configuration` section. Each section is contained under a
|
|
|
|
top-level yaml object with it's name. For example, a ``spack.yaml``
|
|
|
|
manifest file containing some package preference configuration (as in
|
|
|
|
a ``packages.yaml`` file) could contain:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
...
|
|
|
|
packages:
|
|
|
|
all:
|
Fix typo in config (#12267)
Using "compilers" with the "s" is an invalid config section and throws an error.
Traceback (most recent call last):
File "spack/bin/spack", line 48, in <module>
sys.exit(spack.main.main())
File "/home/omsai/src/libkmap/spack/lib/spack/spack/main.py", line 633, in main
env = ev.find_environment(args)
File "/home/omsai/src/libkmap/spack/lib/spack/spack/environment.py", line 263, in find_environment
return Environment(env)
File "/home/omsai/src/libkmap/spack/lib/spack/spack/environment.py", line 534, in __init__
self._read_manifest(f)
File "/home/omsai/src/libkmap/spack/lib/spack/spack/environment.py", line 561, in _read_manifest
self.yaml = _read_yaml(f)
File "/home/omsai/src/libkmap/spack/lib/spack/spack/environment.py", line 402, in _read_yaml
validate(data, filename)
File "/home/omsai/src/libkmap/spack/lib/spack/spack/environment.py", line 395, in validate
e, data, filename, e.instance.lc.line + 1)
spack.config.ConfigFormatError: /home/omsai/src/libkmap/spack.yaml:15: Additional properties are not allowed ('compilers' was unexpected)
2019-08-04 09:18:44 +08:00
|
|
|
compiler: [intel]
|
2019-03-29 10:23:16 +08:00
|
|
|
...
|
|
|
|
|
|
|
|
This configuration sets the default compiler for all packages to
|
|
|
|
``intel``.
|
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^
|
2019-03-29 10:23:16 +08:00
|
|
|
Included configurations
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
Spack environments allow an ``include`` heading in their yaml
|
|
|
|
schema. This heading pulls in external configuration files and applies
|
|
|
|
them to the Environment.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
include:
|
|
|
|
- relative/path/to/config.yaml
|
2022-08-31 02:13:23 +08:00
|
|
|
- https://github.com/path/to/raw/config/compilers.yaml
|
2019-03-29 10:23:16 +08:00
|
|
|
- /absolute/path/to/packages.yaml
|
|
|
|
|
2022-08-31 02:13:23 +08:00
|
|
|
Environments can include files or URLs. File paths can be relative or
|
|
|
|
absolute. URLs include the path to the text for individual files or
|
|
|
|
can be the path to a directory containing configuration files.
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Configuration precedence
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
Inline configurations take precedence over included configurations, so
|
|
|
|
you don't have to change shared configuration files to make small changes
|
|
|
|
to an individual environment. Included configurations listed earlier will
|
|
|
|
have higher precedence, as the included configs are applied in reverse order.
|
2019-03-29 10:23:16 +08:00
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
-------------------------------
|
2019-03-29 10:23:16 +08:00
|
|
|
Manually Editing the Specs List
|
2022-03-18 17:41:27 +08:00
|
|
|
-------------------------------
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
The list of abstract/root specs in the Environment is maintained in
|
|
|
|
the ``spack.yaml`` manifest under the heading ``specs``.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
specs:
|
|
|
|
- ncview
|
|
|
|
- netcdf
|
|
|
|
- nco
|
|
|
|
- py-sphinx
|
|
|
|
|
|
|
|
Appending to this list in the yaml is identical to using the ``spack
|
|
|
|
add`` command from the command line. However, there is more power
|
|
|
|
available from the yaml file.
|
|
|
|
|
Best effort co-concretization (iterative algorithm) (#28941)
Currently, environments can either be concretized fully together or fully separately. This works well for users who create environments for interoperable software and can use `concretizer:unify:true`. It does not allow environments with conflicting software to be concretized for maximal interoperability.
The primary use-case for this is facilities providing system software. Facilities provide multiple MPI implementations, but all software built against a given MPI ought to be interoperable.
This PR adds a concretization option `concretizer:unify:when_possible`. When this option is used, Spack will concretize specs in the environment separately, but will optimize for minimal differences in overlapping packages.
* Add a level of indirection to root specs
This commit introduce the "literal" atom, which comes with
a few different "arities". The unary "literal" contains an
integer that id the ID of a spec literal. Other "literals"
contain information on the requests made by literal ID. For
instance zlib@1.2.11 generates the following facts:
literal(0,"root","zlib").
literal(0,"node","zlib").
literal(0,"node_version_satisfies","zlib","1.2.11").
This should help with solving large environments "together
where possible" since later literals can be now solved
together in batches.
* Add a mechanism to relax the number of literals being solved
* Modify spack solve to display the new criteria
Since the new criteria is above all the build criteria,
we need to modify the way we display the output.
Originally done by Greg in #27964 and cherry-picked
to this branch by the co-author of the commit.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
* Inject reusable specs into the solve
Instead of coupling the PyclingoDriver() object with
spack.config, inject the concrete specs that can be
reused.
A method level function takes care of reading from
the store and the buildcache.
* spack solve: show output of multi-rounds
* add tests for best-effort coconcretization
* Enforce having at least a literal being solved
Co-authored-by: Greg Becker <becker33@llnl.gov>
2022-05-25 03:13:28 +08:00
|
|
|
.. _environments_concretization_config:
|
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^
|
2019-10-08 00:53:23 +08:00
|
|
|
Spec concretization
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^
|
2022-11-07 22:38:24 +08:00
|
|
|
An environment can be concretized in three different modes and the behavior active under
|
|
|
|
any environment is determined by the ``concretizer:unify`` configuration option.
|
|
|
|
|
|
|
|
The *default* mode is to unify all specs:
|
2019-10-08 00:53:23 +08:00
|
|
|
|
Best effort co-concretization (iterative algorithm) (#28941)
Currently, environments can either be concretized fully together or fully separately. This works well for users who create environments for interoperable software and can use `concretizer:unify:true`. It does not allow environments with conflicting software to be concretized for maximal interoperability.
The primary use-case for this is facilities providing system software. Facilities provide multiple MPI implementations, but all software built against a given MPI ought to be interoperable.
This PR adds a concretization option `concretizer:unify:when_possible`. When this option is used, Spack will concretize specs in the environment separately, but will optimize for minimal differences in overlapping packages.
* Add a level of indirection to root specs
This commit introduce the "literal" atom, which comes with
a few different "arities". The unary "literal" contains an
integer that id the ID of a spec literal. Other "literals"
contain information on the requests made by literal ID. For
instance zlib@1.2.11 generates the following facts:
literal(0,"root","zlib").
literal(0,"node","zlib").
literal(0,"node_version_satisfies","zlib","1.2.11").
This should help with solving large environments "together
where possible" since later literals can be now solved
together in batches.
* Add a mechanism to relax the number of literals being solved
* Modify spack solve to display the new criteria
Since the new criteria is above all the build criteria,
we need to modify the way we display the output.
Originally done by Greg in #27964 and cherry-picked
to this branch by the co-author of the commit.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
* Inject reusable specs into the solve
Instead of coupling the PyclingoDriver() object with
spack.config, inject the concrete specs that can be
reused.
A method level function takes care of reading from
the store and the buildcache.
* spack solve: show output of multi-rounds
* add tests for best-effort coconcretization
* Enforce having at least a literal being solved
Co-authored-by: Greg Becker <becker33@llnl.gov>
2022-05-25 03:13:28 +08:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
specs:
|
|
|
|
- hdf5+mpi
|
|
|
|
- zlib@1.2.8
|
|
|
|
concretizer:
|
2022-11-07 22:38:24 +08:00
|
|
|
unify: true
|
|
|
|
|
|
|
|
This means that any package in the environment corresponds to a single concrete spec. In
|
|
|
|
the above example, when ``hdf5`` depends down the line of ``zlib``, it is required to
|
|
|
|
take ``zlib@1.2.8`` instead of a newer version. This mode of concretization is
|
|
|
|
particularly useful when environment views are used: if every package occurs in
|
|
|
|
only one flavor, it is usually possible to merge all install directories into a view.
|
Best effort co-concretization (iterative algorithm) (#28941)
Currently, environments can either be concretized fully together or fully separately. This works well for users who create environments for interoperable software and can use `concretizer:unify:true`. It does not allow environments with conflicting software to be concretized for maximal interoperability.
The primary use-case for this is facilities providing system software. Facilities provide multiple MPI implementations, but all software built against a given MPI ought to be interoperable.
This PR adds a concretization option `concretizer:unify:when_possible`. When this option is used, Spack will concretize specs in the environment separately, but will optimize for minimal differences in overlapping packages.
* Add a level of indirection to root specs
This commit introduce the "literal" atom, which comes with
a few different "arities". The unary "literal" contains an
integer that id the ID of a spec literal. Other "literals"
contain information on the requests made by literal ID. For
instance zlib@1.2.11 generates the following facts:
literal(0,"root","zlib").
literal(0,"node","zlib").
literal(0,"node_version_satisfies","zlib","1.2.11").
This should help with solving large environments "together
where possible" since later literals can be now solved
together in batches.
* Add a mechanism to relax the number of literals being solved
* Modify spack solve to display the new criteria
Since the new criteria is above all the build criteria,
we need to modify the way we display the output.
Originally done by Greg in #27964 and cherry-picked
to this branch by the co-author of the commit.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
* Inject reusable specs into the solve
Instead of coupling the PyclingoDriver() object with
spack.config, inject the concrete specs that can be
reused.
A method level function takes care of reading from
the store and the buildcache.
* spack solve: show output of multi-rounds
* add tests for best-effort coconcretization
* Enforce having at least a literal being solved
Co-authored-by: Greg Becker <becker33@llnl.gov>
2022-05-25 03:13:28 +08:00
|
|
|
|
2022-11-07 22:38:24 +08:00
|
|
|
A downside of unified concretization is that it can be overly strict. For example, a
|
|
|
|
concretization error would happen when both ``hdf5+mpi`` and ``hdf5~mpi`` are specified
|
|
|
|
in an environment.
|
Best effort co-concretization (iterative algorithm) (#28941)
Currently, environments can either be concretized fully together or fully separately. This works well for users who create environments for interoperable software and can use `concretizer:unify:true`. It does not allow environments with conflicting software to be concretized for maximal interoperability.
The primary use-case for this is facilities providing system software. Facilities provide multiple MPI implementations, but all software built against a given MPI ought to be interoperable.
This PR adds a concretization option `concretizer:unify:when_possible`. When this option is used, Spack will concretize specs in the environment separately, but will optimize for minimal differences in overlapping packages.
* Add a level of indirection to root specs
This commit introduce the "literal" atom, which comes with
a few different "arities". The unary "literal" contains an
integer that id the ID of a spec literal. Other "literals"
contain information on the requests made by literal ID. For
instance zlib@1.2.11 generates the following facts:
literal(0,"root","zlib").
literal(0,"node","zlib").
literal(0,"node_version_satisfies","zlib","1.2.11").
This should help with solving large environments "together
where possible" since later literals can be now solved
together in batches.
* Add a mechanism to relax the number of literals being solved
* Modify spack solve to display the new criteria
Since the new criteria is above all the build criteria,
we need to modify the way we display the output.
Originally done by Greg in #27964 and cherry-picked
to this branch by the co-author of the commit.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
* Inject reusable specs into the solve
Instead of coupling the PyclingoDriver() object with
spack.config, inject the concrete specs that can be
reused.
A method level function takes care of reading from
the store and the buildcache.
* spack solve: show output of multi-rounds
* add tests for best-effort coconcretization
* Enforce having at least a literal being solved
Co-authored-by: Greg Becker <becker33@llnl.gov>
2022-05-25 03:13:28 +08:00
|
|
|
|
2022-11-07 22:38:24 +08:00
|
|
|
The second mode is to *unify when possible*: this makes concretization of root specs
|
|
|
|
more independendent. Instead of requiring reuse of dependencies across different root
|
|
|
|
specs, it is only maximized:
|
2019-10-08 00:53:23 +08:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
specs:
|
Best effort co-concretization (iterative algorithm) (#28941)
Currently, environments can either be concretized fully together or fully separately. This works well for users who create environments for interoperable software and can use `concretizer:unify:true`. It does not allow environments with conflicting software to be concretized for maximal interoperability.
The primary use-case for this is facilities providing system software. Facilities provide multiple MPI implementations, but all software built against a given MPI ought to be interoperable.
This PR adds a concretization option `concretizer:unify:when_possible`. When this option is used, Spack will concretize specs in the environment separately, but will optimize for minimal differences in overlapping packages.
* Add a level of indirection to root specs
This commit introduce the "literal" atom, which comes with
a few different "arities". The unary "literal" contains an
integer that id the ID of a spec literal. Other "literals"
contain information on the requests made by literal ID. For
instance zlib@1.2.11 generates the following facts:
literal(0,"root","zlib").
literal(0,"node","zlib").
literal(0,"node_version_satisfies","zlib","1.2.11").
This should help with solving large environments "together
where possible" since later literals can be now solved
together in batches.
* Add a mechanism to relax the number of literals being solved
* Modify spack solve to display the new criteria
Since the new criteria is above all the build criteria,
we need to modify the way we display the output.
Originally done by Greg in #27964 and cherry-picked
to this branch by the co-author of the commit.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
* Inject reusable specs into the solve
Instead of coupling the PyclingoDriver() object with
spack.config, inject the concrete specs that can be
reused.
A method level function takes care of reading from
the store and the buildcache.
* spack solve: show output of multi-rounds
* add tests for best-effort coconcretization
* Enforce having at least a literal being solved
Co-authored-by: Greg Becker <becker33@llnl.gov>
2022-05-25 03:13:28 +08:00
|
|
|
- hdf5~mpi
|
|
|
|
- hdf5+mpi
|
|
|
|
- zlib@1.2.8
|
|
|
|
concretizer:
|
|
|
|
unify: when_possible
|
|
|
|
|
2022-11-07 22:38:24 +08:00
|
|
|
This means that both ``hdf5`` installations will use ``zlib@1.2.8`` as a dependency even
|
|
|
|
if newer versions of that library are available.
|
Best effort co-concretization (iterative algorithm) (#28941)
Currently, environments can either be concretized fully together or fully separately. This works well for users who create environments for interoperable software and can use `concretizer:unify:true`. It does not allow environments with conflicting software to be concretized for maximal interoperability.
The primary use-case for this is facilities providing system software. Facilities provide multiple MPI implementations, but all software built against a given MPI ought to be interoperable.
This PR adds a concretization option `concretizer:unify:when_possible`. When this option is used, Spack will concretize specs in the environment separately, but will optimize for minimal differences in overlapping packages.
* Add a level of indirection to root specs
This commit introduce the "literal" atom, which comes with
a few different "arities". The unary "literal" contains an
integer that id the ID of a spec literal. Other "literals"
contain information on the requests made by literal ID. For
instance zlib@1.2.11 generates the following facts:
literal(0,"root","zlib").
literal(0,"node","zlib").
literal(0,"node_version_satisfies","zlib","1.2.11").
This should help with solving large environments "together
where possible" since later literals can be now solved
together in batches.
* Add a mechanism to relax the number of literals being solved
* Modify spack solve to display the new criteria
Since the new criteria is above all the build criteria,
we need to modify the way we display the output.
Originally done by Greg in #27964 and cherry-picked
to this branch by the co-author of the commit.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
* Inject reusable specs into the solve
Instead of coupling the PyclingoDriver() object with
spack.config, inject the concrete specs that can be
reused.
A method level function takes care of reading from
the store and the buildcache.
* spack solve: show output of multi-rounds
* add tests for best-effort coconcretization
* Enforce having at least a literal being solved
Co-authored-by: Greg Becker <becker33@llnl.gov>
2022-05-25 03:13:28 +08:00
|
|
|
|
2022-11-07 22:38:24 +08:00
|
|
|
The third mode of operation is to concretize root specs entirely independently by
|
|
|
|
disabling unified concretization:
|
Best effort co-concretization (iterative algorithm) (#28941)
Currently, environments can either be concretized fully together or fully separately. This works well for users who create environments for interoperable software and can use `concretizer:unify:true`. It does not allow environments with conflicting software to be concretized for maximal interoperability.
The primary use-case for this is facilities providing system software. Facilities provide multiple MPI implementations, but all software built against a given MPI ought to be interoperable.
This PR adds a concretization option `concretizer:unify:when_possible`. When this option is used, Spack will concretize specs in the environment separately, but will optimize for minimal differences in overlapping packages.
* Add a level of indirection to root specs
This commit introduce the "literal" atom, which comes with
a few different "arities". The unary "literal" contains an
integer that id the ID of a spec literal. Other "literals"
contain information on the requests made by literal ID. For
instance zlib@1.2.11 generates the following facts:
literal(0,"root","zlib").
literal(0,"node","zlib").
literal(0,"node_version_satisfies","zlib","1.2.11").
This should help with solving large environments "together
where possible" since later literals can be now solved
together in batches.
* Add a mechanism to relax the number of literals being solved
* Modify spack solve to display the new criteria
Since the new criteria is above all the build criteria,
we need to modify the way we display the output.
Originally done by Greg in #27964 and cherry-picked
to this branch by the co-author of the commit.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
* Inject reusable specs into the solve
Instead of coupling the PyclingoDriver() object with
spack.config, inject the concrete specs that can be
reused.
A method level function takes care of reading from
the store and the buildcache.
* spack solve: show output of multi-rounds
* add tests for best-effort coconcretization
* Enforce having at least a literal being solved
Co-authored-by: Greg Becker <becker33@llnl.gov>
2022-05-25 03:13:28 +08:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
specs:
|
2022-11-07 22:38:24 +08:00
|
|
|
- hdf5~mpi
|
Best effort co-concretization (iterative algorithm) (#28941)
Currently, environments can either be concretized fully together or fully separately. This works well for users who create environments for interoperable software and can use `concretizer:unify:true`. It does not allow environments with conflicting software to be concretized for maximal interoperability.
The primary use-case for this is facilities providing system software. Facilities provide multiple MPI implementations, but all software built against a given MPI ought to be interoperable.
This PR adds a concretization option `concretizer:unify:when_possible`. When this option is used, Spack will concretize specs in the environment separately, but will optimize for minimal differences in overlapping packages.
* Add a level of indirection to root specs
This commit introduce the "literal" atom, which comes with
a few different "arities". The unary "literal" contains an
integer that id the ID of a spec literal. Other "literals"
contain information on the requests made by literal ID. For
instance zlib@1.2.11 generates the following facts:
literal(0,"root","zlib").
literal(0,"node","zlib").
literal(0,"node_version_satisfies","zlib","1.2.11").
This should help with solving large environments "together
where possible" since later literals can be now solved
together in batches.
* Add a mechanism to relax the number of literals being solved
* Modify spack solve to display the new criteria
Since the new criteria is above all the build criteria,
we need to modify the way we display the output.
Originally done by Greg in #27964 and cherry-picked
to this branch by the co-author of the commit.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
* Inject reusable specs into the solve
Instead of coupling the PyclingoDriver() object with
spack.config, inject the concrete specs that can be
reused.
A method level function takes care of reading from
the store and the buildcache.
* spack solve: show output of multi-rounds
* add tests for best-effort coconcretization
* Enforce having at least a literal being solved
Co-authored-by: Greg Becker <becker33@llnl.gov>
2022-05-25 03:13:28 +08:00
|
|
|
- hdf5+mpi
|
|
|
|
- zlib@1.2.8
|
2022-05-24 04:20:34 +08:00
|
|
|
concretizer:
|
2022-11-07 22:38:24 +08:00
|
|
|
unify: false
|
|
|
|
|
|
|
|
In this example ``hdf5`` is concretized separately, and does not consider ``zlib@1.2.8``
|
|
|
|
as a constraint or preference. Instead, it will take the latest possible version.
|
2019-10-08 00:53:23 +08:00
|
|
|
|
2022-11-07 22:38:24 +08:00
|
|
|
The last two concretization options are typically useful for system administrators and
|
|
|
|
user support groups providing a large software stack for their HPC center.
|
Best effort co-concretization (iterative algorithm) (#28941)
Currently, environments can either be concretized fully together or fully separately. This works well for users who create environments for interoperable software and can use `concretizer:unify:true`. It does not allow environments with conflicting software to be concretized for maximal interoperability.
The primary use-case for this is facilities providing system software. Facilities provide multiple MPI implementations, but all software built against a given MPI ought to be interoperable.
This PR adds a concretization option `concretizer:unify:when_possible`. When this option is used, Spack will concretize specs in the environment separately, but will optimize for minimal differences in overlapping packages.
* Add a level of indirection to root specs
This commit introduce the "literal" atom, which comes with
a few different "arities". The unary "literal" contains an
integer that id the ID of a spec literal. Other "literals"
contain information on the requests made by literal ID. For
instance zlib@1.2.11 generates the following facts:
literal(0,"root","zlib").
literal(0,"node","zlib").
literal(0,"node_version_satisfies","zlib","1.2.11").
This should help with solving large environments "together
where possible" since later literals can be now solved
together in batches.
* Add a mechanism to relax the number of literals being solved
* Modify spack solve to display the new criteria
Since the new criteria is above all the build criteria,
we need to modify the way we display the output.
Originally done by Greg in #27964 and cherry-picked
to this branch by the co-author of the commit.
Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
* Inject reusable specs into the solve
Instead of coupling the PyclingoDriver() object with
spack.config, inject the concrete specs that can be
reused.
A method level function takes care of reading from
the store and the buildcache.
* spack solve: show output of multi-rounds
* add tests for best-effort coconcretization
* Enforce having at least a literal being solved
Co-authored-by: Greg Becker <becker33@llnl.gov>
2022-05-25 03:13:28 +08:00
|
|
|
|
2022-05-24 04:20:34 +08:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
The ``concretizer:unify`` config option was introduced in Spack 0.18 to
|
|
|
|
replace the ``concretization`` property. For reference,
|
2022-06-24 17:31:43 +08:00
|
|
|
``concretization: together`` is replaced by ``concretizer:unify:true``,
|
|
|
|
and ``concretization: separately`` is replaced by ``concretizer:unify:false``.
|
2019-10-08 00:53:23 +08:00
|
|
|
|
|
|
|
.. admonition:: Re-concretization of user specs
|
|
|
|
|
2022-11-07 22:38:24 +08:00
|
|
|
When using *unified* concretization (when possible), the entire set of specs will be
|
2019-10-08 00:53:23 +08:00
|
|
|
re-concretized after any addition of new user specs, to ensure that
|
2022-11-07 22:38:24 +08:00
|
|
|
the environment remains consistent / minimal. When instead unified concretization is
|
|
|
|
disabled, only the new specs will be concretized after any addition.
|
2019-10-08 00:53:23 +08:00
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^
|
2019-03-29 10:23:16 +08:00
|
|
|
Spec Matrices
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
Entries in the ``specs`` list can be individual abstract specs or a
|
|
|
|
spec matrix.
|
|
|
|
|
|
|
|
A spec matrix is a yaml object containing multiple lists of specs, and
|
|
|
|
evaluates to the cross-product of those specs. Spec matrices also
|
|
|
|
contain an ``excludes`` directive, which eliminates certain
|
|
|
|
combinations from the evaluated result.
|
|
|
|
|
|
|
|
The following two Environment manifests are identical:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
specs:
|
|
|
|
- zlib %gcc@7.1.0
|
|
|
|
- zlib %gcc@4.9.3
|
|
|
|
- libelf %gcc@7.1.0
|
|
|
|
- libelf %gcc@4.9.3
|
|
|
|
- libdwarf %gcc@7.1.0
|
|
|
|
- cmake
|
|
|
|
|
|
|
|
spack:
|
|
|
|
specs:
|
|
|
|
- matrix:
|
|
|
|
- [zlib, libelf, libdwarf]
|
|
|
|
- ['%gcc@7.1.0', '%gcc@4.9.3']
|
|
|
|
exclude:
|
|
|
|
- libdwarf%gcc@4.9.3
|
|
|
|
- cmake
|
|
|
|
|
|
|
|
Spec matrices can be used to install swaths of software across various
|
|
|
|
toolchains.
|
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
2019-03-29 10:23:16 +08:00
|
|
|
Spec List References
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
The last type of possible entry in the specs list is a reference.
|
|
|
|
|
|
|
|
The Spack Environment manifest yaml schema contains an additional
|
|
|
|
heading ``definitions``. Under definitions is an array of yaml
|
|
|
|
objects. Each object has one or two fields. The one required field is
|
|
|
|
a name, and the optional field is a ``when`` clause.
|
|
|
|
|
|
|
|
The named field is a spec list. The spec list uses the same syntax as
|
|
|
|
the ``specs`` entry. Each entry in the spec list can be a spec, a spec
|
|
|
|
matrix, or a reference to an earlier named list. References are
|
|
|
|
specified using the ``$`` sigil, and are "splatted" into place
|
|
|
|
(i.e. the elements of the referent are at the same level as the
|
|
|
|
elements listed separately). As an example, the following two manifest
|
|
|
|
files are identical.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
definitions:
|
|
|
|
- first: [libelf, libdwarf]
|
2020-05-05 06:11:10 +08:00
|
|
|
- compilers: ['%gcc', '%intel']
|
2019-03-29 10:23:16 +08:00
|
|
|
- second:
|
|
|
|
- $first
|
|
|
|
- matrix:
|
|
|
|
- [zlib]
|
|
|
|
- [$compilers]
|
|
|
|
specs:
|
|
|
|
- $second
|
|
|
|
- cmake
|
|
|
|
|
|
|
|
spack:
|
|
|
|
specs:
|
|
|
|
- libelf
|
|
|
|
- libdwarf
|
|
|
|
- zlib%gcc
|
|
|
|
- zlib%intel
|
|
|
|
- cmake
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2019-07-24 06:42:16 +08:00
|
|
|
Named spec lists in the definitions section may only refer
|
2019-03-29 10:23:16 +08:00
|
|
|
to a named list defined above itself. Order matters.
|
|
|
|
|
|
|
|
In short files like the example, it may be easier to simply list the
|
|
|
|
included specs. However for more complicated examples involving many
|
|
|
|
packages across many toolchains, separately factored lists make
|
|
|
|
Environments substantially more manageable.
|
|
|
|
|
|
|
|
Additionally, the ``-l`` option to the ``spack add`` command allows
|
|
|
|
one to add to named lists in the definitions section of the manifest
|
|
|
|
file directly from the command line.
|
|
|
|
|
|
|
|
The ``when`` directive can be used to conditionally add specs to a
|
2019-07-24 06:42:16 +08:00
|
|
|
named list. The ``when`` directive takes a string of Python code
|
2019-03-29 10:23:16 +08:00
|
|
|
referring to a restricted set of variables, and evaluates to a
|
|
|
|
boolean. The specs listed are appended to the named list if the
|
|
|
|
``when`` string evaluates to ``True``. In the following snippet, the
|
|
|
|
named list ``compilers`` is ``['%gcc', '%clang', '%intel']`` on
|
|
|
|
``x86_64`` systems and ``['%gcc', '%clang']`` on all other systems.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
definitions:
|
|
|
|
- compilers: ['%gcc', '%clang']
|
2020-06-26 01:13:26 +08:00
|
|
|
- when: arch.satisfies('x86_64:')
|
2019-03-29 10:23:16 +08:00
|
|
|
compilers: ['%intel']
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
Any definitions with the same named list with true ``when``
|
|
|
|
clauses (or absent ``when`` clauses) will be appended together
|
|
|
|
|
|
|
|
The valid variables for a ``when`` clause are:
|
|
|
|
|
|
|
|
#. ``platform``. The platform string of the default Spack
|
|
|
|
architecture on the system.
|
|
|
|
|
|
|
|
#. ``os``. The os string of the default Spack architecture on
|
|
|
|
the system.
|
|
|
|
|
|
|
|
#. ``target``. The target string of the default Spack
|
|
|
|
architecture on the system.
|
|
|
|
|
2020-06-26 01:13:26 +08:00
|
|
|
#. ``architecture`` or ``arch``. A Spack spec satisfying the default Spack
|
|
|
|
architecture on the system. This supports querying via the ``satisfies``
|
|
|
|
method, as shown above.
|
|
|
|
|
|
|
|
#. ``arch_str``. The architecture string of the default Spack architecture
|
|
|
|
on the system.
|
2019-03-29 10:23:16 +08:00
|
|
|
|
2019-07-24 06:42:16 +08:00
|
|
|
#. ``re``. The standard regex module in Python.
|
2019-03-29 10:23:16 +08:00
|
|
|
|
2019-07-24 06:42:16 +08:00
|
|
|
#. ``env``. The user environment (usually ``os.environ`` in Python).
|
2019-03-29 10:23:16 +08:00
|
|
|
|
|
|
|
#. ``hostname``. The hostname of the system (if ``hostname`` is an
|
|
|
|
executable in the user's PATH).
|
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-05-05 06:11:10 +08:00
|
|
|
SpecLists as Constraints
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-05-05 06:11:10 +08:00
|
|
|
|
|
|
|
Dependencies and compilers in Spack can be both packages in an
|
|
|
|
environment and constraints on other packages. References to SpecLists
|
|
|
|
allow a shorthand to treat packages in a list as either a compiler or
|
|
|
|
a dependency using the ``$%`` or ``$^`` syntax respectively.
|
|
|
|
|
|
|
|
For example, the following environment has three root packages:
|
|
|
|
``gcc@8.1.0``, ``mvapich2@2.3.1 %gcc@8.1.0``, and ``hdf5+mpi
|
|
|
|
%gcc@8.1.0 ^mvapich2@2.3.1``.
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
definitions:
|
|
|
|
- compilers: [gcc@8.1.0]
|
|
|
|
- mpis: [mvapich2@2.3.1]
|
|
|
|
- packages: [hdf5+mpi]
|
|
|
|
|
|
|
|
specs:
|
|
|
|
- $compilers
|
|
|
|
- matrix:
|
|
|
|
- [$mpis]
|
|
|
|
- [$%compilers]
|
|
|
|
- matrix:
|
|
|
|
- [$packages]
|
|
|
|
- [$^mpis]
|
|
|
|
- [$%compilers]
|
|
|
|
|
|
|
|
This allows for a much-needed reduction in redundancy between packages
|
|
|
|
and constraints.
|
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
----------------
|
|
|
|
Filesystem Views
|
|
|
|
----------------
|
2019-03-29 10:23:16 +08:00
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
Spack Environments can define filesystem views, which provide a direct access point
|
|
|
|
for software similar to the directory hierarchy that might exist under ``/usr/local``.
|
|
|
|
Filesystem views are updated every time the environment is written out to the lock
|
|
|
|
file ``spack.lock``, so the concrete environment and the view are always compatible.
|
|
|
|
The files of the view's installed packages are brought into the view by symbolic or
|
|
|
|
hard links, referencing the original Spack installation, or by copy.
|
2019-04-17 01:59:56 +08:00
|
|
|
|
2021-05-29 05:12:05 +08:00
|
|
|
.. _configuring_environment_views:
|
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Configuration in ``spack.yaml``
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2019-04-17 01:59:56 +08:00
|
|
|
|
|
|
|
The Spack Environment manifest file has a top-level keyword
|
2022-03-18 17:41:27 +08:00
|
|
|
``view``. Each entry under that heading is a **view descriptor**, headed
|
|
|
|
by a name. Any number of views may be defined under the ``view`` heading.
|
|
|
|
The view descriptor contains the root of the view, and
|
2021-08-18 00:47:26 +08:00
|
|
|
optionally the projections for the view, ``select`` and
|
|
|
|
``exclude`` lists for the view and link information via ``link`` and
|
2022-03-18 17:41:27 +08:00
|
|
|
``link_type``.
|
|
|
|
|
|
|
|
For example, in the following manifest
|
2019-07-24 06:42:16 +08:00
|
|
|
file snippet we define a view named ``mpis``, rooted at
|
2019-04-17 01:59:56 +08:00
|
|
|
``/path/to/view`` in which all projections use the package name,
|
|
|
|
version, and compiler name to determine the path for a given
|
|
|
|
package. This view selects all packages that depend on MPI, and
|
|
|
|
excludes those built with the PGI compiler at version 18.5.
|
2022-03-10 04:35:26 +08:00
|
|
|
The root specs with their (transitive) link and run type dependencies
|
|
|
|
will be put in the view due to the ``link: all`` option,
|
|
|
|
and the files in the view will be symlinks to the spack install
|
|
|
|
directories.
|
2019-04-17 01:59:56 +08:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
...
|
|
|
|
view:
|
|
|
|
mpis:
|
|
|
|
root: /path/to/view
|
|
|
|
select: [^mpi]
|
|
|
|
exclude: ['%pgi@18.5']
|
|
|
|
projections:
|
2022-06-18 00:25:52 +08:00
|
|
|
all: '{name}/{version}-{compiler.name}'
|
2021-08-18 00:47:26 +08:00
|
|
|
link: all
|
|
|
|
link_type: symlink
|
2019-04-17 01:59:56 +08:00
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
The default for the ``select`` and
|
2019-04-17 01:59:56 +08:00
|
|
|
``exclude`` values is to select everything and exclude nothing. The
|
2021-08-18 00:47:26 +08:00
|
|
|
default projection is the default view projection (``{}``). The ``link``
|
2022-03-10 04:35:26 +08:00
|
|
|
attribute allows the following values:
|
|
|
|
|
|
|
|
#. ``link: all`` include root specs with their transitive run and link type
|
|
|
|
dependencies (default);
|
|
|
|
#. ``link: run`` include root specs with their transitive run type dependencies;
|
|
|
|
#. ``link: roots`` include root specs without their dependencies.
|
|
|
|
|
|
|
|
The ``link_type`` defaults to ``symlink`` but can also take the value
|
|
|
|
of ``hardlink`` or ``copy``.
|
|
|
|
|
|
|
|
.. tip::
|
|
|
|
|
|
|
|
The option ``link: run`` can be used to create small environment views for
|
|
|
|
Python packages. Python will be able to import packages *inside* of the view even
|
|
|
|
when the environment is not activated, and linked libraries will be located
|
|
|
|
*outside* of the view thanks to rpaths.
|
2019-04-17 01:59:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
There are two shorthands for environments with a single view. If the
|
|
|
|
environment at ``/path/to/env`` has a single view, with a root at
|
|
|
|
``/path/to/env/.spack-env/view``, with default selection and exclusion
|
|
|
|
and the default projection, we can put ``view: True`` in the
|
|
|
|
environment manifest. Similarly, if the environment has a view with a
|
|
|
|
different root, but default selection, exclusion, and projections, the
|
|
|
|
manifest can say ``view: /path/to/view``. These views are
|
|
|
|
automatically named ``default``, so that
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
...
|
|
|
|
view: True
|
|
|
|
|
|
|
|
is equivalent to
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
...
|
|
|
|
view:
|
|
|
|
default:
|
|
|
|
root: .spack-env/view
|
|
|
|
|
|
|
|
and
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
...
|
|
|
|
view: /path/to/view
|
|
|
|
|
|
|
|
is equivalent to
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
spack:
|
|
|
|
...
|
|
|
|
view:
|
|
|
|
default:
|
|
|
|
root: /path/to/view
|
|
|
|
|
|
|
|
By default, Spack environments are configured with ``view: True`` in
|
|
|
|
the manifest. Environments can be configured without views using
|
|
|
|
``view: False``. For backwards compatibility reasons, environments
|
|
|
|
with no ``view`` key are treated the same as ``view: True``.
|
|
|
|
|
|
|
|
From the command line, the ``spack env create`` command takes an
|
2019-07-24 06:42:16 +08:00
|
|
|
argument ``--with-view [PATH]`` that sets the path for a single, default
|
2019-04-17 01:59:56 +08:00
|
|
|
view. If no path is specified, the default path is used (``view:
|
2019-07-24 06:42:16 +08:00
|
|
|
True``). The argument ``--without-view`` can be used to create an
|
2019-04-17 01:59:56 +08:00
|
|
|
environment without any view configured.
|
|
|
|
|
|
|
|
The ``spack env view`` command can be used to change the manage views
|
|
|
|
of an Environment. The subcommand ``spack env view enable`` will add a
|
|
|
|
view named ``default`` to an environment. It takes an optional
|
|
|
|
argument to specify the path for the new default view. The subcommand
|
|
|
|
``spack env view disable`` will remove the view named ``default`` from
|
|
|
|
an environment if one exists. The subcommand ``spack env view
|
|
|
|
regenerate`` will regenerate the views for the environment. This will
|
|
|
|
apply any updates in the environment configuration that have not yet
|
|
|
|
been applied.
|
|
|
|
|
2022-03-18 17:41:27 +08:00
|
|
|
.. _view_projections:
|
|
|
|
|
|
|
|
""""""""""""""""
|
|
|
|
View Projections
|
|
|
|
""""""""""""""""
|
|
|
|
The default projection into a view is to link every package into the
|
|
|
|
root of the view. The projections attribute is a mapping of partial specs to
|
|
|
|
spec format strings, defined by the :meth:`~spack.spec.Spec.format`
|
|
|
|
function, as shown in the example below:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
projections:
|
|
|
|
zlib: {name}-{version}
|
|
|
|
^mpi: {name}-{version}/{^mpi.name}-{^mpi.version}-{compiler.name}-{compiler.version}
|
|
|
|
all: {name}-{version}/{compiler.name}-{compiler.version}
|
|
|
|
|
|
|
|
The entries in the projections configuration file must all be either
|
|
|
|
specs or the keyword ``all``. For each spec, the projection used will
|
|
|
|
be the first non-``all`` entry that the spec satisfies, or ``all`` if
|
|
|
|
there is an entry for ``all`` and no other entry is satisfied by the
|
|
|
|
spec. Where the keyword ``all`` appears in the file does not
|
|
|
|
matter.
|
|
|
|
|
|
|
|
Given the example above, the spec ``zlib@1.2.8``
|
|
|
|
will be linked into ``/my/view/zlib-1.2.8/``, the spec
|
|
|
|
``hdf5@1.8.10+mpi %gcc@4.9.3 ^mvapich2@2.2`` will be linked into
|
|
|
|
``/my/view/hdf5-1.8.10/mvapich2-2.2-gcc-4.9.3``, and the spec
|
|
|
|
``hdf5@1.8.10~mpi %gcc@4.9.3`` will be linked into
|
|
|
|
``/my/view/hdf5-1.8.10/gcc-4.9.3``.
|
|
|
|
|
|
|
|
If the keyword ``all`` does not appear in the projections
|
|
|
|
configuration file, any spec that does not satisfy any entry in the
|
|
|
|
file will be linked into the root of the view as in a single-prefix
|
|
|
|
view. Any entries that appear below the keyword ``all`` in the
|
|
|
|
projections configuration file will not be used, as all specs will use
|
|
|
|
the projection under ``all`` before reaching those entries.
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2019-04-17 01:59:56 +08:00
|
|
|
Activating environment views
|
2022-03-18 17:41:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2019-04-17 01:59:56 +08:00
|
|
|
|
|
|
|
The ``spack env activate`` command will put the default view for the
|
|
|
|
environment into the user's path, in addition to activating the
|
|
|
|
environment for Spack commands. The arguments ``-v,--with-view`` and
|
|
|
|
``-V,--without-view`` can be used to tune this behavior. The default
|
|
|
|
behavior is to activate with the environment view if there is one.
|
|
|
|
|
|
|
|
The environment variables affected by the ``spack env activate``
|
2020-11-18 07:24:00 +08:00
|
|
|
command and the paths that are used to update them are determined by
|
|
|
|
the :ref:`prefix inspections <customize-env-modifications>` defined in
|
|
|
|
your modules configuration; the defaults are summarized in the following
|
|
|
|
table.
|
2019-04-17 01:59:56 +08:00
|
|
|
|
|
|
|
=================== =========
|
|
|
|
Variable Paths
|
|
|
|
=================== =========
|
|
|
|
PATH bin
|
|
|
|
MANPATH man, share/man
|
|
|
|
ACLOCAL_PATH share/aclocal
|
2019-10-06 10:03:35 +08:00
|
|
|
PKG_CONFIG_PATH lib/pkgconfig, lib64/pkgconfig, share/pkgconfig
|
2019-07-24 06:42:16 +08:00
|
|
|
CMAKE_PREFIX_PATH .
|
2019-04-17 01:59:56 +08:00
|
|
|
=================== =========
|
|
|
|
|
|
|
|
Each of these paths are appended to the view root, and added to the
|
|
|
|
relevant variable if the path exists. For this reason, it is not
|
|
|
|
recommended to use non-default projections with the default view of an
|
|
|
|
environment.
|
|
|
|
|
|
|
|
The ``spack env deactivate`` command will remove the default view of
|
|
|
|
the environment from the user's path.
|
Makefile generator for parallel spack install of environments (#30254)
`make` solves a lot of headaches that would otherwise have to be implemented in Spack:
1. Parallelism over packages through multiple `spack install` processes
2. Orderly output of parallel package installs thanks to `make --sync-output=recurse` or `make -Orecurse` (works well in GNU Make 4.3; macOS is unfortunately on a 16 years old 3.x version, but it's one `spack install gmake` away...)
3. Shared jobserver across packages, which means a single `-j` to rule them all, instead of manually finding a balance between `#spack install processes` & `#jobs per package` (See #30302).
This pr adds the `spack env depfile` command that generates a Makefile with dag hashes as
targets, and dag hashes of dependencies as prerequisites, and a command
along the lines of `spack install --only=packages /hash` to just install
a single package.
It exposes two convenient phony targets: `all`, `fetch-all`. The former installs the environment, the latter just fetches all sources. So one can either use `make all -j16` directly or run `make fetch-all -j16` on a login node and `make all -j16` on a compute node.
Example:
```yaml
spack:
specs: [perl]
view: false
```
running
```
$ spack -e . env depfile --make-target-prefix env | tee Makefile
```
generates
```Makefile
SPACK ?= spack
.PHONY: env/all env/fetch-all env/clean
env/all: env/env
env/fetch-all: env/fetch
env/env: env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww
@touch $@
env/fetch: env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc
@touch $@
env/dirs:
@mkdir -p env/.fetch env/.install
env/.fetch/%: | env/dirs
$(info Fetching $(SPEC))
$(SPACK) -e '/tmp/tmp.7PHPSIRACv' fetch $(SPACK_FETCH_FLAGS) /$(notdir $@) && touch $@
env/.install/%: env/.fetch/%
$(info Installing $(SPEC))
+$(SPACK) -e '/tmp/tmp.7PHPSIRACv' install $(SPACK_INSTALL_FLAGS) --only-concrete --only=package --no-add /$(notdir $@) && touch $@
# Set the human-readable spec for each target
env/%/cdqldivylyxocqymwnfzmzc5sx2zwvww: SPEC = perl@5.34.1%gcc@10.3.0+cpanm+shared+threads arch=linux-ubuntu20.04-zen2
env/%/gv5kin2xnn33uxyfte6k4a3bynhmtxze: SPEC = berkeley-db@18.1.40%gcc@10.3.0+cxx~docs+stl patches=b231fcc arch=linux-ubuntu20.04-zen2
env/%/cuymc7e5gupwyu7vza5d4vrbuslk277p: SPEC = bzip2@1.0.8%gcc@10.3.0~debug~pic+shared arch=linux-ubuntu20.04-zen2
env/%/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: SPEC = diffutils@3.8%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws: SPEC = libiconv@1.16%gcc@10.3.0 libs=shared,static arch=linux-ubuntu20.04-zen2
env/%/yfz2agazed7ohevqvnrmm7jfkmsgwjao: SPEC = gdbm@1.19%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/73t7ndb5w72hrat5hsax4caox2sgumzu: SPEC = readline@8.1%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/trvdyncxzfozxofpm3cwgq4vecpxixzs: SPEC = ncurses@6.2%gcc@10.3.0~symlinks+termlib abi=none arch=linux-ubuntu20.04-zen2
env/%/sbzszb7v557ohyd6c2ekirx2t3ctxfxp: SPEC = pkgconf@1.8.0%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/c4go4gxlcznh5p5nklpjm644epuh3pzc: SPEC = zlib@1.2.12%gcc@10.3.0+optimize+pic+shared patches=0d38234 arch=linux-ubuntu20.04-zen2
# Install dependencies
env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww: env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p: env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk
env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws
env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao: env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu
env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu: env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs
env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs: env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp
env/clean:
rm -f -- env/env env/fetch env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
```
Then with `make -O` you get very nice orderly output when packages are built in parallel:
```console
$ make -Orecurse -j16
spack -e . install --only-concrete --only=package /c4go4gxlcznh5p5nklpjm644epuh3pzc && touch c4go4gxlcznh5p5nklpjm644epuh3pzc
==> Installing zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
...
Fetch: 0.00s. Build: 0.88s. Total: 0.88s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
spack -e . install --only-concrete --only=package /sbzszb7v557ohyd6c2ekirx2t3ctxfxp && touch sbzszb7v557ohyd6c2ekirx2t3ctxfxp
==> Installing pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
...
Fetch: 0.00s. Build: 3.96s. Total: 3.96s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
```
For Perl, at least for me, using `make -j16` versus `spack -e . install -j16` speeds up the builds from 3m32.623s to 2m22.775s, as some configure scripts run in parallel.
Another nice feature is you can do Makefile "metaprogramming" and depend on packages built by Spack. This example fetches all sources (in parallel) first, print a message, and only then build packages (in parallel).
```Makefile
SPACK ?= spack
.PHONY: env
all: env
spack.lock: spack.yaml
$(SPACK) -e . concretize -f
env.mk: spack.lock
$(SPACK) -e . env depfile -o $@ --make-target-prefix spack
fetch: spack/fetch
@echo Fetched all packages && touch $@
env: fetch spack/env
@echo This executes after the environment has been installed
clean:
rm -rf spack/ env.mk spack.lock
ifeq (,$(filter clean,$(MAKECMDGOALS)))
include env.mk
endif
```
2022-05-06 01:45:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
.. _env-generate-depfile:
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------
|
|
|
|
Generating Depfiles from Environments
|
|
|
|
------------------------------------------
|
|
|
|
|
|
|
|
Spack can generate ``Makefile``\s to make it easier to build multiple
|
|
|
|
packages in an environment in parallel. Generated ``Makefile``\s expose
|
|
|
|
targets that can be included in existing ``Makefile``\s, to allow
|
|
|
|
other targets to depend on the environment installation.
|
|
|
|
|
|
|
|
A typical workflow is as follows:
|
|
|
|
|
|
|
|
.. code:: console
|
|
|
|
|
|
|
|
spack env create -d .
|
|
|
|
spack -e . add perl
|
|
|
|
spack -e . concretize
|
2022-10-15 12:10:05 +08:00
|
|
|
spack -e . env depfile -o Makefile
|
2022-05-06 20:04:48 +08:00
|
|
|
make -j64
|
|
|
|
|
|
|
|
This generates a ``Makefile`` from a concretized environment in the
|
|
|
|
current working directory, and ``make -j64`` installs the environment,
|
|
|
|
exploiting parallelism across packages as much as possible. Spack
|
|
|
|
respects the Make jobserver and forwards it to the build environment
|
|
|
|
of packages, meaning that a single ``-j`` flag is enough to control the
|
|
|
|
load, even when packages are built in parallel.
|
Makefile generator for parallel spack install of environments (#30254)
`make` solves a lot of headaches that would otherwise have to be implemented in Spack:
1. Parallelism over packages through multiple `spack install` processes
2. Orderly output of parallel package installs thanks to `make --sync-output=recurse` or `make -Orecurse` (works well in GNU Make 4.3; macOS is unfortunately on a 16 years old 3.x version, but it's one `spack install gmake` away...)
3. Shared jobserver across packages, which means a single `-j` to rule them all, instead of manually finding a balance between `#spack install processes` & `#jobs per package` (See #30302).
This pr adds the `spack env depfile` command that generates a Makefile with dag hashes as
targets, and dag hashes of dependencies as prerequisites, and a command
along the lines of `spack install --only=packages /hash` to just install
a single package.
It exposes two convenient phony targets: `all`, `fetch-all`. The former installs the environment, the latter just fetches all sources. So one can either use `make all -j16` directly or run `make fetch-all -j16` on a login node and `make all -j16` on a compute node.
Example:
```yaml
spack:
specs: [perl]
view: false
```
running
```
$ spack -e . env depfile --make-target-prefix env | tee Makefile
```
generates
```Makefile
SPACK ?= spack
.PHONY: env/all env/fetch-all env/clean
env/all: env/env
env/fetch-all: env/fetch
env/env: env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww
@touch $@
env/fetch: env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc
@touch $@
env/dirs:
@mkdir -p env/.fetch env/.install
env/.fetch/%: | env/dirs
$(info Fetching $(SPEC))
$(SPACK) -e '/tmp/tmp.7PHPSIRACv' fetch $(SPACK_FETCH_FLAGS) /$(notdir $@) && touch $@
env/.install/%: env/.fetch/%
$(info Installing $(SPEC))
+$(SPACK) -e '/tmp/tmp.7PHPSIRACv' install $(SPACK_INSTALL_FLAGS) --only-concrete --only=package --no-add /$(notdir $@) && touch $@
# Set the human-readable spec for each target
env/%/cdqldivylyxocqymwnfzmzc5sx2zwvww: SPEC = perl@5.34.1%gcc@10.3.0+cpanm+shared+threads arch=linux-ubuntu20.04-zen2
env/%/gv5kin2xnn33uxyfte6k4a3bynhmtxze: SPEC = berkeley-db@18.1.40%gcc@10.3.0+cxx~docs+stl patches=b231fcc arch=linux-ubuntu20.04-zen2
env/%/cuymc7e5gupwyu7vza5d4vrbuslk277p: SPEC = bzip2@1.0.8%gcc@10.3.0~debug~pic+shared arch=linux-ubuntu20.04-zen2
env/%/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: SPEC = diffutils@3.8%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws: SPEC = libiconv@1.16%gcc@10.3.0 libs=shared,static arch=linux-ubuntu20.04-zen2
env/%/yfz2agazed7ohevqvnrmm7jfkmsgwjao: SPEC = gdbm@1.19%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/73t7ndb5w72hrat5hsax4caox2sgumzu: SPEC = readline@8.1%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/trvdyncxzfozxofpm3cwgq4vecpxixzs: SPEC = ncurses@6.2%gcc@10.3.0~symlinks+termlib abi=none arch=linux-ubuntu20.04-zen2
env/%/sbzszb7v557ohyd6c2ekirx2t3ctxfxp: SPEC = pkgconf@1.8.0%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/c4go4gxlcznh5p5nklpjm644epuh3pzc: SPEC = zlib@1.2.12%gcc@10.3.0+optimize+pic+shared patches=0d38234 arch=linux-ubuntu20.04-zen2
# Install dependencies
env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww: env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p: env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk
env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws
env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao: env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu
env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu: env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs
env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs: env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp
env/clean:
rm -f -- env/env env/fetch env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
```
Then with `make -O` you get very nice orderly output when packages are built in parallel:
```console
$ make -Orecurse -j16
spack -e . install --only-concrete --only=package /c4go4gxlcznh5p5nklpjm644epuh3pzc && touch c4go4gxlcznh5p5nklpjm644epuh3pzc
==> Installing zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
...
Fetch: 0.00s. Build: 0.88s. Total: 0.88s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
spack -e . install --only-concrete --only=package /sbzszb7v557ohyd6c2ekirx2t3ctxfxp && touch sbzszb7v557ohyd6c2ekirx2t3ctxfxp
==> Installing pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
...
Fetch: 0.00s. Build: 3.96s. Total: 3.96s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
```
For Perl, at least for me, using `make -j16` versus `spack -e . install -j16` speeds up the builds from 3m32.623s to 2m22.775s, as some configure scripts run in parallel.
Another nice feature is you can do Makefile "metaprogramming" and depend on packages built by Spack. This example fetches all sources (in parallel) first, print a message, and only then build packages (in parallel).
```Makefile
SPACK ?= spack
.PHONY: env
all: env
spack.lock: spack.yaml
$(SPACK) -e . concretize -f
env.mk: spack.lock
$(SPACK) -e . env depfile -o $@ --make-target-prefix spack
fetch: spack/fetch
@echo Fetched all packages && touch $@
env: fetch spack/env
@echo This executes after the environment has been installed
clean:
rm -rf spack/ env.mk spack.lock
ifeq (,$(filter clean,$(MAKECMDGOALS)))
include env.mk
endif
```
2022-05-06 01:45:21 +08:00
|
|
|
|
|
|
|
By default the following phony convenience targets are available:
|
|
|
|
|
|
|
|
- ``make all``: installs the environment (default target);
|
|
|
|
- ``make clean``: cleans files used by make, but does not uninstall packages.
|
|
|
|
|
|
|
|
.. tip::
|
|
|
|
|
|
|
|
GNU Make version 4.3 and above have great support for output synchronization
|
|
|
|
through the ``-O`` and ``--output-sync`` flags, which ensure that output is
|
|
|
|
printed orderly per package install. To get synchronized output with colors,
|
|
|
|
use ``make -j<N> SPACK_COLOR=always --output-sync=recurse``.
|
|
|
|
|
2022-10-15 12:10:05 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Specifying dependencies on generated ``make`` targets
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
An interesting question is how to include generated ``Makefile``\s in your own
|
|
|
|
``Makefile``\s. This comes up when you want to install an environment that provides
|
|
|
|
executables required in a command for a make target of your own.
|
|
|
|
|
|
|
|
The example below shows how to accomplish this: the ``env`` target specifies
|
|
|
|
the generated ``spack/env`` target as a prerequisite, meaning that the environment
|
|
|
|
gets installed and is available for use in the ``env`` target.
|
Makefile generator for parallel spack install of environments (#30254)
`make` solves a lot of headaches that would otherwise have to be implemented in Spack:
1. Parallelism over packages through multiple `spack install` processes
2. Orderly output of parallel package installs thanks to `make --sync-output=recurse` or `make -Orecurse` (works well in GNU Make 4.3; macOS is unfortunately on a 16 years old 3.x version, but it's one `spack install gmake` away...)
3. Shared jobserver across packages, which means a single `-j` to rule them all, instead of manually finding a balance between `#spack install processes` & `#jobs per package` (See #30302).
This pr adds the `spack env depfile` command that generates a Makefile with dag hashes as
targets, and dag hashes of dependencies as prerequisites, and a command
along the lines of `spack install --only=packages /hash` to just install
a single package.
It exposes two convenient phony targets: `all`, `fetch-all`. The former installs the environment, the latter just fetches all sources. So one can either use `make all -j16` directly or run `make fetch-all -j16` on a login node and `make all -j16` on a compute node.
Example:
```yaml
spack:
specs: [perl]
view: false
```
running
```
$ spack -e . env depfile --make-target-prefix env | tee Makefile
```
generates
```Makefile
SPACK ?= spack
.PHONY: env/all env/fetch-all env/clean
env/all: env/env
env/fetch-all: env/fetch
env/env: env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww
@touch $@
env/fetch: env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc
@touch $@
env/dirs:
@mkdir -p env/.fetch env/.install
env/.fetch/%: | env/dirs
$(info Fetching $(SPEC))
$(SPACK) -e '/tmp/tmp.7PHPSIRACv' fetch $(SPACK_FETCH_FLAGS) /$(notdir $@) && touch $@
env/.install/%: env/.fetch/%
$(info Installing $(SPEC))
+$(SPACK) -e '/tmp/tmp.7PHPSIRACv' install $(SPACK_INSTALL_FLAGS) --only-concrete --only=package --no-add /$(notdir $@) && touch $@
# Set the human-readable spec for each target
env/%/cdqldivylyxocqymwnfzmzc5sx2zwvww: SPEC = perl@5.34.1%gcc@10.3.0+cpanm+shared+threads arch=linux-ubuntu20.04-zen2
env/%/gv5kin2xnn33uxyfte6k4a3bynhmtxze: SPEC = berkeley-db@18.1.40%gcc@10.3.0+cxx~docs+stl patches=b231fcc arch=linux-ubuntu20.04-zen2
env/%/cuymc7e5gupwyu7vza5d4vrbuslk277p: SPEC = bzip2@1.0.8%gcc@10.3.0~debug~pic+shared arch=linux-ubuntu20.04-zen2
env/%/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: SPEC = diffutils@3.8%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws: SPEC = libiconv@1.16%gcc@10.3.0 libs=shared,static arch=linux-ubuntu20.04-zen2
env/%/yfz2agazed7ohevqvnrmm7jfkmsgwjao: SPEC = gdbm@1.19%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/73t7ndb5w72hrat5hsax4caox2sgumzu: SPEC = readline@8.1%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/trvdyncxzfozxofpm3cwgq4vecpxixzs: SPEC = ncurses@6.2%gcc@10.3.0~symlinks+termlib abi=none arch=linux-ubuntu20.04-zen2
env/%/sbzszb7v557ohyd6c2ekirx2t3ctxfxp: SPEC = pkgconf@1.8.0%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/c4go4gxlcznh5p5nklpjm644epuh3pzc: SPEC = zlib@1.2.12%gcc@10.3.0+optimize+pic+shared patches=0d38234 arch=linux-ubuntu20.04-zen2
# Install dependencies
env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww: env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p: env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk
env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws
env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao: env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu
env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu: env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs
env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs: env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp
env/clean:
rm -f -- env/env env/fetch env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
```
Then with `make -O` you get very nice orderly output when packages are built in parallel:
```console
$ make -Orecurse -j16
spack -e . install --only-concrete --only=package /c4go4gxlcznh5p5nklpjm644epuh3pzc && touch c4go4gxlcznh5p5nklpjm644epuh3pzc
==> Installing zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
...
Fetch: 0.00s. Build: 0.88s. Total: 0.88s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
spack -e . install --only-concrete --only=package /sbzszb7v557ohyd6c2ekirx2t3ctxfxp && touch sbzszb7v557ohyd6c2ekirx2t3ctxfxp
==> Installing pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
...
Fetch: 0.00s. Build: 3.96s. Total: 3.96s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
```
For Perl, at least for me, using `make -j16` versus `spack -e . install -j16` speeds up the builds from 3m32.623s to 2m22.775s, as some configure scripts run in parallel.
Another nice feature is you can do Makefile "metaprogramming" and depend on packages built by Spack. This example fetches all sources (in parallel) first, print a message, and only then build packages (in parallel).
```Makefile
SPACK ?= spack
.PHONY: env
all: env
spack.lock: spack.yaml
$(SPACK) -e . concretize -f
env.mk: spack.lock
$(SPACK) -e . env depfile -o $@ --make-target-prefix spack
fetch: spack/fetch
@echo Fetched all packages && touch $@
env: fetch spack/env
@echo This executes after the environment has been installed
clean:
rm -rf spack/ env.mk spack.lock
ifeq (,$(filter clean,$(MAKECMDGOALS)))
include env.mk
endif
```
2022-05-06 01:45:21 +08:00
|
|
|
|
|
|
|
.. code:: Makefile
|
|
|
|
|
|
|
|
SPACK ?= spack
|
|
|
|
|
2022-07-05 20:48:32 +08:00
|
|
|
.PHONY: all clean env
|
Makefile generator for parallel spack install of environments (#30254)
`make` solves a lot of headaches that would otherwise have to be implemented in Spack:
1. Parallelism over packages through multiple `spack install` processes
2. Orderly output of parallel package installs thanks to `make --sync-output=recurse` or `make -Orecurse` (works well in GNU Make 4.3; macOS is unfortunately on a 16 years old 3.x version, but it's one `spack install gmake` away...)
3. Shared jobserver across packages, which means a single `-j` to rule them all, instead of manually finding a balance between `#spack install processes` & `#jobs per package` (See #30302).
This pr adds the `spack env depfile` command that generates a Makefile with dag hashes as
targets, and dag hashes of dependencies as prerequisites, and a command
along the lines of `spack install --only=packages /hash` to just install
a single package.
It exposes two convenient phony targets: `all`, `fetch-all`. The former installs the environment, the latter just fetches all sources. So one can either use `make all -j16` directly or run `make fetch-all -j16` on a login node and `make all -j16` on a compute node.
Example:
```yaml
spack:
specs: [perl]
view: false
```
running
```
$ spack -e . env depfile --make-target-prefix env | tee Makefile
```
generates
```Makefile
SPACK ?= spack
.PHONY: env/all env/fetch-all env/clean
env/all: env/env
env/fetch-all: env/fetch
env/env: env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww
@touch $@
env/fetch: env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc
@touch $@
env/dirs:
@mkdir -p env/.fetch env/.install
env/.fetch/%: | env/dirs
$(info Fetching $(SPEC))
$(SPACK) -e '/tmp/tmp.7PHPSIRACv' fetch $(SPACK_FETCH_FLAGS) /$(notdir $@) && touch $@
env/.install/%: env/.fetch/%
$(info Installing $(SPEC))
+$(SPACK) -e '/tmp/tmp.7PHPSIRACv' install $(SPACK_INSTALL_FLAGS) --only-concrete --only=package --no-add /$(notdir $@) && touch $@
# Set the human-readable spec for each target
env/%/cdqldivylyxocqymwnfzmzc5sx2zwvww: SPEC = perl@5.34.1%gcc@10.3.0+cpanm+shared+threads arch=linux-ubuntu20.04-zen2
env/%/gv5kin2xnn33uxyfte6k4a3bynhmtxze: SPEC = berkeley-db@18.1.40%gcc@10.3.0+cxx~docs+stl patches=b231fcc arch=linux-ubuntu20.04-zen2
env/%/cuymc7e5gupwyu7vza5d4vrbuslk277p: SPEC = bzip2@1.0.8%gcc@10.3.0~debug~pic+shared arch=linux-ubuntu20.04-zen2
env/%/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: SPEC = diffutils@3.8%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws: SPEC = libiconv@1.16%gcc@10.3.0 libs=shared,static arch=linux-ubuntu20.04-zen2
env/%/yfz2agazed7ohevqvnrmm7jfkmsgwjao: SPEC = gdbm@1.19%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/73t7ndb5w72hrat5hsax4caox2sgumzu: SPEC = readline@8.1%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/trvdyncxzfozxofpm3cwgq4vecpxixzs: SPEC = ncurses@6.2%gcc@10.3.0~symlinks+termlib abi=none arch=linux-ubuntu20.04-zen2
env/%/sbzszb7v557ohyd6c2ekirx2t3ctxfxp: SPEC = pkgconf@1.8.0%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/c4go4gxlcznh5p5nklpjm644epuh3pzc: SPEC = zlib@1.2.12%gcc@10.3.0+optimize+pic+shared patches=0d38234 arch=linux-ubuntu20.04-zen2
# Install dependencies
env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww: env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p: env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk
env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws
env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao: env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu
env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu: env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs
env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs: env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp
env/clean:
rm -f -- env/env env/fetch env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
```
Then with `make -O` you get very nice orderly output when packages are built in parallel:
```console
$ make -Orecurse -j16
spack -e . install --only-concrete --only=package /c4go4gxlcznh5p5nklpjm644epuh3pzc && touch c4go4gxlcznh5p5nklpjm644epuh3pzc
==> Installing zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
...
Fetch: 0.00s. Build: 0.88s. Total: 0.88s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
spack -e . install --only-concrete --only=package /sbzszb7v557ohyd6c2ekirx2t3ctxfxp && touch sbzszb7v557ohyd6c2ekirx2t3ctxfxp
==> Installing pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
...
Fetch: 0.00s. Build: 3.96s. Total: 3.96s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
```
For Perl, at least for me, using `make -j16` versus `spack -e . install -j16` speeds up the builds from 3m32.623s to 2m22.775s, as some configure scripts run in parallel.
Another nice feature is you can do Makefile "metaprogramming" and depend on packages built by Spack. This example fetches all sources (in parallel) first, print a message, and only then build packages (in parallel).
```Makefile
SPACK ?= spack
.PHONY: env
all: env
spack.lock: spack.yaml
$(SPACK) -e . concretize -f
env.mk: spack.lock
$(SPACK) -e . env depfile -o $@ --make-target-prefix spack
fetch: spack/fetch
@echo Fetched all packages && touch $@
env: fetch spack/env
@echo This executes after the environment has been installed
clean:
rm -rf spack/ env.mk spack.lock
ifeq (,$(filter clean,$(MAKECMDGOALS)))
include env.mk
endif
```
2022-05-06 01:45:21 +08:00
|
|
|
|
|
|
|
all: env
|
|
|
|
|
|
|
|
spack.lock: spack.yaml
|
|
|
|
$(SPACK) -e . concretize -f
|
|
|
|
|
|
|
|
env.mk: spack.lock
|
2023-01-19 21:58:34 +08:00
|
|
|
$(SPACK) -e . env depfile -o $@ --make-prefix spack
|
Makefile generator for parallel spack install of environments (#30254)
`make` solves a lot of headaches that would otherwise have to be implemented in Spack:
1. Parallelism over packages through multiple `spack install` processes
2. Orderly output of parallel package installs thanks to `make --sync-output=recurse` or `make -Orecurse` (works well in GNU Make 4.3; macOS is unfortunately on a 16 years old 3.x version, but it's one `spack install gmake` away...)
3. Shared jobserver across packages, which means a single `-j` to rule them all, instead of manually finding a balance between `#spack install processes` & `#jobs per package` (See #30302).
This pr adds the `spack env depfile` command that generates a Makefile with dag hashes as
targets, and dag hashes of dependencies as prerequisites, and a command
along the lines of `spack install --only=packages /hash` to just install
a single package.
It exposes two convenient phony targets: `all`, `fetch-all`. The former installs the environment, the latter just fetches all sources. So one can either use `make all -j16` directly or run `make fetch-all -j16` on a login node and `make all -j16` on a compute node.
Example:
```yaml
spack:
specs: [perl]
view: false
```
running
```
$ spack -e . env depfile --make-target-prefix env | tee Makefile
```
generates
```Makefile
SPACK ?= spack
.PHONY: env/all env/fetch-all env/clean
env/all: env/env
env/fetch-all: env/fetch
env/env: env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww
@touch $@
env/fetch: env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc
@touch $@
env/dirs:
@mkdir -p env/.fetch env/.install
env/.fetch/%: | env/dirs
$(info Fetching $(SPEC))
$(SPACK) -e '/tmp/tmp.7PHPSIRACv' fetch $(SPACK_FETCH_FLAGS) /$(notdir $@) && touch $@
env/.install/%: env/.fetch/%
$(info Installing $(SPEC))
+$(SPACK) -e '/tmp/tmp.7PHPSIRACv' install $(SPACK_INSTALL_FLAGS) --only-concrete --only=package --no-add /$(notdir $@) && touch $@
# Set the human-readable spec for each target
env/%/cdqldivylyxocqymwnfzmzc5sx2zwvww: SPEC = perl@5.34.1%gcc@10.3.0+cpanm+shared+threads arch=linux-ubuntu20.04-zen2
env/%/gv5kin2xnn33uxyfte6k4a3bynhmtxze: SPEC = berkeley-db@18.1.40%gcc@10.3.0+cxx~docs+stl patches=b231fcc arch=linux-ubuntu20.04-zen2
env/%/cuymc7e5gupwyu7vza5d4vrbuslk277p: SPEC = bzip2@1.0.8%gcc@10.3.0~debug~pic+shared arch=linux-ubuntu20.04-zen2
env/%/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: SPEC = diffutils@3.8%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws: SPEC = libiconv@1.16%gcc@10.3.0 libs=shared,static arch=linux-ubuntu20.04-zen2
env/%/yfz2agazed7ohevqvnrmm7jfkmsgwjao: SPEC = gdbm@1.19%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/73t7ndb5w72hrat5hsax4caox2sgumzu: SPEC = readline@8.1%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/trvdyncxzfozxofpm3cwgq4vecpxixzs: SPEC = ncurses@6.2%gcc@10.3.0~symlinks+termlib abi=none arch=linux-ubuntu20.04-zen2
env/%/sbzszb7v557ohyd6c2ekirx2t3ctxfxp: SPEC = pkgconf@1.8.0%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/c4go4gxlcznh5p5nklpjm644epuh3pzc: SPEC = zlib@1.2.12%gcc@10.3.0+optimize+pic+shared patches=0d38234 arch=linux-ubuntu20.04-zen2
# Install dependencies
env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww: env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p: env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk
env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws
env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao: env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu
env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu: env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs
env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs: env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp
env/clean:
rm -f -- env/env env/fetch env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
```
Then with `make -O` you get very nice orderly output when packages are built in parallel:
```console
$ make -Orecurse -j16
spack -e . install --only-concrete --only=package /c4go4gxlcznh5p5nklpjm644epuh3pzc && touch c4go4gxlcznh5p5nklpjm644epuh3pzc
==> Installing zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
...
Fetch: 0.00s. Build: 0.88s. Total: 0.88s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
spack -e . install --only-concrete --only=package /sbzszb7v557ohyd6c2ekirx2t3ctxfxp && touch sbzszb7v557ohyd6c2ekirx2t3ctxfxp
==> Installing pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
...
Fetch: 0.00s. Build: 3.96s. Total: 3.96s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
```
For Perl, at least for me, using `make -j16` versus `spack -e . install -j16` speeds up the builds from 3m32.623s to 2m22.775s, as some configure scripts run in parallel.
Another nice feature is you can do Makefile "metaprogramming" and depend on packages built by Spack. This example fetches all sources (in parallel) first, print a message, and only then build packages (in parallel).
```Makefile
SPACK ?= spack
.PHONY: env
all: env
spack.lock: spack.yaml
$(SPACK) -e . concretize -f
env.mk: spack.lock
$(SPACK) -e . env depfile -o $@ --make-target-prefix spack
fetch: spack/fetch
@echo Fetched all packages && touch $@
env: fetch spack/env
@echo This executes after the environment has been installed
clean:
rm -rf spack/ env.mk spack.lock
ifeq (,$(filter clean,$(MAKECMDGOALS)))
include env.mk
endif
```
2022-05-06 01:45:21 +08:00
|
|
|
|
|
|
|
env: spack/env
|
|
|
|
$(info Environment installed!)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf spack.lock env.mk spack/
|
|
|
|
|
|
|
|
ifeq (,$(filter clean,$(MAKECMDGOALS)))
|
|
|
|
include env.mk
|
|
|
|
endif
|
|
|
|
|
2022-10-15 12:10:05 +08:00
|
|
|
This works as follows: when ``make`` is invoked, it first "remakes" the missing
|
|
|
|
include ``env.mk`` as there is a target for it. This triggers concretization of
|
|
|
|
the environment and makes spack output ``env.mk``. At that point the
|
|
|
|
generated target ``spack/env`` becomes available through ``include env.mk``.
|
Makefile generator for parallel spack install of environments (#30254)
`make` solves a lot of headaches that would otherwise have to be implemented in Spack:
1. Parallelism over packages through multiple `spack install` processes
2. Orderly output of parallel package installs thanks to `make --sync-output=recurse` or `make -Orecurse` (works well in GNU Make 4.3; macOS is unfortunately on a 16 years old 3.x version, but it's one `spack install gmake` away...)
3. Shared jobserver across packages, which means a single `-j` to rule them all, instead of manually finding a balance between `#spack install processes` & `#jobs per package` (See #30302).
This pr adds the `spack env depfile` command that generates a Makefile with dag hashes as
targets, and dag hashes of dependencies as prerequisites, and a command
along the lines of `spack install --only=packages /hash` to just install
a single package.
It exposes two convenient phony targets: `all`, `fetch-all`. The former installs the environment, the latter just fetches all sources. So one can either use `make all -j16` directly or run `make fetch-all -j16` on a login node and `make all -j16` on a compute node.
Example:
```yaml
spack:
specs: [perl]
view: false
```
running
```
$ spack -e . env depfile --make-target-prefix env | tee Makefile
```
generates
```Makefile
SPACK ?= spack
.PHONY: env/all env/fetch-all env/clean
env/all: env/env
env/fetch-all: env/fetch
env/env: env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww
@touch $@
env/fetch: env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc
@touch $@
env/dirs:
@mkdir -p env/.fetch env/.install
env/.fetch/%: | env/dirs
$(info Fetching $(SPEC))
$(SPACK) -e '/tmp/tmp.7PHPSIRACv' fetch $(SPACK_FETCH_FLAGS) /$(notdir $@) && touch $@
env/.install/%: env/.fetch/%
$(info Installing $(SPEC))
+$(SPACK) -e '/tmp/tmp.7PHPSIRACv' install $(SPACK_INSTALL_FLAGS) --only-concrete --only=package --no-add /$(notdir $@) && touch $@
# Set the human-readable spec for each target
env/%/cdqldivylyxocqymwnfzmzc5sx2zwvww: SPEC = perl@5.34.1%gcc@10.3.0+cpanm+shared+threads arch=linux-ubuntu20.04-zen2
env/%/gv5kin2xnn33uxyfte6k4a3bynhmtxze: SPEC = berkeley-db@18.1.40%gcc@10.3.0+cxx~docs+stl patches=b231fcc arch=linux-ubuntu20.04-zen2
env/%/cuymc7e5gupwyu7vza5d4vrbuslk277p: SPEC = bzip2@1.0.8%gcc@10.3.0~debug~pic+shared arch=linux-ubuntu20.04-zen2
env/%/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: SPEC = diffutils@3.8%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws: SPEC = libiconv@1.16%gcc@10.3.0 libs=shared,static arch=linux-ubuntu20.04-zen2
env/%/yfz2agazed7ohevqvnrmm7jfkmsgwjao: SPEC = gdbm@1.19%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/73t7ndb5w72hrat5hsax4caox2sgumzu: SPEC = readline@8.1%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/trvdyncxzfozxofpm3cwgq4vecpxixzs: SPEC = ncurses@6.2%gcc@10.3.0~symlinks+termlib abi=none arch=linux-ubuntu20.04-zen2
env/%/sbzszb7v557ohyd6c2ekirx2t3ctxfxp: SPEC = pkgconf@1.8.0%gcc@10.3.0 arch=linux-ubuntu20.04-zen2
env/%/c4go4gxlcznh5p5nklpjm644epuh3pzc: SPEC = zlib@1.2.12%gcc@10.3.0+optimize+pic+shared patches=0d38234 arch=linux-ubuntu20.04-zen2
# Install dependencies
env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww: env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p: env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk
env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk: env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws
env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao: env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu
env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu: env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs
env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs: env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp
env/clean:
rm -f -- env/env env/fetch env/.fetch/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.fetch/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.fetch/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.fetch/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.fetch/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.fetch/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.fetch/73t7ndb5w72hrat5hsax4caox2sgumzu env/.fetch/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.fetch/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.fetch/c4go4gxlcznh5p5nklpjm644epuh3pzc env/.install/cdqldivylyxocqymwnfzmzc5sx2zwvww env/.install/gv5kin2xnn33uxyfte6k4a3bynhmtxze env/.install/cuymc7e5gupwyu7vza5d4vrbuslk277p env/.install/7vangk4jvsdgw6u6oe6ob63pyjl5cbgk env/.install/hyb7ehxxyqqp2hiw56bzm5ampkw6cxws env/.install/yfz2agazed7ohevqvnrmm7jfkmsgwjao env/.install/73t7ndb5w72hrat5hsax4caox2sgumzu env/.install/trvdyncxzfozxofpm3cwgq4vecpxixzs env/.install/sbzszb7v557ohyd6c2ekirx2t3ctxfxp env/.install/c4go4gxlcznh5p5nklpjm644epuh3pzc
```
Then with `make -O` you get very nice orderly output when packages are built in parallel:
```console
$ make -Orecurse -j16
spack -e . install --only-concrete --only=package /c4go4gxlcznh5p5nklpjm644epuh3pzc && touch c4go4gxlcznh5p5nklpjm644epuh3pzc
==> Installing zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
...
Fetch: 0.00s. Build: 0.88s. Total: 0.88s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/zlib-1.2.12-c4go4gxlcznh5p5nklpjm644epuh3pzc
spack -e . install --only-concrete --only=package /sbzszb7v557ohyd6c2ekirx2t3ctxfxp && touch sbzszb7v557ohyd6c2ekirx2t3ctxfxp
==> Installing pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
...
Fetch: 0.00s. Build: 3.96s. Total: 3.96s.
[+] /tmp/tmp.b1eTyAOe85/store/linux-ubuntu20.04-zen2/gcc-10.3.0/pkgconf-1.8.0-sbzszb7v557ohyd6c2ekirx2t3ctxfxp
```
For Perl, at least for me, using `make -j16` versus `spack -e . install -j16` speeds up the builds from 3m32.623s to 2m22.775s, as some configure scripts run in parallel.
Another nice feature is you can do Makefile "metaprogramming" and depend on packages built by Spack. This example fetches all sources (in parallel) first, print a message, and only then build packages (in parallel).
```Makefile
SPACK ?= spack
.PHONY: env
all: env
spack.lock: spack.yaml
$(SPACK) -e . concretize -f
env.mk: spack.lock
$(SPACK) -e . env depfile -o $@ --make-target-prefix spack
fetch: spack/fetch
@echo Fetched all packages && touch $@
env: fetch spack/env
@echo This executes after the environment has been installed
clean:
rm -rf spack/ env.mk spack.lock
ifeq (,$(filter clean,$(MAKECMDGOALS)))
include env.mk
endif
```
2022-05-06 01:45:21 +08:00
|
|
|
|
|
|
|
As it is typically undesirable to remake ``env.mk`` as part of ``make clean``,
|
|
|
|
the include is conditional.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
When including generated ``Makefile``\s, it is important to use
|
2023-01-19 21:58:34 +08:00
|
|
|
the ``--make-prefix`` flag and use the non-phony target
|
|
|
|
``<prefix>/env`` as prerequisite, instead of the phony target
|
|
|
|
``<prefix>/all``.
|
2022-10-15 12:10:05 +08:00
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Building a subset of the environment
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2022-11-16 22:47:31 +08:00
|
|
|
The generated ``Makefile``\s contain install targets for each spec, identified
|
|
|
|
by ``<name>-<version>-<hash>``. This allows you to install only a subset of the
|
|
|
|
packages in the environment. When packages are unique in the environment, it's
|
|
|
|
enough to know the name and let tab-completion fill out the version and hash.
|
|
|
|
|
|
|
|
The following phony targets are available: ``install/<spec>`` to install the
|
|
|
|
spec with its dependencies, and ``install-deps/<spec>`` to *only* install
|
2022-10-15 12:10:05 +08:00
|
|
|
its dependencies. This can be useful when certain flags should only apply to
|
|
|
|
dependencies. Below we show a use case where a spec is installed with verbose
|
|
|
|
output (``spack install --verbose``) while its dependencies are installed silently:
|
|
|
|
|
|
|
|
.. code:: console
|
|
|
|
|
2022-11-16 22:47:31 +08:00
|
|
|
$ spack env depfile -o Makefile
|
2022-10-15 12:10:05 +08:00
|
|
|
|
|
|
|
# Install dependencies in parallel, only show a log on error.
|
2022-11-16 22:47:31 +08:00
|
|
|
$ make -j16 install-deps/python-3.11.0-<hash> SPACK_INSTALL_FLAGS=--show-log-on-error
|
2022-10-15 12:10:05 +08:00
|
|
|
|
|
|
|
# Install the root spec with verbose output.
|
2023-01-19 02:19:46 +08:00
|
|
|
$ make -j16 install/python-3.11.0-<hash> SPACK_INSTALL_FLAGS=--verbose
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
Adding post-install hooks
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
Another advanced use-case of generated ``Makefile``\s is running a post-install
|
|
|
|
command for each package. These "hooks" could be anything from printing a
|
|
|
|
post-install message, running tests, or pushing just-built binaries to a buildcache.
|
|
|
|
|
|
|
|
This can be accomplished through the generated ``[<prefix>/]SPACK_PACKAGE_IDS``
|
|
|
|
variable. Assuming we have an active and concrete environment, we generate the
|
|
|
|
associated ``Makefile`` with a prefix ``example``:
|
|
|
|
|
|
|
|
.. code:: console
|
|
|
|
|
2023-01-19 21:58:34 +08:00
|
|
|
$ spack env depfile -o env.mk --make-prefix example
|
2023-01-19 02:19:46 +08:00
|
|
|
|
|
|
|
And we now include it in a different ``Makefile``, in which we create a target
|
|
|
|
``example/push/%`` with ``%`` referring to a package identifier. This target
|
|
|
|
depends on the particular package installation. In this target we automatically
|
|
|
|
have the target-specific ``HASH`` and ``SPEC`` variables at our disposal. They
|
|
|
|
are respectively the spec hash (excluding leading ``/``), and a human-readable spec.
|
|
|
|
Finally, we have an entrypoint target ``push`` that will update the buildcache
|
|
|
|
index once every package is pushed. Note how this target uses the generated
|
|
|
|
``example/SPACK_PACKAGE_IDS`` variable to define its prerequisites.
|
|
|
|
|
|
|
|
.. code:: Makefile
|
|
|
|
|
|
|
|
SPACK ?= spack
|
|
|
|
BUILDCACHE_DIR = $(CURDIR)/tarballs
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
|
|
|
|
all: push
|
|
|
|
|
|
|
|
include env.mk
|
|
|
|
|
|
|
|
example/push/%: example/install/%
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(info About to push $(SPEC) to a buildcache)
|
|
|
|
$(SPACK) -e . buildcache create --allow-root --only=package --directory $(BUILDCACHE_DIR) /$(HASH)
|
|
|
|
@touch $@
|
|
|
|
|
|
|
|
push: $(addprefix example/push/,$(example/SPACK_PACKAGE_IDS))
|
|
|
|
$(info Updating the buildcache index)
|
|
|
|
$(SPACK) -e . buildcache update-index --directory $(BUILDCACHE_DIR)
|
|
|
|
$(info Done!)
|
|
|
|
@touch $@
|