Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/course/conda.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ We've discovered we also need the `statsmodels` package for some extra work we w

````{admonition} Searching for packages

Conda has a command-line search functionality that we describe below in the section [Use Conda to search for a package](#searching-for-packages); you can also use the [`conda-forge` repository](https://anaconda.org/conda-forge) or [`bioconda` repository](https://anaconda.org/bioconda) to search for packages.
Conda has a command-line search functionality that we describe below in the section [Using Conda to search for a package](searching-for-packages); you can also use the [`conda-forge` repository](https://anaconda.org/conda-forge) or [`bioconda` repository](https://anaconda.org/bioconda) to search for packages.
````

Once you have the name (and possibly version) of the package you want to install, again there are two different ways to add these packages, much like there were two ways to create the environment to begin with.
Expand Down
359 changes: 214 additions & 145 deletions book/course/spack/advanced.md

Large diffs are not rendered by default.

21 changes: 8 additions & 13 deletions book/course/spack/containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Spack install software within.
To define your container, you create a YAML file that describes what you want.
Here's I'm saying I want spack to install gromacs with MPI enabled, and
OpenMPI. I want it to create the container for Singularity/Apptainer, and I
want it to make sure the libgomp1 package is installed onto the OS.
want it to make sure the libgomp package is installed onto the OS.

spack.yaml:

Expand All @@ -21,10 +21,13 @@ spack:
# What I want it to create
container:
format: singularity
images:
os: almalinux:9
spack: 1.1.0
# Bonus OS packages I'd like installed
os_packages:
final:
- libgomp1
- libgomp
# Additional config for the build process
config:
mount proc: yes
Expand Down Expand Up @@ -57,18 +60,10 @@ As a proof of life, let's run gromacs from within that container:

```bash
$ apptainer run gromacs-openmpi.sif mpirun -np 4 gmx_mpi
:-) GROMACS - gmx_mpi, 2024.4-spack (-:
:-) GROMACS - gmx_mpi, 2025.3-spack (-:

Executable: /opt/software/linux-zen4/gromacs-2024.4-af5srsrjr7w2alftldvyek2chqu4rtls/bin/gmx_mpi
Data prefix: /opt/software/linux-zen4/gromacs-2024.4-af5srsrjr7w2alftldvyek2chqu4rtls
Working dir: /users/example/hpc2
Command line:
gmx_mpi

SYNOPSIS

gmx [-[no]h] [-[no]quiet] [-[no]version] [-[no]copyright] [-nice <int>]
[-[no]backup]
Executable: /opt/software/linux-zen4/gromacs-2025.3-ipqq3w22geizv4y6pdroneco3hq33xkj/bin/gmx_mpi
Data prefix: /opt/software/linux-zen4/gromacs-2025.3-ipqq3w22geizv4y6pdroneco3hq33xkj
...
```

Expand Down
26 changes: 18 additions & 8 deletions book/course/spack/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Environments in Spack feel a whole lot like environments in Conda; they allow
you to bundle up a number of different pieces of software into a single entity,
making a single coherent collection.

This is a very simple introduction, and really doesn't cover all the things
you can do with environments, so if you're interested in these, please read
the main documentation links in the [References](environments:references) section.

## Creating an environment

Here's a minimal workflow for creating an environment:
Expand All @@ -13,17 +17,21 @@ Here's a minimal workflow for creating an environment:
```bash
spack env create myenv
```
- Activate it
```bash
spack env activate myenv
```

- Add a list of software to it

```bash
spack -e myenv add bash@5 python py-numpy py-scipy py-matplotlib [email protected].15
spack add bash@5 python py-numpy py-scipy py-matplotlib [email protected].7
```

- Tweak the config if required

```bash
spack -e myenv config edit
spack config edit
```

Please review the references for more information on options here, but nothing
Expand All @@ -32,7 +40,7 @@ Here's a minimal workflow for creating an environment:
- Validate the installation

```bash
spack -e myenv concretize
spack concretize
```

[Concretizing](https://spack.readthedocs.io/en/latest/environments.html#spec-concretization)
Expand All @@ -42,7 +50,7 @@ Here's a minimal workflow for creating an environment:
- Build and install the software

```bash
spack -e myenv install
spack install
```

Note this follows the normal behaviour of Spack, reusing previously built
Expand All @@ -51,7 +59,8 @@ software, and external software you've told it to use.
## Using an environment

Again, this feels very familiar to people used to Conda; you have to activate
an environment before using it:
an environment before using it (although we did actually do this earlier when
we created it):

```bash
spack env activate myenv
Expand All @@ -63,8 +72,8 @@ Once activated, you can confirm that it's really live:
$ which bash
~/spack/var/spack/environments/myenv/.spack-env/view/bin/bash
$ bash --version
GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
GNU bash, version 5.3.3(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
Expand All @@ -79,7 +88,8 @@ You can leave an environment using:
spack env deactivate
```

(environments:references)=
## References

- [Using Spack to Replace Homebrew/Conda](https://spack.readthedocs.io/en/latest/replace_conda_homebrew.html)
- [Environment Basics](https://spack.readthedocs.io/en/latest/environments_basics.html)
- [Environments](https://spack.readthedocs.io/en/latest/environments.html)
Loading
Loading