spack.cmd package

exception spack.cmd.CommandNameError(name)[source]

Bases: SpackError

Exception class thrown for impermissible command names

exception spack.cmd.PythonNameError(name)[source]

Bases: SpackError

Exception class thrown for impermissible python names

spack.cmd.all_commands()[source]

Get a sorted list of all spack commands.

This will list the lib/spack/spack/cmd directory and find the commands there to construct the list. It does not actually import the python files – just gets the names.

spack.cmd.cmd_name(python_name)[source]

Convert module name (with _) to command name (with -).

spack.cmd.disambiguate_spec(spec, env, local=False, installed=True, first=False)[source]

Given a spec, figure out which installed package it refers to.

Parameters:
spack.cmd.disambiguate_spec_from_hashes(spec, hashes, local=False, installed=True, first=False)[source]

Given a spec and a list of hashes, get concrete spec the spec refers to.

Parameters:
  • spec (spack.spec.Spec) – a spec to disambiguate

  • hashes (Iterable) – a set of hashes of specs among which to disambiguate

  • local (bool) – do not search chained spack instances

  • installed (bool or spack.database.InstallStatus or Iterable) – install status argument passed to database query. See spack.database.Database._query for details.

spack.cmd.display_specs(specs, args=None, **kwargs)[source]

Display human readable specs with customizable formatting.

Prints the supplied specs to the screen, formatted according to the arguments provided.

Specs are grouped by architecture and compiler, and columnized if possible.

Options can add more information to the default display. Options can be provided either as keyword arguments or as an argparse namespace. Keyword arguments take precedence over settings in the argparse namespace.

Parameters:
  • specs (list) – the specs to display

  • args (argparse.Namespace or None) – namespace containing formatting arguments

Keyword Arguments:
  • paths (bool) – Show paths with each displayed spec

  • deps (bool) – Display dependencies with specs

  • long (bool) – Display short hashes with specs

  • very_long (bool) – Display full hashes with specs (supersedes long)

  • namespaces (bool) – Print namespaces along with names

  • show_flags (bool) – Show compiler flags with specs

  • variants (bool) – Show variants with specs

  • indent (int) – indent each line this much

  • groups (bool) – display specs grouped by arch/compiler (default True)

  • decorator (Callable) – function to call to decorate specs

  • all_headers (bool) – show headers even when arch/compiler aren’t defined

  • output (IO) – A file object to write to. Default is sys.stdout

spack.cmd.display_specs_as_json(specs, deps=False)[source]

Convert specs to a list of json records.

spack.cmd.ensure_single_spec_or_die(spec, matching_specs)[source]
spack.cmd.extant_file(f)[source]

Argparse type for files that exist.

spack.cmd.filter_loaded_specs(specs)[source]

Filter a list of specs returning only those that are currently loaded.

spack.cmd.find_environment(args)[source]

Find active environment from args or environment variable.

Check for an environment in this order:
  1. via spack -e ENV or spack -D DIR (arguments)

  2. via a path in the spack.environment.spack_env_var environment variable.

If an environment is found, read it in. If not, return None.

Parameters:

args (argparse.Namespace) – argparse namespace with command arguments

Returns:

a found environment, or None

Return type:

(spack.environment.Environment)

spack.cmd.first_line(docstring)[source]

Return the first line of the docstring.

spack.cmd.get_command(cmd_name)[source]

Imports the command function associated with cmd_name.

The function’s name is derived from cmd_name using python_name().

Parameters:

cmd_name (str) – name of the command (contains -, not _).

spack.cmd.get_module(cmd_name)[source]

Imports the module for a particular command name and returns it.

Parameters:

cmd_name (str) – name of the command for which to get a module (contains -, not _).

spack.cmd.gray_hash(spec, length)[source]
spack.cmd.is_git_repo(path)[source]
spack.cmd.iter_groups(specs, indent, all_headers)[source]

Break a list of specs into groups indexed by arch/compiler.

spack.cmd.matching_spec_from_env(spec)[source]

Returns a concrete spec, matching what is available in the environment. If no matching spec is found in the environment (or if no environment is active), this will return the given spec but concretized.

spack.cmd.parse_specs(args: str | List[str], concretize: bool = False, tests: bool = False) List[Spec][source]

Convenience function for parsing arguments from specs. Handles common exceptions and dies if there are errors.

spack.cmd.print_how_many_pkgs(specs, pkg_type='', suffix='')[source]

Given a list of specs, this will print a message about how many specs are in that list.

Parameters:
  • specs (list) – depending on how many items are in this list, choose the plural or singular form of the word “package”

  • pkg_type (str) – the output string will mention this provided category, e.g. if pkg_type is “installed” then the message would be “3 installed packages”

spack.cmd.python_name(cmd_name)[source]

Convert - to _ in command name, to make a valid identifier.

spack.cmd.quote_kvp(string: str) str[source]

For strings like name=value or name==value, quote and escape the value if needed.

This is a compromise to respect quoting of key-value pairs on the CLI. The shell strips quotes from quoted arguments, so we cannot know exactly how CLI arguments were quoted. To compensate, we re-add quotes around anything staritng with name= or name==, and we assume the rest of the argument is the value. This covers the common cases of passign flags, e.g., cflags="-O2 -g" on the command line.

spack.cmd.remove_options(parser, *options)[source]

Remove some options from a parser.

spack.cmd.require_active_env(cmd_name)[source]

Used by commands to get the active environment

If an environment is not found, print an error message that says the calling command needs an active environment.

Parameters:

cmd_name (str) – name of calling command

Returns:

the active environment

Return type:

(spack.environment.Environment)

spack.cmd.require_cmd_name(cname)[source]

Require that the provided name is a valid command name (per cmd_name()). Useful for checking parameters for function prerequisites.

spack.cmd.require_python_name(pname)[source]

Require that the provided name is a valid python name (per python_name()). Useful for checking parameters for function prerequisites.

spack.cmd.spack_is_git_repo()[source]

Ensure that this instance of Spack is a git clone.

Subpackages

Submodules

spack.cmd.add module

spack.cmd.add.add(parser, args)[source]
spack.cmd.add.setup_parser(subparser)[source]

spack.cmd.arch module

spack.cmd.arch.arch(parser, args)[source]
spack.cmd.arch.display_targets(targets)[source]

Prints a human readable list of the targets passed as argument.

spack.cmd.arch.setup_parser(subparser)[source]

spack.cmd.audit module

spack.cmd.audit.audit(parser, args)[source]
spack.cmd.audit.configs(parser, args)[source]
spack.cmd.audit.externals(parser, args)[source]
spack.cmd.audit.list(parser, args)[source]
spack.cmd.audit.packages(parser, args)[source]
spack.cmd.audit.packages_https(parser, args)[source]
spack.cmd.audit.setup_parser(subparser)[source]

spack.cmd.blame module

spack.cmd.blame.blame(parser, args)[source]
spack.cmd.blame.dump_json(rows, last_mod, total_lines, emails)[source]

Dump the blame as a json object to the terminal.

spack.cmd.blame.print_table(rows, last_mod, total_lines, emails)[source]

Given a set of rows with authors and lines, print a table.

spack.cmd.blame.setup_parser(subparser)[source]

spack.cmd.bootstrap module

spack.cmd.bootstrap.LOCAL_MIRROR_DIR = 'bootstrap_cache'

Subdirectory where to create the mirror

spack.cmd.bootstrap.bootstrap(parser, args)[source]
spack.cmd.bootstrap.setup_parser(subparser)[source]

spack.cmd.build_env module

spack.cmd.build_env.build_env(parser, args)[source]

spack.cmd.buildcache module

class spack.cmd.buildcache.NoPool[source]

Bases: object

map(func, args)[source]
starmap(func, args)[source]
spack.cmd.buildcache.buildcache(parser, args)[source]
spack.cmd.buildcache.check_fn(args: Namespace)[source]

check specs against remote binary mirror(s) to see if any need to be rebuilt

this command uses the process exit code to indicate its result, specifically, if the exit code is non-zero, then at least one of the indicated specs needs to be rebuilt

spack.cmd.buildcache.copy_buildcache_file(src_url, dest_url, local_path=None)[source]

Copy from source url to destination url

spack.cmd.buildcache.download_fn(args)[source]

download buildcache entry from a remote mirror to local folder

this command uses the process exit code to indicate its result, specifically, a non-zero exit code indicates that the command failed to download at least one of the required buildcache components

spack.cmd.buildcache.get_buildcache_name_fn(args)[source]

get name (prefix) of buildcache entries for this spec

spack.cmd.buildcache.install_fn(args)[source]

