Spack is a package manager for supercomputers, Linux, and macOS. It makes installing scientific software easy. With Spack, you can build a package with multiple versions, configurations, platforms, and compilers, and all of these builds can coexist on the same machine.

Spack isn't tied to a particular language; you can build a software stack in Python or R, link to libraries written in C, C++, or Fortran, and easily swap compilers. Use Spack to install in your home directory, to manage shared installations and modules on a cluster, or to build combinatorial versions of software for testing.

Install Spack

Clone Spack from github and you’re ready to go:

git clone https://github.com/spack/spack.git
. spack/share/spack/setup-env.sh
spack install hdf5

Custom versions & configurations

Spack allows installation to be customized. Users can specify the version, build compiler, compile-time options, and cross-compile platform, all on the command line.

   # Install a specific version by appending @
   $ spack install hdf5@1.10.1

   # Specify a compiler (and optional version), with %
   $ spack install hdf5@1.10.1 %gcc@4.7.3

   # Add special boolean compile-time options with +
   $ spack install hdf5@1.10.1 %gcc@4.7.3 +szip

   # Add custom compiler flags
   $ spack install hdf5@1.10.1 %gcc@4.7.3 cppflags="-O3 -floop-block"

   # Cross-compile for compute nodes on a Cray or Blue Gene/Q
   $ spack install hdf5@1.10.1 target=backend

Users can specify as many or few options as they care about. Spack will fill in the unspecified values with sensible defaults. The two listed syntaxes for variants are identical when the value is boolean.

Customize dependencies

Spack allows dependencies of particular installations to be customized extensively. Suppose that mpileaks depends indirectly on libelf and libdwarf. Using ^, users can add custom configurations for the dependencies:

   # Install mpileaks and link it with specific versions of libelf and libdwarf
   $ spack install mpileaks@1.1.2 %gcc@4.7.3 +debug ^libelf@0.8.12 ^libdwarf@20130729+debug

Packages can peacefully coexist

Spack installs every unique package/dependency configuration into its own prefix, so new installs will not break existing ones.

Spack avoids library misconfiguration by using RPATH to link dependencies. When a user links a library or runs a program, it is tied to the dependencies it was built with, so there is no need to manipulate LD_LIBRARY_PATH at runtime.

Creating packages is easy

Spack packages are simple Python scripts. The spack create command will generate boilerplate to get you started, and you can create a package in a matter of minutes. You write the build instructions; Spack builds the dependencies for you.

from spack import *

class Kripke(Package):
    """Kripke is a simple, scalable, 3D Sn deterministic particle
       transport proxy/mini app.
    """
    homepage = "https://codesign.llnl.gov/kripke.php"
    url      = "https://codesign.llnl.gov/downloads/kripke-openmp-1.1.tar.gz"

    version('1.1', '7fe6f2b26ed983a6ce5495ab701f85bf')

    variant('mpi',    default=True, description='Build with MPI.')
    variant('openmp', default=True, description='Build with OpenMP enabled.')

    depends_on('mpi', when="+mpi")

    def install(self, spec, prefix):
        with working_dir('build', create=True):
            cmake('-DCMAKE_INSTALL_PREFIX:PATH=.',
                  '-DENABLE_OPENMP=%s' % ('+openmp' in spec),
                  '-DENABLE_MPI=%s'    % ('+mpi' in spec),
                  '..',
                  *std_cmake_args)

            make()
            mkdirp(prefix.bin)
            install('kripke', prefix.bin)

Get Involved!

Visit Spack on GitHub and take the tutoral. Join the discussion on the the Google Group, and learn to contribute your own packages.