Spack Spec Command
Specs
The commands spack install
and spack uninstall
take a package name with an optional version of the package’s name.
You can also specify the compiler, compiler version, architecture, compile options, and dependency options for a build. In Spack, that descriptor is called a spec
.
Spack uses specs to refer to a particular build configuration (or configurations) of a package.
For example, the following configuration is a spec of the tcl
package.
tcl@8.6.10%gcc@9.2.1 ^zlib@1.2.11%gcc@9.2.1~optimize
If the above spec is provided to spack install
command, it will install tcl
package at version 8.6.10
using gcc
compiler at version 9.2.1
.
Additionally, it says to link tcl
with the zlib
library (which it depends on) if it’s listed as a dependency of tcl
. It also builds zlib
with gcc@9.2.1
with the optimize
option enabled.
A package can be installed using different specs. |
Each spec must start with the package name (tcl
). It also may consist of some optional pieces as shown in the following table:
Option | Description | Example | |
---|---|---|---|
@ |
version specifier |
@8.6.10 |
|
% |
compiler specifier |
%gcc@9.2.1 |
|
|
variant specifiers for boolean variants |
~optimize |
|
name=<value> |
variant specifiers that aren’t restricted to boolean variants |
||
name=<value> |
compiler flag specifiers |
|
|
target=<value> |
architecture specifier |
target=x86_64 |
|
^ |
Dependency specs |
^zlib@1.2.11 |
For more details, visit Spack Documentation.
Spack Spec Command
As mentioned above, a spec of a package should contain the package name and other optional pieces such as version, and compiler specifications.
For example, you can install the zlib
package as follows:
spack install zlib
zlib
is a spec that’s used to install zlib
package. You can see that the version, compiler and its version, dependencies, variants, and flags are missing.
In this case, the default spec will be used to install zlib
.
The general syntax of spack spec
command is:
spack spec [options] <package_spec_or_hash>
The following table shows the options that can be used with spack spec
command.
Flag | Description | |
---|---|---|
-l |
show dependency hashes as well as versions |
|
-L |
show full dependency hashes as well as versions |
|
show install status of packages: [+] installed, [-] not installed |
||
-y |
print concrete spec as YAML |
|
-j |
print concrete spec as JSON |
|
-N |
show fully qualified package names |
|
-t |
show dependency types |
To find the spec that will be used to install the default version of the zlib
package you can run spack spec
as follows:
spack spec zlib
Output:
Input spec
--------------------------------
zlib
Concretized
--------------------------------
zlib@1.2.11%gcc@9.2.1+optimize+pic+shared arch=linux-ubuntu19.10-skylake
The output shows Input spec
which is the spec that you type in the command line. Also, Concretized
which is the concretized version of the Input spec.
You can see in the concretized spec that the package version, compiler, and variants were specified.
To show the concretized spec of zlib@1.2.8
spec, you simply type:
spack spec zlib@1.2.8
Output:
Input spec
--------------------------------
zlib@1.2.8
Concretized
--------------------------------
zlib@1.2.8%gcc@9.2.1+optimize+pic+shared arch=linux-ubuntu19.10-skylake
Consider tcl
as another example, you can find the concretized version of tcl
using its hash.
You first need to find its hash by typing:
spack find -l
Output:
-- linux-centos7-x86_64 / gcc@4.8.5 -----------------------------
w2rk6fp autoconf@2.69 fsuch7d isl@0.20 6uccmsd ncurses@6.2
h5atxgm automake@1.16.2 66scwnb libiconv@1.16 emv5ut4 perl@5.32.0
bwuaqje berkeley-db@18.1.40 lctnabj libsigsegv@2.12 vztwdsa pkgconf@1.7.3
7g5yr5g diffutils@3.7 bcbiddk libtool@2.4.6 ojil344 readline@8.0
vxq35mm gcc@9.3.0 kafywd7 m4@1.4.18 3vbkxar tcl@8.6.10
...
From the above output, you can see that 3vbkxar
is the hash of the installed package tcl
.
To find the spec of that package and show dependency hashes as well as versions using its hash, you type:
spack spec -l /3vbkxar
Output:
3vbkxar tcl@8.6.10%gcc@4.8.5 arch=linux-centos7-x86_64
64vg6e4 ^zlib@1.2.11%gcc@4.8.5+optimize+pic+shared arch=linux-centos7-x86_64
The above output shows the dependencies of the tcl
package along with their hashes. You can also look at the spec of a dependency using its hash.
To find the spec of zlib
and check if it’s installed or not, you type:
spack spec -I /64vg6e4
The following output shows that the package has been installed [+]
.
Input spec
--------------------------------
[+] zlib@1.2.11%gcc@4.8.5+optimize+pic+shared arch=linux-centos7-x86_64
Concretized
--------------------------------
[+] zlib@1.2.11%gcc@4.8.5+optimize+pic+shared arch=linux-centos7-x86_64