install from a binary package

spack.cmd.buildcache.keys_fn(args)[source]

get public keys available on mirrors

spack.cmd.buildcache.list_fn(args)[source]

list binary packages available from mirrors

spack.cmd.buildcache.manifest_copy(manifest_file_list, dest_mirror=None)[source]

Read manifest files containing information about specific specs to copy from source to destination, remove duplicates since any binary packge for a given hash should be the same as any other, and copy all files specified in the manifest files.

spack.cmd.buildcache.preview_fn(args)[source]

analyze an installed spec and reports whether executables and libraries are relocatable

spack.cmd.buildcache.push_fn(args)[source]

create a binary package and push it to a mirror

spack.cmd.buildcache.save_specfile_fn(args)[source]

get full spec for dependencies and write them to files in the specified output directory

uses exit code to signal success or failure. an exit code of zero means the command was likely successful. if any errors or exceptions are encountered, or if expected command-line arguments are not provided, then the exit code will be non-zero

spack.cmd.buildcache.setup_parser(subparser: ArgumentParser)[source]
spack.cmd.buildcache.sync_fn(args)[source]

sync binaries (and associated metadata) from one mirror to another

requires an active environment in order to know which specs to sync

spack.cmd.buildcache.update_index(mirror: Mirror, update_keys=False)[source]
spack.cmd.buildcache.update_index_fn(args)[source]

update a buildcache index

spack.cmd.cd module

spack.cmd.cd.cd(parser, args)[source]
spack.cmd.cd.setup_parser(subparser)[source]

This is for decoration – spack cd is used through spack’s shell support. This allows spack cd to print a descriptive help message when called with -h.

spack.cmd.change module

spack.cmd.change.change(parser, args)[source]
spack.cmd.change.setup_parser(subparser)[source]

spack.cmd.checksum module

spack.cmd.checksum.add_versions_to_package(pkg: PackageBase, version_lines: str, is_batch: bool)[source]

Add checksumed versions to a package’s instructions and open a user’s editor so they may double check the work of the function.

Parameters:
spack.cmd.checksum.checksum(parser, args)[source]
spack.cmd.checksum.print_checksum_status(pkg: PackageBase, version_hashes: dict)[source]

Verify checksums present in version_hashes against those present in the package’s instructions.

Parameters:
spack.cmd.checksum.setup_parser(subparser)[source]

spack.cmd.ci module

spack.cmd.ci.ci(parser, args)[source]
spack.cmd.ci.ci_generate(args)[source]

generate jobs file from a CI-aware spack file

if you want to report the results on CDash, you will need to set the SPACK_CDASH_AUTH_TOKEN before invoking this command. the value must be the CDash authorization token needed to create a build group and register all generated jobs under it

spack.cmd.ci.ci_rebuild(args)[source]

rebuild a spec if it is not on the remote mirror

check a single spec against the remote mirror, and rebuild it from source if the mirror does not contain the hash

spack.cmd.ci.ci_reindex(args)[source]

rebuild the buildcache index for the remote mirror

use the active, gitlab-enabled environment to rebuild the buildcache index for the associated mirror

spack.cmd.ci.ci_reproduce(args)[source]

generate instructions for reproducing the spec rebuild job

artifacts of the provided gitlab pipeline rebuild job’s URL will be used to derive instructions for reproducing the build locally

spack.cmd.ci.deindent(desc)[source]
spack.cmd.ci.setup_parser(subparser)[source]
spack.cmd.ci.unicode_escape(path: str) str[source]

Returns transformed path with any unicode characters replaced with their corresponding escapes

spack.cmd.clean module

class spack.cmd.clean.AllClean(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]

Bases: Action

Activates flags -s -d -f -m and -p simultaneously

spack.cmd.clean.clean(parser, args)[source]
spack.cmd.clean.remove_python_cache()[source]
spack.cmd.clean.setup_parser(subparser)[source]

spack.cmd.clone module

spack.cmd.clone.clone(parser, args)[source]
spack.cmd.clone.get_origin_info(remote)[source]
spack.cmd.clone.setup_parser(subparser)[source]

spack.cmd.commands module

class spack.cmd.commands.BashCompletionWriter(prog: str, out: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, aliases: bool = False)[source]

Bases: ArgparseWriter

Write argparse output as bash programmable tab completion.

body(positionals: Sequence[str], optionals: Sequence[str], subcommands: Sequence[str]) str[source]

Return the body of the function.

Parameters:
  • positionals – List of positional arguments.

  • optionals – List of optional arguments.

  • subcommands – List of subcommand parsers.

Returns:

Function body.

end_function(prog: str) str[source]

Return the syntax needed to end a function definition.

Parameters:

prog – Program name

Returns:

Function definition ending.

format(cmd: Command) str[source]

Return the string representation of a single node in the parser tree.

Parameters:

cmd – Parsed information about a command or subcommand.

Returns:

String representation of this subcommand.

optionals(optionals: Sequence[str]) str[source]

Return the syntax for reporting optional flags.

Parameters:

optionals – List of optional arguments.

Returns:

Syntax for optional flags.

positionals(positionals: Sequence[str]) str[source]

Return the syntax for reporting positional arguments.

Parameters:

positionals – List of positional arguments.

Returns:

Syntax for positional arguments.

start_function(prog: str) str[source]

Return the syntax needed to begin a function definition.

Parameters:

prog – Program name.

Returns:

Function definition beginning.

subcommands(subcommands: Sequence[str]) str[source]

Return the syntax for reporting subcommands.

Parameters:

subcommands – List of subcommand parsers.

Returns:

Syntax for subcommand parsers

class spack.cmd.commands.FishCompletionWriter(prog: str, out: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, aliases: bool = False)[source]

Bases: ArgparseWriter

Write argparse output as bash programmable tab completion.

complete(prog: str, positionals: List[Tuple[str, Iterable[Any] | None, int | str | None, str]], optionals: List[Tuple[Sequence[str], List[str], str, int | str | None, str]], subcommands: List[Tuple[ArgumentParser, str, str]]) str[source]

Return all the completion commands.

Parameters:
  • prog – Program name.

  • positionals – List of positional arguments.

  • optionals – List of optional arguments.

  • subcommands – List of subcommand parsers.

Returns:

Completion command.

static complete_head(prog: str, index: int | None = None, nargs: int | str | None = None) str[source]

Return the head of the completion command.

Parameters:
  • prog – Program name.

  • index – Index of positional argument.

  • nargs – Number of arguments.

Returns:

Head of the completion command.

format(cmd: Command) str[source]

Return the string representation of a single node in the parser tree.

Parameters:

cmd – Parsed information about a command or subcommand.

Returns:

String representation of a node.

optionals(prog: str, optionals: List[Tuple[Sequence[str], List[str], str, int | str | None, str]]) str[source]

Return the completion for optional arguments.

Parameters:
  • prog – Program name.

  • optionals – List of optional arguments.

Returns:

Completion command.

optspecs(prog: str, optionals: List[Tuple[Sequence[str], List[str], str, int | str | None, str]]) str[source]

Read the optionals and return the command to set optspec.

Parameters:
  • prog – Program name.

  • optionals – List of optional arguments.

Returns:

Command to set optspec variable.

positionals(prog: str, positionals: List[Tuple[str, Iterable[Any] | None, int | str | None, str]]) str[source]

Return the completion for positional arguments.

Parameters:
  • prog – Program name.

  • positionals – List of positional arguments.

Returns:

Completion command.

prog_comment(prog: str) str[source]

Return a comment line for the command.

Parameters:

prog – Program name.

Returns:

Comment line.

subcommands(prog: str, subcommands: List[Tuple[ArgumentParser, str, str]]) str[source]

Return the completion for subcommands.

Parameters:
  • prog – Program name.

  • subcommands – List of subcommand parsers.

Returns:

Completion command.

class spack.cmd.commands.SpackArgparseRstWriter(prog: str, out: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, aliases: bool = False, documented_commands: ~typing.Set[str] = {}, rst_levels: ~typing.Sequence[str] = ['-', '-', '^', '~', ':', '`'])[source]

Bases: ArgparseRstWriter

RST writer tailored for spack documentation.

usage(usage: str) str[source]

Example usage of a command.

Parameters:

usage – Command usage.

Returns:

Usage of a command.

class spack.cmd.commands.SubcommandWriter(prog: str, out: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, aliases: bool = False)[source]

Bases: ArgparseWriter

Write argparse output as a list of subcommands.

format(cmd: Command) str[source]

Return the string representation of a single node in the parser tree.

Parameters:

cmd – Parsed information about a command or subcommand.

Returns:

