Environments, spack.yaml und spack.lock¶
Erstellen einer virtuellen Umgebung:
==> Created environment 'python-311' in /srv/jupyter/spack/var/spack/environments/python-311 ==> You can activate this environment with: ==> spack env activate python-311
Alternativ kann sie auch an beliebigen anderen Orten gespeichert werden, z.B.:
$ cd spackenvs/ $ spack env create -d python-311 ==> Created environment in /srv/jupyter/jupyter-tutorial/spackenvs/python-311 ==> You can activate this environment with: ==> spack env activate /srv/jupyter/jupyter-tutorial/spackenvs/python-311
Überprüfen der virtuellen Umgebung:
$ spack env list ==> 1 environments python-311
Aktivieren der virtuellen Umgebung:
$ spack env activate python-311
Überprüfen der Aktivierung:
Wenn ihr eine Umgebung aktiviert habt, wird euch nur das angezeigt, was sich in der aktuellen Umgebung befindet. Das sollte unmittelbar nach der Aktivierung nichts sein:
$ spack find ==> In environment python-311 ==> No root specs ==> 0 installed packages
Und wenn ihr überprüfen möchtet, in welcher Umgebung ihr euch befindet, dann könnt ihr dies abfragen mit:
$ spack env status ==> In environment python-311
Schließlich könnt ihr die aktivierte Umgebung verlassen mit
spack env deactivateoder kurzdespacktivate.$ despacktivate $ spack env status ==> No active environment
Pakete installieren¶
$ spack env activate python-311
$ spack add python@3.11.0
$ spack install
==> Concretized python@3.11.0
- 4nvposf python@3.11.0%gcc@11.3.0+bz2+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4+uuid+zlib build_system=generic patches=13fa8bf,b0615b2,f2fd060 arch=linux-ubuntu22.04-sandybridge
- 6fefzf3 ^bzip2@1.0.8%gcc@11.3.0~debug~pic+shared build_system=generic arch=linux-ubuntu22.04-sandybridge
- 27f7g74 ^diffutils@3.8%gcc@11.3.0 build_system=autotools arch=linux-ubuntu22.04-sandybridge
…
==> python: Successfully installed python-3.11.0-4nvposf6bicf5ogp6nqacfo4dfvwm7zv
Fetch: 5.19s. Build: 3m 48.84s. Total: 3m 54.03s.
[+] /srv/jupyter/spack/opt/spack/linux-ubuntu22.04-sandybridge/gcc-11.3.0/python-3.11.0-4nvposf6bicf5ogp6nqacfo4dfvwm7zv
==> Updating view at /srv/jupyter/python-311/.spack-env/view
$ spack find
==> In environment /home/veit/python-311
==> Root specs
python@3.11.0
==> Installed packages
-- linux-ubuntu22.04-sandybridge / gcc@11.3.0 -------------------
berkeley-db@18.1.40 libiconv@1.16 readline@8.1.2
bzip2@1.0.8 libmd@1.0.4 sqlite@3.39.4
ca-certificates-mozilla@2022-10-11 libxml2@2.10.1 tar@1.34
diffutils@3.8 ncurses@6.3 util-linux-uuid@2.38.1
expat@2.4.8 openssl@1.1.1s xz@5.2.7
gdbm@1.23 perl@5.36.0 zlib@1.2.13
gettext@0.21.1 pigz@2.7 zstd@1.5.2
libbsd@0.11.5 pkgconf@1.8.0
libffi@3.4.2 python@3.11.0
==> 25 installed packages
Mit spack cd -e python-311 könnt ihr in dieses Verzeichnis wechseln,
z.B.:
$ spack cd -e python-311
$ pwd
/srv/jupyter/spack/var/spack/environments/python-311
Dort befinden sich die beiden Dateien spack.yaml und spack.lock.
spack.yamlist die Konfigurationsdatei für die virtuelle Umgebung. Sie wird in
~/spack/var/spack/environments/beim Aufruf vonspack env createerstellt.Alternativ zu
spack installkönnen inspack.yamlauch derspecs-Listepython@3.11.0,py-numpyetc. hinzugefügt werden:specs: [python@3.11.0, …]
spack.lockMit
spack installwerden die Specs konkretisiert, inspack.lockgeschrieben und installiert. Im Gegensatz zuspack.yamlistspack.lockimjson-Format geschrieben und enthält die notwendigen Informationen, um reproduzierbare Builds der Umgebung erstellen zu können:{ "_meta": { "file-type": "spack-lockfile", "lockfile-version": 4, "specfile-version": 3 }, "roots": [ { "hash": "4nvposf6bicf5ogp6nqacfo4dfvwm7zv", "spec": "python@3.11.0" } ], "concrete_specs": { "4nvposf6bicf5ogp6nqacfo4dfvwm7zv": { "name": "python", "version": "3.11.0", "arch": { "platform": "linux", "platform_os": "ubuntu22.04", "target": { "name": "sandybridge", "vendor": "GenuineIntel", "features": [ "aes", "avx", ... ] } } } } }
Installation zusätzlicher Pakete¶
Zusätzliche Pakete können in der virtuellen Umgebung mit spack add und
spack install installiert werden. Für Matplotlib
sieht dies z.B. folgendermaßen aus:
$ spack add py-numpy
==> Adding py-numpy to environment /srv/jupyter/jupyter-tutorial/spackenvs/python-311
$ spack install
==> Concretized python@3.11.0
[+] 4nvposf python@3.11.0%gcc@11.3.0+bz2+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4+uuid+zlib build_system=generic patches=13fa8bf,b0615b2,f2fd060 arch=linux-ubuntu22.04-sandybridge
[+] 6fefzf3 ^bzip2@1.0.8%gcc@11.3.0~debug~pic+shared build_system=generic arch=linux-ubuntu22.04-sandybridge
[+] 27f7g74 ^diffutils@3.8%gcc@11.3.0 build_system=autotools arch=linux-ubuntu22.04-sandybridge
…
==> Installing environment /srv/jupyter/jupyter-tutorial/spackenvs/python-311
…
==> Successfully installed py-numpy
Konfiguration¶
spack spec spezifiziert die Abhängigkeiten bestimmter Pakete, z.B.:
$ spack spec py-matplotlib
Input spec
--------------------------------
py-matplotlib
Concretized
--------------------------------
py-matplotlib@3.6.2%gcc@11.3.0~animation~fonts~latex~movies backend=agg build_system=python_pip arch=linux-ubuntu22.04-sandybridge
^freetype@2.11.1%gcc@11.3.0 build_system=autotools arch=linux-ubuntu22.04-sandybridge
^bzip2@1.0.8%gcc@11.3.0~debug~pic+shared build_system=generic arch=linux-ubuntu22.04-sandybridge
^diffutils@3.8%gcc@11.3.0 build_system=autotools arch=linux-ubuntu22.04-sandybridge
^libpng@1.6.37%gcc@11.3.0 build_system=autotools arch=linux-ubuntu22.04-sandybridge
…
Mit spack config get könnt ihr euch die Konfiguration einer bestimmten
Umgebung anschauen:
$ spack config get
# This is a Spack Environment file.
#
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
# add package specs to the `specs` list
specs: [python@3.11.0, py-numpy]
view: true
concretizer:
unify: true
Mit spack config edit kann die Konfigurationsdatei spack.yaml editiert
werden.
Bemerkung
Wenn in der Umgebung bereits Pakete installiert sind, sollten mit spack
concretize -f alle Abhängigkeiten erneut spezifiziert werden.
Laden der Module¶
Mit spack env loads -r <env> werden alle Module mit ihren Abhängigkeiten
geladen.
Bemerkung
Aktuell funktioniert dies jedoch nicht beim Laden der Module aus
Environments, die nicht in $SPACK_ROOT/var/environments liegen.
Daher ersetzen wir das Verzeichnis $SPACK_ROOT/var/environments durch
einen symbolischen Link:
$ rm $SPACK_ROOT/var/environments
$ cd $SPACK_ROOT/var/
$ ln -s /srv/jupyter/jupyter-tutorial/spackenvs environments
Siehe auch