Spackenv: Script to create environments based on spack module loads
#2698
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Problem
I've been able to build my stuff with Spack, but was still having problems assembling a proper set of
spack module loads
commands to use it. The reason is because I need to support multiple configurations / subsets of my overall system. For example, they might be:spack setup
).This PR makes it easier to create environment scripts --- that is, files full of
module load
commands --- based on this variety of needs. It is built as a separate Python executable program that calls Spack multiple times (to ensure robustness, so I don't hit bugs like #2666).One serious problem up till now is that
spack load
,spack module loads
, etc. do not have the benefit of concretization; they are resolved completely differently fromspack install
(although concretization is slow, so doing it inspack load
would be a mixed blessing). The problem is that once you've used a spec forspack install
, there is no easy / foolproof / automatable way to subsequently issue aspack load
command for that module. If you have many similar installed versions in your Spack, that could be a real problem. This PR gets around that issue by tracking the hash that Spack uses to install the original spec, and then issuing aspack module loads
command for that hash.@tgamblin @eschnett @mathstuf @adamjstewart @becker33 @hartzell
Comments welcome, this software is "hot off the press." I'm especially interested in design ideas at this point. My guess is this script is a little "far out," and will need some iteration on design. I'm also hoping to get better / more robust file formats, but am not sure of what would be best.
Brief Docs
The user creates environment files (
.env
) in asrc
directory.spackenv
then turns them into environment scripts (no extension) in anenv
directory. Users can thensource
those scripts in their Bash shell.Here is a sample environment file:
This environment consists of emacs (and all its dependencies), plus the dependencies for libpciaccess (but not their dependencies). Syntactically, it works as so:
The
spack=
directive gives the Spack command thatspackenv
is to use. This is to allow for environments to use different configurations (egpackages.yaml
files; see Command Line Scopes #2686).Each line consists of two parts, separated by a colon. The first part is command line arguments to be sent to
spack install
. The second part (optional) is command line arguments to be sent tospack module loads
.spackenv
has two sub-commands:spackenv install
andspackenv loads
.spackenv install
spackenv install
runsspack install
once per line in the.env
file. It creates a.log
files with Spack's output, and tees it to STDOUT as well. Here is the log for a typicalspackenv install
command; the contents of~/env/test.log
is also displayed to STDOUT here:This is just typical Spack output. The extra lines starting with
SPACKENV
are parsed later byspackenv
. Note that if stuff was already installed (for real or viaspack setup
),spackenv install
won't build anything.spackenv loads
The script of
module load
commands is generated byspackenv loads
. Oncespackenv install
has run successfully, the user can runspackenv loads
, as follows:Here,
spackenv
shows you what commands it's running. It also produces the file~/env/test
, which looks like:This file may now be used to load up the specified environment in a Bash shell.
[This PR depends on #2664...]