String representation of this subcommand.

spack.cmd.commands.bash(args: Namespace, out: IO) None[source]

Bash tab-completion script.

Parameters:
  • args – Command-line arguments.

  • out – File object to write to.

spack.cmd.commands.commands(parser: ArgumentParser, args: Namespace) None[source]

Main function that calls formatter functions.

Parameters:
  • parser – Argument parser.

  • args – Command-line arguments.

spack.cmd.commands.fish(args, out)[source]
spack.cmd.commands.formatter(func: Callable[[Namespace, IO], None]) Callable[[Namespace, IO], None][source]

Decorator used to register formatters.

Parameters:

func – Formatting function.

Returns:

The same function.

spack.cmd.commands.formatters: Dict[str, Callable[[Namespace, IO], None]] = {'bash': <function bash>, 'fish': <function fish>, 'names': <function names>, 'rst': <function rst>, 'subcommands': <function subcommands>}

list of command formatters

spack.cmd.commands.names(args: Namespace, out: IO) None[source]

Simple list of top-level commands.

Parameters:
  • args – Command-line arguments.

  • out – File object to write to.

spack.cmd.commands.prepend_header(args: Namespace, out: IO) None[source]

Prepend header text at the beginning of a file.

Parameters:
  • args – Command-line arguments.

  • out – File object to write to.

spack.cmd.commands.rst(args: Namespace, out: IO) None[source]

ReStructuredText documentation of subcommands.

Parameters:
  • args – Command-line arguments.

  • out – File object to write to.

spack.cmd.commands.rst_index(out: IO) None[source]

Generate an index of all commands.

Parameters:

out – File object to write to.

spack.cmd.commands.setup_parser(subparser: ArgumentParser) None[source]

Set up the argument parser.

Parameters:

subparser – Preliminary argument parser.

spack.cmd.commands.subcommands(args: Namespace, out: IO) None[source]

Hierarchical tree of subcommands.

Parameters:
  • args – Command-line arguments.

  • out – File object to write to.

spack.cmd.commands.update_completion(parser: ArgumentParser, args: Namespace) None[source]

Iterate through the shells and update the standard completion files.

This is a convenience method to avoid calling this command many times, and to simplify completion update for developers.

Parameters:
  • parser – Argument parser.

  • args – Command-line arguments.

spack.cmd.commands.update_completion_args: Dict[str, Dict[str, Any]] = {'bash': {'aliases': True, 'format': 'bash', 'header': '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/latest/lib/spack/docs/_spack_root/share/spack/bash/spack-completion.bash', 'update': '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/latest/lib/spack/docs/_spack_root/share/spack/spack-completion.bash'}, 'fish': {'aliases': True, 'format': 'fish', 'header': '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/latest/lib/spack/docs/_spack_root/share/spack/fish/spack-completion.fish', 'update': '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/latest/lib/spack/docs/_spack_root/share/spack/spack-completion.fish'}}

standard arguments for updating completion scripts we iterate through these when called with –update-completion

spack.cmd.compiler module

spack.cmd.compiler.compiler(parser, args)[source]
spack.cmd.compiler.compiler_find(args)[source]

Search either $PATH or a list of paths OR MODULES for compilers and add them to Spack’s configuration.

spack.cmd.compiler.compiler_info(args)[source]

Print info about all compilers matching a spec.

spack.cmd.compiler.compiler_list(args)[source]
spack.cmd.compiler.compiler_remove(args)[source]
spack.cmd.compiler.setup_parser(subparser)[source]

spack.cmd.compilers module

spack.cmd.compilers.compilers(parser, args)[source]
spack.cmd.compilers.setup_parser(subparser)[source]

spack.cmd.concretize module

spack.cmd.concretize.concretize(parser, args)[source]
spack.cmd.concretize.setup_parser(subparser)[source]

spack.cmd.config module

spack.cmd.config.config(parser, args)[source]
spack.cmd.config.config_add(args)[source]

Add the given configuration to the specified config scope

This is a stateful operation that edits the config files.

spack.cmd.config.config_blame(args)[source]

Print out line-by-line blame of merged YAML.

spack.cmd.config.config_change(args)[source]
spack.cmd.config.config_edit(args)[source]

Edit the configuration file for a specific scope and config section.

With no arguments and an active environment, edit the spack.yaml for the active environment.

spack.cmd.config.config_get(args)[source]

Dump merged YAML configuration for a specific section.

With no arguments and an active environment, print the contents of the environment’s manifest file (spack.yaml).

spack.cmd.config.config_list(args)[source]

List the possible configuration sections.

Used primarily for shell tab completion scripts.

spack.cmd.config.config_prefer_upstream(args)[source]

Generate a packages config based on the configuration of all upstream installs.

spack.cmd.config.config_remove(args)[source]

Remove the given configuration from the specified config scope

This is a stateful operation that edits the config files.

spack.cmd.config.config_revert(args)[source]
spack.cmd.config.config_update(args)[source]
spack.cmd.config.print_configuration(args, *, blame: bool) None[source]
spack.cmd.config.print_flattened_configuration(*, blame: bool) None[source]

Prints to stdout a flattened version of the configuration.

Parameters:

blame – if True, shows file provenance for each entry in the configuration.

spack.cmd.config.setup_parser(subparser)[source]

spack.cmd.containerize module

spack.cmd.containerize.containerize(parser, args)[source]
spack.cmd.containerize.setup_parser(subparser)[source]

spack.cmd.create module

class spack.cmd.create.AutoreconfPackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for Autotools-based packages that do not come with a configure script

base_class_name = 'AutotoolsPackage'
body_def = '    def autoreconf(self, spec, prefix):\n        # FIXME: Modify the autoreconf method as necessary\n        autoreconf("--install", "--verbose", "--force")\n\n    def configure_args(self):\n        # FIXME: Add arguments other than --prefix\n        # FIXME: If not needed delete this function\n        args = []\n        return args'
dependencies = '    depends_on("autoconf", type="build")\n    depends_on("automake", type="build")\n    depends_on("libtool", type="build")\n    depends_on("m4", type="build")\n\n    # FIXME: Add additional dependencies if required.\n    # depends_on("foo")'
class spack.cmd.create.AutotoolsPackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for Autotools-based packages that do come with a configure script

base_class_name = 'AutotoolsPackage'
body_def = '    def configure_args(self):\n        # FIXME: Add arguments other than --prefix\n        # FIXME: If not needed delete this function\n        args = []\n        return args'
class spack.cmd.create.BazelPackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for Bazel-based packages

body_def = '    def install(self, spec, prefix):\n        # FIXME: Add logic to build and install here.\n        bazel()'
dependencies = '    # FIXME: Add additional dependencies if required.\n    depends_on("bazel", type="build")'
class spack.cmd.create.BuildSystemGuesser[source]

Bases: object

An instance of BuildSystemGuesser provides a callable object to be used during spack create. By passing this object to spack checksum, we can take a peek at the fetched tarball and discern the build system it uses

class spack.cmd.create.BundlePackageTemplate(name, versions)[source]

Bases: object

Provides the default values to be used for a bundle package file template.

base_class_name = 'BundlePackage'
body_def = '    # There is no need for install() since there is no code.'
dependencies = '    # FIXME: Add dependencies if required.\n    # depends_on("foo")'
url_def = '    # There is no URL since there is no code to download.'
write(pkg_path)[source]

Writes the new package file.

class spack.cmd.create.CMakePackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for CMake-based packages

base_class_name = 'CMakePackage'
body_def = '    def cmake_args(self):\n        # FIXME: Add arguments other than\n        # FIXME: CMAKE_INSTALL_PREFIX and CMAKE_BUILD_TYPE\n        # FIXME: If not needed delete this function\n        args = []\n        return args'
class spack.cmd.create.CargoPackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for cargo-based packages

base_class_name = 'CargoPackage'
body_def = ''
class spack.cmd.create.GoPackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for Go-module-based packages

base_class_name = 'GoPackage'
body_def = ''
class spack.cmd.create.IntelPackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for licensed Intel software

base_class_name = 'IntelPackage'
body_def = '    # FIXME: Override `setup_environment` if necessary.'
class spack.cmd.create.LuaPackageTemplate(name, url, *args, **kwargs)[source]

Bases: PackageTemplate

Provides appropriate overrides for LuaRocks-based packages

base_class_name = 'LuaPackage'
body_def = '    def luarocks_args(self):\n        # FIXME: Add arguments to `luarocks make` other than rockspec path\n        # FIXME: If not needed delete this function\n        args = []\n        return args'
class spack.cmd.create.MakefilePackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for Makefile packages

