在日常支持中,我们可能需要安装Python、GCC等工具。通常步骤是
一圈下来,耗时不少。
它是一个自动化包管理器,支持管理Linux、MacOS上的包。
Spack能使得上述步骤自动化,并自动生成modulefile(Environment Modules或Lmod的,都可以生成)——无论是对于广泛使用的开源包,还是有知识产权保护的有限范围分发包,还是处于研发阶段的内部包,它都能轻松搞定。
本文以安装开源包Python为例,来感受一下自动安装的魅力,
先看已有的Python版本
[thesre@localhost ~]$ module avail python
-------------------------------------------- /app/spack-0.16.2/share/spack/modules/linux-centos7-sandybridge --------------------------------------------
python-3.8.6-gcc-9.4.0-x7ebx7b
[thesre@localhost ~]$
安装Python 3.9.0
[thesre@localhost ~]$ spack -k install python@3.9.0
==> Warning: You asked for --insecure. Will NOT check SSL certificates.
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/libiconv-1.16-qp6xhw7243p2s3jrfygxcor3f723zy4y
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/libbsd-0.10.0-ot7ls7bw4butgierpa4cmjluqvsjoaji
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/pkgconf-1.7.3-vdqtrqwkkhqy3g4i5jjj3t3siptzpgxm
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/xz-5.2.5-ds3jrbkvzlrnklirwgnagoj67ngbx6gb
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/zlib-1.2.11-wrpx7fqamc562dxcn3qwyl5dzfswl5qh
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/libffi-3.3-s7scryukxbekp7u3hlq5czx5fyz2cyzi
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/libuuid-1.0.3-rssfovgso7ojag5ybguj4qpoptzyliab
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/berkeley-db-18.1.40-gfcdrmlydcd4smrmzkziudw6zedihsmv
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/diffutils-3.7-qhfscuxrwvf5y3y3jywz5fiqqgvy6wvj
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/tar-1.32-n6b45i35ks4is5u5taaqd6mzfw44fzlk
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/expat-2.2.10-cal2lrbnkmhqomqhpw4buidkwd256fvu
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/ncurses-6.2-idwc6kcoigxcy43iau4bmlvkocu4olg5
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/libxml2-2.9.10-miqastwta7pzpo4nvqt2bwnkyohwute7
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/bzip2-1.0.8-bt2hrgk32n4zue4w53q4ev7ylidvyv6e
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/readline-8.0-cf4ys6umtgnbq42uxy55ar6yrko2cae5
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/gettext-0.21-cnwqlvg22ivf2a6cygxcphkmx4l5m36p
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/sqlite-3.33.0-wbvmbd6rjewg6fqpciwa72slwpbinhac
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/gdbm-1.18.1-brzlhvhm5mppt7aml2yqz5tlztqrolne
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/perl-5.32.0-gg2xi5suigorukjnv3irvkgv6ebsb2st
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/openssl-1.1.1h-7p3yykxrgamue5lapcnfeh5zhkhohipr
==> Installing python-3.9.0-wz6q56w5ytjm5mh2us44r2df5ntcwvfl
==> No binary for python-3.9.0-wz6q56w5ytjm5mh2us44r2df5ntcwvfl found: installing from source
==> Using cached archive: /app/spack-0.16.2/var/spack/cache/_source-cache/archive/df/df796b2dc8ef085edae2597a41c1c0a63625ebd92487adaef2fed22b567873e8.tgz
==> python: Executing phase: 'autoreconf'
==> python: Executing phase: 'configure'
==> python: Executing phase: 'build'
==> python: Executing phase: 'install'
[+] /app/spack-0.16.2/opt/spack/linux-centos7-sandybridge/gcc-9.4.0/python-3.9.0-wz6q56w5ytjm5mh2us44r2df5ntcwvfl
[thesre@localhost ~]$
可以看到多了一个版本,是刚刚安装的Python 3.9.0,其modulename为python-3.9.0-gcc-9.4.0-wz6q56w
[thesre@localhost ~]$ module avail python
-------------------------------------------- /app/spack-0.16.2/share/spack/modules/linux-centos7-sandybridge --------------------------------------------
python-3.8.6-gcc-9.4.0-x7ebx7b python-3.9.0-gcc-9.4.0-wz6q56w
101资料:https://spack-tutorial.readthedocs.io/en/latest/#tutorial-spack-101
spack能为
的组合自动生成依赖DAG(单向无环图),并为安装的每一个包名自动打上哈希码,以确保不会冲突。
以上面例子为例,安装Python 3.9.0,并装上了其n个依赖包(全都已经安装好了的)。假如将上述组合中的任何一个更改,都会生成一个新的DAG。