Allow usage of config variables and env variables with include_concrete (#45871)

* Allow usage of spack config vars in concrete env path
* Update docs on usage of spack config vars in concrete env path
This commit is contained in:
jgraciahlrs 2025-05-08 21:23:02 +02:00 committed by GitHub
parent 0f7c1b5e38
commit 1a379215da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -539,7 +539,9 @@ from the command line.
You can also include an environment directly in the ``spack.yaml`` file. It
involves adding the ``include_concrete`` heading in the yaml followed by the
absolute path to the independent environments.
absolute path to the independent environments. Note, that you may use Spack
config variables such as ``$spack`` or environment variables as long as the
expression expands to an absolute path.
.. code-block:: yaml
@ -549,7 +551,7 @@ absolute path to the independent environments.
unify: true
include_concrete:
- /absolute/path/to/environment1
- /absolute/path/to/environment2
- $spack/../path/to/environment2
Once the ``spack.yaml`` has been updated you must concretize the environment to

View File

@ -1049,7 +1049,11 @@ def add_view(name, values):
def _process_concrete_includes(self):
"""Extract and load into memory included concrete spec data."""
self.included_concrete_envs = self.manifest[TOP_LEVEL_KEY].get(included_concrete_name, [])
_included_concrete_envs = self.manifest[TOP_LEVEL_KEY].get(included_concrete_name, [])
# Expand config and environment variables
self.included_concrete_envs = [
spack.util.path.canonicalize_path(_env) for _env in _included_concrete_envs
]
if self.included_concrete_envs:
if os.path.exists(self.lock_path):