base_class_name = 'MakefilePackage'
body_def = '    def edit(self, spec, prefix):\n        # FIXME: Edit the Makefile if necessary\n        # FIXME: If not needed delete this function\n        # makefile = FileFilter("Makefile")\n        # makefile.filter("CC = .*", "CC = cc")\n        pass'
class spack.cmd.create.MavenPackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for Maven-based packages

base_class_name = 'MavenPackage'
body_def = '    def build(self, spec, prefix):\n        # FIXME: If not needed delete this function\n        pass'
class spack.cmd.create.MesonPackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for meson-based packages

base_class_name = 'MesonPackage'
body_def = '    def meson_args(self):\n        # FIXME: If not needed delete this function\n        args = []\n        return args'
class spack.cmd.create.OctavePackageTemplate(name, *args, **kwargs)[source]

Bases: PackageTemplate

Provides appropriate overrides for octave packages

base_class_name = 'OctavePackage'
dependencies = '    extends("octave")\n\n    # FIXME: Add additional dependencies if required.\n    # depends_on("octave-foo", type=("build", "run"))'
class spack.cmd.create.PackageTemplate(name, url, versions)[source]

Bases: BundlePackageTemplate

Provides the default values to be used for the package file template

base_class_name = 'Package'
body_def = '    def install(self, spec, prefix):\n        # FIXME: Unknown build system\n        make()\n        make("install")'
url_line = '    url = "{url}"'
class spack.cmd.create.PerlbuildPackageTemplate(name, *args, **kwargs)[source]

Bases: PerlmakePackageTemplate

Provides appropriate overrides for Perl extensions that come with a Build.PL instead of a Makefile.PL

dependencies = '    depends_on("perl-module-build", type="build")\n\n    # FIXME: Add additional dependencies if required:\n    # depends_on("perl-foo", type=("build", "run"))'
class spack.cmd.create.PerlmakePackageTemplate(name, *args, **kwargs)[source]

Bases: PackageTemplate

Provides appropriate overrides for Perl extensions that come with a Makefile.PL

base_class_name = 'PerlPackage'
body_def = '    def configure_args(self):\n        # FIXME: Add non-standard arguments\n        # FIXME: If not needed delete this function\n        args = []\n        return args'
dependencies = '    # FIXME: Add dependencies if required:\n    # depends_on("perl-foo", type=("build", "run"))'
class spack.cmd.create.PythonPackageTemplate(name, url, *args, **kwargs)[source]

Bases: PackageTemplate

Provides appropriate overrides for python extensions

base_class_name = 'PythonPackage'
body_def = '    def config_settings(self, spec, prefix):\n        # FIXME: Add configuration settings to be passed to the build backend\n        # FIXME: If not needed, delete this function\n        settings = {}\n        return settings'
dependencies = '    # FIXME: Only add the python/pip/wheel dependencies if you need specific versions\n    # or need to change the dependency type. Generic python/pip/wheel dependencies are\n    # added implicity by the PythonPackage base class.\n    # depends_on("python@2.X:2.Y,3.Z:", type=("build", "run"))\n    # depends_on("py-pip@X.Y:", type="build")\n    # depends_on("py-wheel@X.Y:", type="build")\n\n    # FIXME: Add a build backend, usually defined in pyproject.toml. If no such file\n    # exists, use setuptools.\n    # depends_on("py-setuptools", type="build")\n    # depends_on("py-hatchling", type="build")\n    # depends_on("py-flit-core", type="build")\n    # depends_on("py-poetry-core", type="build")\n\n    # FIXME: Add additional dependencies if required.\n    # depends_on("py-foo", type=("build", "run"))'
class spack.cmd.create.QMakePackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for QMake-based packages

base_class_name = 'QMakePackage'
body_def = '    def qmake_args(self):\n        # FIXME: If not needed delete this function\n        args = []\n        return args'
class spack.cmd.create.RPackageTemplate(name, url, *args, **kwargs)[source]

Bases: PackageTemplate

Provides appropriate overrides for R extensions

base_class_name = 'RPackage'
body_def = '    def configure_args(self):\n        # FIXME: Add arguments to pass to install via --configure-args\n        # FIXME: If not needed delete this function\n        args = []\n        return args'
dependencies = '    # FIXME: Add dependencies if required.\n    # depends_on("r-foo", type=("build", "run"))'
class spack.cmd.create.RacketPackageTemplate(name, url, *args, **kwargs)[source]

Bases: PackageTemplate

Provides approriate overrides for Racket extensions

base_class_name = 'RacketPackage'
body_def = '    # FIXME: specify the name of the package,\n    # as it should appear to ``raco pkg install``\n    name = "{0}"\n    # FIXME: set to true if published on pkgs.racket-lang.org\n    # pkgs = False\n    # FIXME: specify path to the root directory of the\n    # package, if not the base directory\n    # subdirectory = None\n    '
dependencies = '    # FIXME: Add dependencies if required. Only add the racket dependency\n    # if you need specific versions. A generic racket dependency is\n    # added implicity by the RacketPackage class.\n    # depends_on("racket@8.3:", type=("build", "run"))'
url_line = '    # FIXME: set the proper location from which to fetch your package\n    git = "git@github.com:example/example.git"\n    '
class spack.cmd.create.RubyPackageTemplate(name, *args, **kwargs)[source]

Bases: PackageTemplate

Provides appropriate overrides for Ruby packages

base_class_name = 'RubyPackage'
body_def = '    def build(self, spec, prefix):\n        # FIXME: If not needed delete this function\n        pass'
dependencies = '    # FIXME: Add dependencies if required. Only add the ruby dependency\n    # if you need specific versions. A generic ruby dependency is\n    # added implicity by the RubyPackage class.\n    # depends_on("ruby@X.Y.Z:", type=("build", "run"))\n    # depends_on("ruby-foo", type=("build", "run"))'
class spack.cmd.create.SIPPackageTemplate(name, *args, **kwargs)[source]

Bases: PackageTemplate

Provides appropriate overrides for SIP packages.

base_class_name = 'SIPPackage'
body_def = '    def configure_args(self, spec, prefix):\n        # FIXME: Add arguments other than --bindir and --destdir\n        # FIXME: If not needed delete this function\n        args = []\n        return args'
class spack.cmd.create.SconsPackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate overrides for SCons-based packages

base_class_name = 'SConsPackage'
body_def = '    def build_args(self, spec, prefix):\n        # FIXME: Add arguments to pass to build.\n        # FIXME: If not needed delete this function\n        args = []\n        return args'
class spack.cmd.create.WafPackageTemplate(name, url, versions)[source]

Bases: PackageTemplate

Provides appropriate override for Waf-based packages

base_class_name = 'WafPackage'
body_def = '    # FIXME: Override configure_args(), build_args(),\n    # or install_args() if necessary.'
spack.cmd.create.create(parser, args)[source]
spack.cmd.create.get_build_system(template, url, guesser)[source]

Determine the build system template.

If a template is specified, always use that. Otherwise, if a URL is provided, download the tarball and peek inside to guess what build system it uses. Otherwise, use a generic template by default.

Parameters:
  • template (str) – --template argument given to spack create

  • url (str) – url argument given to spack create

  • args (argparse.Namespace) – The arguments given to spack create

  • guesser (BuildSystemGuesser) – The first_stage_function given to spack checksum which records the build system it detects

Returns:

The name of the build system template to use

Return type:

str

spack.cmd.create.get_name(name, url)[source]

Get the name of the package based on the supplied arguments.

If a name was provided, always use that. Otherwise, if a URL was provided, extract the name from that. Otherwise, use a default.

Parameters:
  • name (str) – explicit --name argument given to spack create

  • url (str) – url argument given to spack create

Returns:

The name of the package

Return type:

str

spack.cmd.create.get_repository(args, name)[source]

Returns a Repo object that will allow us to determine the path where the new package file should be created.

Parameters:
  • args (argparse.Namespace) – The arguments given to spack create

  • name (str) – The name of the package to create

Returns:

A Repo object capable of determining the path to the

package file

Return type:

spack.repo.Repo

spack.cmd.create.get_url(url)[source]

Get the URL to use.

Use a default URL if none is provided.

Parameters:

url (str) – url argument to spack create

Returns:

The URL of the package

Return type:

str

spack.cmd.create.get_versions(args, name)[source]

Returns a list of versions and hashes for a package.

Also returns a BuildSystemGuesser object.

Returns default values if no URL is provided.

Parameters:
  • args (argparse.Namespace) – The arguments given to spack create

  • name (str) – The name of the package

Returns:

versions and hashes, and a BuildSystemGuesser object

Return type:

tuple

