spack.hooks package


spack.hooks.extensions module


spack.hooks.licensing module


This hook symlinks local licenses to the global license for licensed software.


This hook handles global license setup for licensed software.


Prompt the user, letting them know that a license is required.

For packages that rely on license files, a global license file is created and opened for editing.

For packages that rely on environment variables to point to a license, a warning message is printed.

For all other packages, documentation on how to set up a license is printed.

Create local symlinks that point to the global license file.

spack.hooks.licensing.write_license_file(pkg, license_path)[source]

Writes empty license file.

Comments give suggestions on alternative methods of installing a license.

spack.hooks.module_file_generation module


spack.hooks.monitor module

spack.hooks.monitor.on_analyzer_save(pkg, result)[source]

given a package and a result, if we have a spack monitor, upload the result to it.


Triggered on cancel of an install


Triggered on failure of an install


On start of an install, we want to ping the server if it exists


On the success of an install (after everything is complete)

spack.hooks.monitor.on_phase_error(pkg, phase_name, log_file)[source]

Triggered on a phase error

spack.hooks.monitor.on_phase_success(pkg, phase_name, log_file)[source]

Triggered on a phase success

spack.hooks.permissions_setters module


spack.hooks.sbang module

exception spack.hooks.sbang.SbangPathError(message, long_message=None)[source]

Bases: SpackError

Raised when the install tree root is too long for sbang to work.


Adds a second shebang line, using sbang, at the beginning of a file, if necessary. Note: Spack imposes a relaxed shebang line limit, meaning that a newline or end of file must occur before spack_shebang_limit bytes. If not, the file is not patched.

spack.hooks.sbang.filter_shebangs_in_directory(directory, filenames=None)[source]

Ensure that sbang is installed in the root of Spack’s install_tree.

This is the shortest known publicly accessible path, and installing sbang here ensures that users can access the script and that sbang itself is in a short path.

spack.hooks.sbang.is_windows = False

Groupdb does not exist on Windows, prevent imports on supported systems


This hook edits scripts so that they call /bin/bash $spack_prefix/bin/sbang instead of something longer than the shebang limit.


Location sbang should be installed within Spack’s install_tree.


Full shebang line that should be prepended to files to use sbang.

The line returned does not have a final newline (caller should add it if needed).

This should be the only place in Spack that knows about what interpreter we use for sbang.

spack.hooks.sbang.spack_shebang_limit = 4096

Spack itself also limits the shebang line to at most 4KB, which should be plenty.

spack.hooks.write_install_manifest module


Module contents

This package contains modules with hooks for various stages in the Spack install process. You can add modules here and they’ll be executed by package at various times during the package lifecycle.

Each hook is just a function that takes a package as a parameter. Hooks are not executed in any particular order.

Currently the following hooks are supported:

  • pre_install(spec)

  • post_install(spec)

  • pre_uninstall(spec)

  • post_uninstall(spec)

  • on_install_start(spec)

  • on_install_success(spec)

  • on_install_failure(spec)

  • on_phase_success(pkg, phase_name, log_file)

  • on_phase_error(pkg, phase_name, log_file)

  • on_phase_error(pkg, phase_name, log_file)

  • on_analyzer_save(pkg, result)

  • post_env_write(env)

This can be used to implement support for things like module systems (e.g. modules, lmod, etc.) or to add other custom features.