spack.cmd.create.setup_parser(subparser)[source]

spack.cmd.debug module

spack.cmd.debug.create_db_tarball(args)[source]
spack.cmd.debug.debug(parser, args)[source]
spack.cmd.debug.report(args)[source]
spack.cmd.debug.setup_parser(subparser)[source]

spack.cmd.deconcretize module

spack.cmd.deconcretize.deconcretize(parser, args)[source]
spack.cmd.deconcretize.deconcretize_specs(args, specs)[source]
spack.cmd.deconcretize.get_deconcretize_list(args: Namespace, specs: List[Spec], env: Environment) List[Spec][source]

Get list of environment roots to deconcretize

spack.cmd.deconcretize.setup_parser(subparser)[source]

spack.cmd.dependencies module

spack.cmd.dependencies.dependencies(parser, args)[source]
spack.cmd.dependencies.setup_parser(subparser)[source]

spack.cmd.dependents module

spack.cmd.dependents.dependents(parser, args)[source]
spack.cmd.dependents.get_dependents(pkg_name, ideps, transitive=False, dependents=None)[source]

Get all dependents for a package.

Parameters:
  • pkg_name (str) – name of the package whose dependents should be returned

  • ideps (dict) – dictionary of dependents, from inverted_dependencies()

  • transitive (bool or None) – return transitive dependents when True

spack.cmd.dependents.inverted_dependencies()[source]

Iterate through all packages and return a dictionary mapping package names to possible dependencies.

Virtual packages are included as sources, so that you can query dependents of, e.g., mpi, but virtuals are not included as actual dependents.

spack.cmd.dependents.setup_parser(subparser)[source]

spack.cmd.deprecate module

Deprecate one Spack install in favor of another

Spack packages of different configurations cannot be installed to the same location. However, in some circumstances (e.g. security patches) old installations should never be used again. In these cases, we will mark the old installation as deprecated, remove it, and link another installation into its place.

It is up to the user to ensure binary compatibility between the deprecated installation and its deprecator.

spack.cmd.deprecate.deprecate(parser, args)[source]

Deprecate one spec in favor of another

spack.cmd.deprecate.setup_parser(sp)[source]

spack.cmd.dev_build module

spack.cmd.dev_build.dev_build(self, args)[source]
spack.cmd.dev_build.setup_parser(subparser)[source]

spack.cmd.develop module

spack.cmd.develop.develop(parser, args)[source]
spack.cmd.develop.setup_parser(subparser)[source]

spack.cmd.diff module

spack.cmd.diff.compare_specs(a, b, to_string=False, color=None, ignore_packages=None)[source]

Generate a comparison, including diffs (for each side) and an intersection.

We can either print the result to the console, or parse into a json object for the user to save. We return an object that shows the differences, intersection, and names for a pair of specs a and b.

Parameters:
  • a (spack.spec.Spec) – the first spec to compare

  • b (spack.spec.Spec) – the second spec to compare

  • a_name (str) – the name of spec a

  • b_name (str) – the name of spec b

  • to_string (bool) – return an object that can be json dumped

  • color (bool) – whether to format the names for the console

spack.cmd.diff.diff(parser, args)[source]
spack.cmd.diff.flatten(functions)[source]

Given a list of ASP functions, convert into a list of key: value tuples.

We are squashing whatever is after the first index into one string for easier parsing in the interface

spack.cmd.diff.print_difference(c, attributes='all', out=None)[source]

Print the difference.

Given a diffset for A and a diffset for B, print red/green diffs to show the differences.

spack.cmd.diff.setup_parser(subparser)[source]
spack.cmd.diff.shift(asp_function)[source]

Transforms attr("foo", "bar") into foo("bar").

spack.cmd.docs module

spack.cmd.docs.docs(parser, args)[source]

spack.cmd.edit module

spack.cmd.edit.edit(parser, args)[source]
spack.cmd.edit.locate_file(name: str, path: str) str[source]
spack.cmd.edit.locate_package(name: str, repo: Repo) str[source]
spack.cmd.edit.setup_parser(subparser)[source]

spack.cmd.env module

class spack.cmd.env.ViewAction[source]

Bases: object

static actions()[source]
disable = 'disable'
enable = 'enable'
regenerate = 'regenerate'
spack.cmd.env.create_temp_env_directory()[source]

Returns the path of a temporary directory in which to create an environment

spack.cmd.env.env(parser, args)[source]

Look for a function called environment_<name> and call it.

spack.cmd.env.env_activate(args)[source]
spack.cmd.env.env_activate_setup_parser(subparser)[source]

set the current environment

spack.cmd.env.env_create(args)[source]
spack.cmd.env.env_create_setup_parser(subparser)[source]

create a new environment

spack.cmd.env.env_deactivate(args)[source]
spack.cmd.env.env_deactivate_setup_parser(subparser)[source]

deactivate any active environment in the shell

spack.cmd.env.env_depfile(args)[source]
spack.cmd.env.env_depfile_setup_parser(subparser)[source]

generate a depfile from the concrete environment specs

spack.cmd.env.env_list(args)[source]
spack.cmd.env.env_list_setup_parser(subparser)[source]

list managed environments

spack.cmd.env.env_loads(args)[source]
spack.cmd.env.env_loads_setup_parser(subparser)[source]

list modules for an installed environment ‘(see spack module loads)’

spack.cmd.env.env_remove(args)[source]

Remove a named environment.

This removes an environment managed by Spack. Directory environments and manifests embedded in repositories should be removed manually.

spack.cmd.env.env_remove_setup_parser(subparser)[source]

remove an existing environment

spack.cmd.env.env_rename(args)[source]

Rename an environment.

This renames a managed environment or moves an anonymous environment.

spack.cmd.env.env_rename_setup_parser(subparser)[source]

rename an existing environment

spack.cmd.env.env_revert(args)[source]
spack.cmd.env.env_revert_setup_parser(subparser)[source]

restore environments to their state before update

spack.cmd.env.env_status(args)[source]
spack.cmd.env.env_status_setup_parser(subparser)[source]

print whether there is an active environment

spack.cmd.env.env_update(args)[source]
spack.cmd.env.env_update_setup_parser(subparser)[source]

update environments to the latest format

spack.cmd.env.env_view(args)[source]
spack.cmd.env.env_view_setup_parser(subparser)[source]

manage a view associated with the environment

spack.cmd.env.setup_parser(subparser)[source]
spack.cmd.env.subcommand_functions = {}

Dictionary mapping subcommand names and aliases to functions

spack.cmd.env.subcommands = ['activate', 'deactivate', 'create', ['remove', 'rm'], ['rename', 'mv'], ['list', 'ls'], ['status', 'st'], 'loads', 'view', 'update', 'revert', 'depfile']

List of subcommands of spack env

spack.cmd.extensions module

spack.cmd.extensions.extensions(parser, args)[source]
spack.cmd.extensions.setup_parser(subparser)[source]

spack.cmd.external module

exception spack.cmd.external.NoManifestFileError(message, long_message=None)[source]

Bases: SpackError

spack.cmd.external.external(parser, args)[source]
spack.cmd.external.external_find(args)[source]
spack.cmd.external.external_list(args)[source]
spack.cmd.external.external_read_cray_manifest(args)[source]
spack.cmd.external.packages_to_search_for(*, names: List[str] | None, tags: List[str], exclude: List[str] | None)[source]
spack.cmd.external.setup_parser(subparser)[source]

spack.cmd.fetch module

spack.cmd.fetch.fetch(parser, args)[source]
spack.cmd.fetch.setup_parser(subparser)[source]

spack.cmd.find module

spack.cmd.find.display_env(env, args, decorator, results)[source]

Display extra find output when running in an environment.

Find in an environment outputs 2 or 3 sections:

  1. Root specs

  2. Concretized roots (if asked for with -c)

  3. Installed specs

spack.cmd.find.find(parser, args)[source]
spack.cmd.find.make_env_decorator(env)[source]

Create a function for decorating specs when in an environment.

spack.cmd.find.query_arguments(args)[source]
spack.cmd.find.setup_parser(subparser)[source]

spack.cmd.gc module

spack.cmd.gc.gc(parser, args)[source]
spack.cmd.gc.roots_from_environments(args, active_env)[source]
spack.cmd.gc.setup_parser(subparser)[source]

spack.cmd.gpg module

spack.cmd.gpg.gpg(parser, args)[source]
spack.cmd.gpg.gpg_create(args)[source]

create a new key

spack.cmd.gpg.gpg_export(args)[source]

export a gpg key, optionally including secret key

spack.cmd.gpg.gpg_init(args)[source]

add the default keys to the keyring

spack.cmd.gpg.gpg_list(args)[source]

list keys available in the keyring

spack.cmd.gpg.gpg_publish(args)[source]

publish public keys to a build cache

spack.cmd.gpg.gpg_sign(args)[source]

sign a package

spack.cmd.gpg.gpg_trust(args)[source]

add a key to the keyring

spack.cmd.gpg.gpg_untrust(args)[source]

remove a key from the keyring

spack.cmd.gpg.gpg_verify(args)[source]

verify a signed package

spack.cmd.gpg.setup_parser(subparser)[source]

spack.cmd.graph module

spack.cmd.graph.graph(parser, args)[source]
spack.cmd.graph.setup_parser(subparser)[source]

spack.cmd.help module

spack.cmd.help.help(parser, args)[source]
spack.cmd.help.setup_parser(subparser)[source]

spack.cmd.info module

class spack.cmd.info.VariantFormatter(pkg)[source]

Bases: object

default(v)[source]
property lines
spack.cmd.info.info(parser, args)[source]
spack.cmd.info.license(s)[source]
spack.cmd.info.padder(str_list, extra=0)[source]

Return a function to pad elements of a list.

spack.cmd.info.print_dependencies(pkg, args)[source]

output build, link, and run package dependencies

spack.cmd.info.print_detectable(pkg, args)[source]

output information on external detection

spack.cmd.info.print_licenses(pkg, args)[source]

Output the licenses of the project.

spack.cmd.info.print_maintainers(pkg, args)[source]

output package maintainers

spack.cmd.info.print_phases(pkg, args)[source]

output installation phases

spack.cmd.info.print_tags(pkg, args)[source]

output package tags

spack.cmd.info.print_tests(pkg, args)[source]

output relevant build-time and stand-alone tests

spack.cmd.info.print_variants(pkg, args)[source]

output variants

spack.cmd.info.print_variants_by_name(pkg)[source]
spack.cmd.info.print_variants_grouped_by_when(pkg)[source]
spack.cmd.info.print_versions(pkg, args)[source]

output versions

spack.cmd.info.print_virtuals(pkg, args)[source]

output virtual packages

spack.cmd.info.section_title(s)[source]
spack.cmd.info.setup_parser(subparser)[source]
spack.cmd.info.variant(s)[source]
spack.cmd.info.version(s)[source]

spack.cmd.install module

spack.cmd.install.cache_opt(default_opt, use_buildcache)[source]
spack.cmd.install.compute_tests_install_kwargs(specs, cli_test_arg)[source]

Translate the test cli argument into the proper install argument

spack.cmd.install.concrete_specs_from_cli(args, install_kwargs)[source]

Return abstract and concrete spec parsed from the command line.

spack.cmd.install.concrete_specs_from_file(args)[source]

Return the list of concrete specs read from files.

spack.cmd.install.default_log_file(spec)[source]

Computes the default filename for the log file and creates the corresponding directory if not present

spack.cmd.install.install(parser, args)[source]
spack.cmd.install.install_kwargs_from_args(args)[source]

Translate command line arguments into a dictionary that will be passed to the package installer.

spack.cmd.install.install_with_active_env(env: Environment, args, install_kwargs, reporter_factory)[source]
spack.cmd.install.install_without_active_env(args, install_kwargs, reporter_factory)[source]
spack.cmd.install.report_filename(args: Namespace, specs: List[Spec]) str[source]

Return the filename to be used for reporting to JUnit or CDash format.

spack.cmd.install.require_user_confirmation_for_overwrite(concrete_specs, args)[source]
spack.cmd.install.setup_parser(subparser)[source]

spack.cmd.license module

class spack.cmd.license.LicenseError[source]

Bases: object

add_error(error)[source]
error_messages()[source]
has_errors()[source]
spack.cmd.license.apache2_mit_spdx = '(Apache-2.0 OR MIT)'

Spack’s license identifier

spack.cmd.license.latest_year = 2024

Latest year that copyright applies. UPDATE THIS when bumping copyright.

spack.cmd.license.lgpl_exceptions = ['lib/spack/spack/cmd/license.py', 'lib/spack/spack/test/cmd/license.py']

licensed files that can have LGPL language in them so far, just this command – so it can find LGPL things elsewhere

spack.cmd.license.license(parser, args)[source]
spack.cmd.license.license_line_regexes = ['Copyright 2013-(2023|2024) Lawrence Livermore National Security, LLC and other', '(Spack|sbang) [Pp]roject [Dd]evelopers\\. See the top-level COPYRIGHT file for details.', 'SPDX-License-Identifier: \\(Apache-2\\.0 OR MIT\\)']

regexes for valid license lines at tops of files

spack.cmd.license.license_lines = 7

SPDX license id must appear in the first <license_lines> lines of a file

spack.cmd.license.licensed_files = ['^bin/spack$', '^bin/spack\\.bat$', '^bin/spack\\.ps1$', '^bin/spack_pwsh\\.ps1$', '^bin/sbang$', '^bin/spack-python$', '^bin/haspywin\\.py$', '^lib/spack/spack_installable/main\\.py$', '^lib/spack/spack/(?!(test/)?util/unparse).*\\.py$', '^lib/spack/spack/.*\\.sh$', '^lib/spack/spack/.*\\.lp$', '^lib/spack/llnl/.*\\.py$', '^lib/spack/env/cc$', '^lib/spack/spack/test/data/style/broken.dummy', '^lib/spack/spack/test/data/unparse/.*\\.txt', '^lib/spack/docs/(?!command_index|spack|llnl).*\\.rst$', '^lib/spack/docs/.*\\.py$', '^lib/spack/docs/spack.yaml$', '^lib/spack/external/__init__.py$', '^share/spack/.*\\.sh$', '^share/spack/.*\\.bash$', '^share/spack/.*\\.csh$', '^share/spack/.*\\.fish$', 'share/spack/setup-env\\.ps1$', '^share/spack/qa/run-[^/]*$', '^share/spack/bash/spack-completion.in$', '^.github/actions/.*\\.py$', '^var/spack/repos/.*/package.py$']

regular expressions for licensed files.

spack.cmd.license.list_files(args)[source]

list files in spack that should have license headers

spack.cmd.license.setup_parser(subparser)[source]

update copyright for the current year in all licensed files

spack.cmd.license.verify(args)[source]

verify that files in spack have the right license header

spack.cmd.list module

spack.cmd.list.filter_by_name(pkgs, args)[source]

Filters the sequence of packages according to user prescriptions

Parameters:
  • pkgs – sequence of packages

  • args – parsed command line arguments

Returns:

filtered and sorted list of packages

spack.cmd.list.formatter(func)[source]

Decorator used to register formatters

spack.cmd.list.get_dependencies(pkg)[source]
spack.cmd.list.github_url(pkg)[source]

Link to a package file on github.

spack.cmd.list.html(pkg_names, out)[source]

Print out information on all packages in Sphinx HTML.

This is intended to be inlined directly into Sphinx documentation. We write HTML instead of RST for speed; generating RST from all packages causes the Sphinx build to take forever. Including this as raw HTML is much faster.

spack.cmd.list.list(parser, args)[source]
spack.cmd.list.name_only(pkgs, out)[source]
spack.cmd.list.rows_for_ncols(elts, ncols)[source]

Print out rows in a table with ncols of elts laid out vertically.

spack.cmd.list.setup_parser(subparser)[source]
spack.cmd.list.version_json(pkg_names, out)[source]

Print all packages with their latest versions.

spack.cmd.load module

spack.cmd.load.load(parser, args)[source]
spack.cmd.load.setup_parser(subparser)[source]

Parser is only constructed so that this prints a nice help message with -h.

spack.cmd.location module

spack.cmd.location.location(parser, args)[source]
spack.cmd.location.setup_parser(subparser)[source]

spack.cmd.log_parse module

spack.cmd.log_parse.log_parse(parser, args)[source]
spack.cmd.log_parse.setup_parser(subparser)[source]

spack.cmd.logs module

spack.cmd.logs.logs(parser, args)[source]
spack.cmd.logs.setup_parser(subparser)[source]

spack.cmd.maintainers module

spack.cmd.maintainers.maintained_packages()[source]
spack.cmd.maintainers.maintainers(parser, args)[source]
spack.cmd.maintainers.maintainers_to_packages(users=None)[source]
spack.cmd.maintainers.packages_to_maintainers(package_names=None)[source]
spack.cmd.maintainers.setup_parser(subparser)[source]
spack.cmd.maintainers.union_values(dictionary)[source]

Given a dictionary with values that are Collections, return their union.

Parameters:

dictionary (dict) – dictionary whose values are all collections.

Returns:

the union of all collections in the dictionary’s values.

Return type:

(set)

spack.cmd.make_installer module

spack.cmd.make_installer.make_installer(parser, args)[source]

Use CMake to generate WIX installer in newly created build directory

spack.cmd.make_installer.setup_parser(subparser)[source]
spack.cmd.make_installer.txt_to_rtf(file_path)[source]

spack.cmd.mark module

spack.cmd.mark.do_mark(specs, explicit)[source]

Marks all the specs in a list.

Parameters:
  • specs (list) – list of specs to be marked

  • explicit (bool) – whether to mark specs as explicitly installed

spack.cmd.mark.find_matching_specs(specs, allow_multiple_matches=False)[source]
Returns a list of specs matching the not necessarily

concretized specs given from cli

Parameters:
  • specs (list) – list of specs to be matched against installed packages

  • allow_multiple_matches (bool) – if True multiple matches are admitted

Returns:

list of specs

spack.cmd.mark.mark(parser, args)[source]
spack.cmd.mark.mark_specs(args, specs)[source]
spack.cmd.mark.setup_parser(subparser)[source]

spack.cmd.mirror module

class spack.cmd.mirror.IncludeFilter(args)[source]

Bases: object

spack.cmd.mirror.all_specs_with_all_versions()[source]
spack.cmd.mirror.concrete_specs_from_cli_or_file(args)[source]
spack.cmd.mirror.concrete_specs_from_environment()[source]
spack.cmd.mirror.concrete_specs_from_user(args)[source]

Return the list of concrete specs that the user wants to mirror. The list is passed either from command line or from a text file.

spack.cmd.mirror.create_mirror_for_all_specs(mirror_specs, path, skip_unstable_versions)[source]
spack.cmd.mirror.create_mirror_for_individual_specs(mirror_specs, path, skip_unstable_versions)[source]
spack.cmd.mirror.extend_with_additional_versions(specs, num_versions)[source]
spack.cmd.mirror.extend_with_dependencies(specs)[source]

Extend the input list by adding all the dependencies explicitly.

spack.cmd.mirror.filter_externals(specs)[source]
spack.cmd.mirror.mirror(parser, args)[source]
spack.cmd.mirror.mirror_add(args)[source]

add a mirror to Spack

spack.cmd.mirror.mirror_create(args)[source]

create a directory to be used as a spack mirror, and fill it with package archives

spack.cmd.mirror.mirror_destroy(args)[source]

given a url, recursively delete everything under it

spack.cmd.mirror.mirror_list(args)[source]

print out available mirrors to the console

spack.cmd.mirror.mirror_remove(args)[source]

remove a mirror by name

spack.cmd.mirror.mirror_set(args)[source]

configure the connection details of a mirror

spack.cmd.mirror.mirror_set_url(args)[source]

change the URL of a mirror

spack.cmd.mirror.process_mirror_stats(present, mirrored, error)[source]
spack.cmd.mirror.setup_parser(subparser)[source]
spack.cmd.mirror.specs_from_text_file(filename, concretize=False)[source]

Return a list of specs read from a text file.

The file should contain one spec per line.

Parameters:
  • filename (str) – name of the file containing the abstract specs.

  • concretize (bool) – if True concretize the specs before returning the list.

spack.cmd.mirror.versions_per_spec(args)[source]

Return how many versions should be mirrored per spec.

spack.cmd.module module

spack.cmd.module.module(parser, args)[source]
spack.cmd.module.setup_parser(subparser)[source]

spack.cmd.patch module

spack.cmd.patch.patch(parser, args)[source]
spack.cmd.patch.setup_parser(subparser)[source]

spack.cmd.pkg module

spack.cmd.pkg.get_grep(required=False)[source]

Get a grep command to use with spack pkg grep.

spack.cmd.pkg.pkg(parser, args, unknown_args)[source]
spack.cmd.pkg.pkg_add(args)[source]

add a package to the git stage with git add

spack.cmd.pkg.pkg_added(args)[source]

show packages added since a commit

spack.cmd.pkg.pkg_changed(args)[source]

show packages changed since a commit

spack.cmd.pkg.pkg_diff(args)[source]

compare packages available in two different git revisions

spack.cmd.pkg.pkg_grep(args, unknown_args)[source]

grep for strings in package.py files from all repositories

spack.cmd.pkg.pkg_hash(args)[source]

dump canonical source code hash for a package spec

spack.cmd.pkg.pkg_list(args)[source]

list packages associated with a particular spack git revision

spack.cmd.pkg.pkg_removed(args)[source]

show packages removed since a commit

spack.cmd.pkg.pkg_source(args)[source]

dump source code for a package

spack.cmd.pkg.setup_parser(subparser)[source]

spack.cmd.providers module

spack.cmd.providers.providers(parser, args)[source]
spack.cmd.providers.setup_parser(subparser)[source]

spack.cmd.pydoc module

spack.cmd.pydoc.pydoc(parser, args)[source]
spack.cmd.pydoc.setup_parser(subparser)[source]

spack.cmd.python module

spack.cmd.python.ipython_interpreter(args)[source]

An ipython interpreter is intended to be interactive, so it doesn’t support running a script or arguments

spack.cmd.python.propagate_exceptions_from(console)[source]

Set sys.excepthook to let uncaught exceptions return 1 to the shell.

Parameters:

console (code.InteractiveConsole) – the console that needs a change in sys.excepthook

spack.cmd.python.python(parser, args, unknown_args)[source]
spack.cmd.python.python_interpreter(args)[source]

A python interpreter is the default interpreter

spack.cmd.python.setup_parser(subparser)[source]

spack.cmd.reindex module

spack.cmd.reindex.reindex(parser, args)[source]

spack.cmd.remove module

spack.cmd.remove.remove(parser, args)[source]
spack.cmd.remove.setup_parser(subparser)[source]

spack.cmd.repo module

spack.cmd.repo.repo(parser, args)[source]
spack.cmd.repo.repo_add(args)[source]

add a package source to Spack’s configuration

spack.cmd.repo.repo_create(args)[source]

create a new package repository

spack.cmd.repo.repo_list(args)[source]

show registered repositories and their namespaces

spack.cmd.repo.repo_remove(args)[source]

remove a repository from Spack’s configuration

spack.cmd.repo.setup_parser(subparser)[source]

spack.cmd.resource module

spack.cmd.resource.resource(parser, args)[source]
spack.cmd.resource.resource_list(args)[source]

list all resources known to spack (currently just patches)

spack.cmd.resource.resource_show(args)[source]

show a resource, identified by its checksum

spack.cmd.resource.setup_parser(subparser)[source]

spack.cmd.restage module

spack.cmd.restage.restage(parser, args)[source]
spack.cmd.restage.setup_parser(subparser)[source]

spack.cmd.solve module

spack.cmd.solve.setup_parser(subparser)[source]
spack.cmd.solve.show_options = ('asp', 'opt', 'output', 'solutions')

output options

spack.cmd.solve.solve(parser, args)[source]

spack.cmd.spec module

spack.cmd.spec.setup_parser(subparser)[source]
spack.cmd.spec.spec(parser, args)[source]

spack.cmd.stage module

spack.cmd.stage.setup_parser(subparser)[source]
spack.cmd.stage.stage(parser, args)[source]

spack.cmd.style module

spack.cmd.style.changed_files(base='develop', untracked=True, all_files=False, root=None)[source]

Get list of changed files in the Spack repository.

Parameters:
  • base (str) – name of base branch to evaluate differences with.

  • untracked (bool) – include untracked files in the list.

  • all_files (bool) – list all files in the repository.

  • root (str) – use this directory instead of the Spack prefix.

spack.cmd.style.cwd_relative(path, args)[source]

Translate prefix-relative path to current working directory-relative.

spack.cmd.style.exclude_directories = ['lib/spack/external']

List of directories to exclude from checks – relative to spack root

spack.cmd.style.grouper(iterable, n, fillvalue=None)[source]

Collect data into fixed-length chunks or blocks

spack.cmd.style.is_package(f)[source]

Whether flake8 should consider a file as a core file or a package.

We run flake8 with different exceptions for the core and for packages, since we allow from spack import * and poking globals into packages.

spack.cmd.style.missing_tools(tools_to_run)[source]
spack.cmd.style.mypy_ignores = ['[annotation-unchecked]']

warnings to ignore in mypy

spack.cmd.style.print_style_header(file_list, args, tools_to_run)[source]
spack.cmd.style.print_tool_header(tool)[source]
spack.cmd.style.print_tool_result(tool, returncode)[source]
spack.cmd.style.rewrite_and_print_output(output, args, re_obj=re.compile('^(.+):([0-9]+):'), replacement='{0}:{1}:')[source]

rewrite ouput with <file>:<line>: format to respect path args

spack.cmd.style.run_black(black_cmd, file_list, args)[source]
spack.cmd.style.run_flake8(flake8_cmd, file_list, args)[source]
spack.cmd.style.run_isort(isort_cmd, file_list, args)[source]
spack.cmd.style.run_mypy(mypy_cmd, file_list, args)[source]
spack.cmd.style.setup_parser(subparser)[source]
spack.cmd.style.style(parser, args)[source]
class spack.cmd.style.tool(name, required=False)[source]

Bases: object

spack.cmd.style.tool_names = ['isort', 'black', 'flake8', 'mypy']

Order in which tools should be run. flake8 is last so that it can double-check the results of other tools (if, e.g., –fix was provided) The list maps an executable name to a method to ensure the tool is bootstrapped or present in the environment.

spack.cmd.style.tools = {'black': (<function run_black>, False), 'flake8': (<function run_flake8>, True), 'isort': (<function run_isort>, False), 'mypy': (<function run_mypy>, False)}

tools we run in spack style

spack.cmd.style.validate_toolset(arg_value)[source]

Validate –tool and –skip arguments (sets of optionally comma-separated tools).

spack.cmd.tags module

spack.cmd.tags.report_tags(category, tags)[source]
spack.cmd.tags.setup_parser(subparser)[source]
spack.cmd.tags.tags(parser, args)[source]

spack.cmd.test module

spack.cmd.test.create_reporter(args, specs_to_test, test_suite)[source]
spack.cmd.test.report_filename(args, test_suite)[source]
spack.cmd.test.setup_parser(subparser)[source]
spack.cmd.test.test(parser, args)[source]
spack.cmd.test.test_find(args)[source]

find tests that are running or have available results

displays aliases for tests that have them, otherwise test suite content hashes

spack.cmd.test.test_list(args)[source]

list installed packages with available tests

spack.cmd.test.test_remove(args)[source]

remove results from Spack test suite(s) (default all)

if no test suite is listed, remove results for all suites.

removed tests can no longer be accessed for results or status, and will not appear in spack test list results

spack.cmd.test.test_results(args)[source]

get the results from Spack test suite(s) (default all)

spack.cmd.test.test_run(args)[source]

run tests for the specified installed packages

if no specs are listed, run tests for all packages in the current environment or all installed packages if there is no active environment

spack.cmd.test.test_status(args)[source]

get the current status for the specified Spack test suite(s)

spack.cmd.test_env module

spack.cmd.test_env.test_env(parser, args)[source]

spack.cmd.tutorial module

spack.cmd.tutorial.setup_parser(subparser)[source]
spack.cmd.tutorial.tutorial(parser, args)[source]

spack.cmd.undevelop module

spack.cmd.undevelop.setup_parser(subparser)[source]
spack.cmd.undevelop.undevelop(parser, args)[source]

spack.cmd.uninstall module

spack.cmd.uninstall.all_specs_in_env(env: Environment, specs: List[Spec]) List[Spec][source]

Given a list of specs, return those that are in the env

spack.cmd.uninstall.dependent_environments(specs: List[Spec], current_env: Environment | None = None) Dict[Environment, List[Spec]][source]
spack.cmd.uninstall.do_uninstall(specs: List[Spec], force: bool = False)[source]
spack.cmd.uninstall.find_matching_specs(env: Environment | None, specs: List[Spec], allow_multiple_matches: bool = False, origin=None) List[Spec][source]
Returns a list of specs matching the not necessarily

concretized specs given from cli

Parameters:
  • env – optional active environment

  • specs – list of specs to be matched against installed packages

  • allow_multiple_matches – if True multiple matches are admitted

Returns:

list of specs

Return type:

list

spack.cmd.uninstall.get_uninstall_list(args, specs: List[Spec], env: Environment | None)[source]

Returns unordered uninstall_list and remove_list: these may overlap (some things may be both uninstalled and removed from the current environment).

It is assumed we are in an environment if –remove is specified (this method raises an exception otherwise).

spack.cmd.uninstall.installed_dependents(specs: List[Spec]) List[Spec][source]
spack.cmd.uninstall.setup_parser(subparser)[source]
spack.cmd.uninstall.uninstall(parser, args)[source]
spack.cmd.uninstall.uninstall_specs(args, specs)[source]

spack.cmd.unit_test module

spack.cmd.unit_test.add_back_pytest_args(args, unknown_args)[source]

Add parsed pytest args, unknown args, and remainder together.

We add some basic pytest arguments to the Spack parser to ensure that they show up in the short help, so we have to reassemble things here.

spack.cmd.unit_test.do_list(args, extra_args)[source]

Print a lists of tests than what pytest offers.

spack.cmd.unit_test.setup_parser(subparser)[source]
spack.cmd.unit_test.unit_test(parser, args, unknown_args)[source]

spack.cmd.unload module

spack.cmd.unload.setup_parser(subparser)[source]

Parser is only constructed so that this prints a nice help message with -h.

spack.cmd.unload.unload(parser, args)[source]

unload spack packages from the user environment

spack.cmd.url module

spack.cmd.url.name_parsed_correctly(pkg, name)[source]

Determine if the name of a package was correctly parsed.

Parameters:
Returns:

True if the name was correctly parsed, else False

Return type:

bool

spack.cmd.url.print_name_and_version(url)[source]

Prints a URL. Underlines the detected name with dashes and the detected version with tildes.

Parameters:

url (str) – The url to parse

spack.cmd.url.remove_prefix(pkg_name)[source]

Remove build system prefix (‘py-’, ‘perl-’, etc.) from a package name.

After determining a name, spack create determines a build system. Some build systems prepend a special string to the front of the name. Since this can’t be guessed from the URL, it would be unfair to say that these names are incorrectly parsed, so we remove them.

Parameters:

pkg_name (str) – the name of the package

Returns:

the name of the package with any build system prefix removed

Return type:

str

spack.cmd.url.remove_separators(version)[source]

Remove separator characters (‘.’, ‘_’, and ‘-’) from a version.

A version like 1.2.3 may be displayed as 1_2_3 in the URL. Make sure 1.2.3, 1-2-3, 1_2_3, and 123 are considered equal. Unfortunately, this also means that 1.23 and 12.3 are equal.

Parameters:

version (str or spack.version.Version) – A version

Returns:

The version with all separator characters removed

Return type:

str

spack.cmd.url.setup_parser(subparser)[source]
spack.cmd.url.url(parser, args)[source]
spack.cmd.url.url_list(args)[source]
spack.cmd.url.url_list_parsing(args, urls, url, pkg)[source]

Helper function for url_list().

Parameters:
Returns:

The updated set of urls

Return type:

set

spack.cmd.url.url_parse(args)[source]
spack.cmd.url.url_stats(args)[source]
spack.cmd.url.url_summary(args)[source]
spack.cmd.url.version_parsed_correctly(pkg, version)[source]

Determine if the version of a package was correctly parsed.

Parameters:
Returns:

True if the name was correctly parsed, else False

Return type:

bool

spack.cmd.verify module

spack.cmd.verify.setup_parser(subparser)[source]
spack.cmd.verify.verify(parser, args)[source]

spack.cmd.versions module

spack.cmd.versions.setup_parser(subparser)[source]
spack.cmd.versions.versions(parser, args)[source]

spack.cmd.view module

Produce a “view” of a Spack DAG.

A “view” is file hierarchy representing the union of a number of Spack-installed package file hierarchies. The union is formed from:

  • specs resolved from the package names given by the user (the seeds)

  • all dependencies of the seeds unless user specifies –no-dependencies

  • less any specs with names matching the regular expressions given by –exclude

The view can be built and tore down via a number of methods (the “actions”):

  • symlink :: a file system view which is a directory hierarchy that is the union of the hierarchies of the installed packages in the DAG where installed files are referenced via symlinks.

  • hardlink :: like the symlink view but hardlinks are used.

  • statlink :: a view producing a status report of a symlink or hardlink view.

The file system view concept is imspired by Nix, implemented by brett.viren@gmail.com ca 2016.

All operations on views are performed via proxy objects such as YamlFilesystemView.

spack.cmd.view.disambiguate_in_view(specs, view)[source]

When dealing with querying actions (remove/status) we only need to disambiguate among specs in the view

spack.cmd.view.setup_parser(sp)[source]
spack.cmd.view.view(parser, args)[source]

Produce a view of a set of packages.