spack.cmd package

Submodules

spack.cmd.activate module

spack.cmd.activate.activate(parser, args)
spack.cmd.activate.setup_parser(subparser)

spack.cmd.add module

spack.cmd.add.add(parser, args)
spack.cmd.add.setup_parser(subparser)

spack.cmd.arch module

spack.cmd.arch.arch(parser, args)
spack.cmd.arch.display_targets(targets)

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

spack.cmd.arch.setup_parser(subparser)

spack.cmd.blame module

spack.cmd.blame.blame(parser, args)
spack.cmd.blame.setup_parser(subparser)

spack.cmd.bootstrap module

spack.cmd.bootstrap.bootstrap(parser, args, **kwargs)
spack.cmd.bootstrap.setup_parser(subparser)

spack.cmd.build module

spack.cmd.build.build(parser, args)
spack.cmd.build.setup_parser(subparser)

spack.cmd.build_env module

spack.cmd.build_env.build_env(parser, args)
spack.cmd.build_env.setup_parser(subparser)

spack.cmd.buildcache module

spack.cmd.buildcache.buildcache(parser, args)
spack.cmd.buildcache.buildcache_copy(args)

Copy a buildcache entry and all its files from one mirror, given as ‘–base-dir’, to some other mirror, specified as ‘–destination-url’. The specific buildcache entry to be copied from one location to the other is identified using the ‘–spec-yaml’ argument.

spack.cmd.buildcache.buildcache_update_index(args)

Update a buildcache index.

spack.cmd.buildcache.check_binaries(args)

Check specs (either a single spec from –spec, or else the full set of release 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.createtarball(args)

create a binary package from an existing install

spack.cmd.buildcache.find_matching_specs(pkgs, allow_multiple_matches=False, env=None)
Returns a list of specs matching the not necessarily

concretized specs given from cli

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

  • allow_multiple_matches – if True multiple matches are admitted

Returns

list of specs

spack.cmd.buildcache.get_buildcache_name(args)

Get name (prefix) of buildcache entries for this spec

spack.cmd.buildcache.get_concrete_spec(args)
spack.cmd.buildcache.get_tarball(args)

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. Normally, just the tarball and .spec.yaml files are required, but if the –require-cdashid argument was provided, then a .cdashid file is also required.

spack.cmd.buildcache.getkeys(args)

get public keys available on mirrors

spack.cmd.buildcache.install_tarball(spec, args)
spack.cmd.buildcache.installtarball(args)

install from a binary package

spack.cmd.buildcache.listspecs(args)

list binary packages available from mirrors

spack.cmd.buildcache.match_downloaded_specs(pkgs, allow_multiple_matches=False, force=False)
Returns a list of specs matching the not necessarily

concretized specs given from cli

Parameters
  • specs – list of specs to be matched against buildcaches on mirror

  • allow_multiple_matches – if True multiple matches are admitted

Returns

list of specs

spack.cmd.buildcache.preview(args)

Print a status tree of the selected specs that shows which nodes are relocatable and which might not be.

Parameters

args – command line arguments

spack.cmd.buildcache.save_spec_yamls(args)

Get full spec for dependencies, relative to root spec, 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)

spack.cmd.cd module

spack.cmd.cd.cd(parser, args)
spack.cmd.cd.setup_parser(subparser)

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.checksum module

spack.cmd.checksum.checksum(parser, args)
spack.cmd.checksum.setup_parser(subparser)

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)

Bases: argparse.Action

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

spack.cmd.clean.clean(parser, args)
spack.cmd.clean.setup_parser(subparser)

spack.cmd.clone module

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

spack.cmd.commands module

class spack.cmd.commands.SpackArgparseRstWriter(documented_commands, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)

Bases: llnl.util.argparsewriter.ArgparseRstWriter

RST writer tailored for spack documentation.

usage(*args)
class spack.cmd.commands.SubcommandWriter(out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)

Bases: llnl.util.argparsewriter.ArgparseWriter

begin_command(prog)
spack.cmd.commands.commands(parser, args)
spack.cmd.commands.formatter(func)

Decorator used to register formatters

spack.cmd.commands.formatters = {'names': <function names>, 'rst': <function rst>, 'subcommands': <function subcommands>}

list of command formatters

spack.cmd.commands.names(args, out)
spack.cmd.commands.prepend_header(args, out)
spack.cmd.commands.rst(args, out)
spack.cmd.commands.rst_index(out)
spack.cmd.commands.setup_parser(subparser)
spack.cmd.commands.subcommands(args, out)

spack.cmd.compiler module

spack.cmd.compiler.compiler(parser, args)
spack.cmd.compiler.compiler_find(args)

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)

Print info about all compilers matching a spec.

spack.cmd.compiler.compiler_list(args)
spack.cmd.compiler.compiler_remove(args)
spack.cmd.compiler.setup_parser(subparser)

spack.cmd.compilers module

spack.cmd.compilers.compilers(parser, args)
spack.cmd.compilers.setup_parser(subparser)

spack.cmd.concretize module

spack.cmd.concretize.concretize(parser, args)
spack.cmd.concretize.setup_parser(subparser)

spack.cmd.config module

spack.cmd.config.config(parser, args)
spack.cmd.config.config_blame(args)

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

spack.cmd.config.config_edit(args)

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)

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.setup_parser(subparser)

spack.cmd.configure module

spack.cmd.configure.configure(parser, args)
spack.cmd.configure.setup_parser(subparser)

spack.cmd.create module

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

Bases: spack.cmd.create.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)

Bases: spack.cmd.create.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)

Bases: spack.cmd.create.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

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)

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)

Writes the new package file.

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

Bases: spack.cmd.create.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.IntelPackageTemplate(name, url, versions)

Bases: spack.cmd.create.PackageTemplate

Provides appropriate overrides for licensed Intel software

base_class_name = 'IntelPackage'
body_def = ' # FIXME: Override `setup_environment` if necessary.'
class spack.cmd.create.MakefilePackageTemplate(name, url, versions)

Bases: spack.cmd.create.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')"
class spack.cmd.create.MesonPackageTemplate(name, url, versions)

Bases: spack.cmd.create.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)

Bases: spack.cmd.create.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)

Bases: spack.cmd.create.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)

Bases: spack.cmd.create.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)

Bases: spack.cmd.create.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, *args, **kwargs)

Bases: spack.cmd.create.PackageTemplate

Provides appropriate overrides for python extensions

base_class_name = 'PythonPackage'
body_def = ' def build_args(self, spec, prefix):\n # FIXME: Add arguments other than --prefix\n # FIXME: If not needed delete this function\n args = []\n return args'
dependencies = " # FIXME: Add dependencies if required.\n # depends_on('py-setuptools', type='build')\n # depends_on('py-foo', type=('build', 'run'))"
class spack.cmd.create.QMakePackageTemplate(name, url, versions)

Bases: spack.cmd.create.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, *args, **kwargs)

Bases: spack.cmd.create.PackageTemplate

Provides appropriate overrides for R extensions

base_class_name = 'RPackage'
body_def = ' def configure_args(self, spec, prefix):\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.SIPPackageTemplate(name, *args, **kwargs)

Bases: spack.cmd.create.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)

Bases: spack.cmd.create.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)

Bases: spack.cmd.create.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)
spack.cmd.create.get_build_system(args, guesser)

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
  • 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(args)

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

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

Returns

The name of the package

Return type

str

spack.cmd.create.get_repository(args, name)

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

Repo

spack.cmd.create.get_url(args)

Get the URL to use.

Use a default URL if none is provided.

Parameters

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

Returns

The URL of the package

Return type

str

spack.cmd.create.get_versions(args, name)

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

str and BuildSystemGuesser

spack.cmd.create.setup_parser(subparser)

spack.cmd.deactivate module

spack.cmd.deactivate.deactivate(parser, args)
spack.cmd.deactivate.setup_parser(subparser)

spack.cmd.debug module

spack.cmd.debug.create_db_tarball(args)
spack.cmd.debug.debug(parser, args)
spack.cmd.debug.setup_parser(subparser)

spack.cmd.dependencies module

spack.cmd.dependencies.dependencies(parser, args)
spack.cmd.dependencies.setup_parser(subparser)

spack.cmd.dependents module

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

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, optional) – return transitive dependents when True

spack.cmd.dependents.inverted_dependencies()

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

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)

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)

Deprecate one spec in favor of another

spack.cmd.deprecate.setup_parser(sp)

spack.cmd.dev_build module

spack.cmd.dev_build.dev_build(self, args)
spack.cmd.dev_build.setup_parser(subparser)

spack.cmd.diy module

spack.cmd.diy.diy(self, args)
spack.cmd.diy.setup_parser(subparser)

spack.cmd.docs module

spack.cmd.docs.docs(parser, args)

spack.cmd.edit module

spack.cmd.edit.edit(parser, args)
spack.cmd.edit.edit_package(name, repo_path, namespace)

Opens the requested package file in your favorite $EDITOR.

Parameters
  • name (str) – The name of the package

  • repo_path (str) – The path to the repository containing this package

  • namespace (str) – A valid namespace registered with Spack

spack.cmd.edit.setup_parser(subparser)

spack.cmd.env module

class spack.cmd.env.ViewAction

Bases: object

static actions()
disable = 'disable'
enable = 'enable'
regenerate = 'regenerate'
spack.cmd.env.env(parser, args)

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

spack.cmd.env.env_activate(args)
spack.cmd.env.env_activate_setup_parser(subparser)

set the current environment

spack.cmd.env.env_create(args)
spack.cmd.env.env_create_setup_parser(subparser)

create a new environment

spack.cmd.env.env_deactivate(args)
spack.cmd.env.env_deactivate_setup_parser(subparser)

deactivate any active environment in the shell

spack.cmd.env.env_list(args)
spack.cmd.env.env_list_setup_parser(subparser)

list available environments

spack.cmd.env.env_loads(args)
spack.cmd.env.env_loads_setup_parser(subparser)

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

spack.cmd.env.env_remove(args)

Remove a named environment.

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

spack.cmd.env.env_remove_setup_parser(subparser)

remove an existing environment

spack.cmd.env.env_status(args)
spack.cmd.env.env_status_setup_parser(subparser)

print whether there is an active environment

spack.cmd.env.env_view(args)
spack.cmd.env.env_view_setup_parser(subparser)

manage a view associated with the environment

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

Dictionary mapping subcommand names and aliases to functions

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

List of subcommands of spack env

spack.cmd.extensions module

spack.cmd.extensions.extensions(parser, args)
spack.cmd.extensions.setup_parser(subparser)

spack.cmd.fetch module

spack.cmd.fetch.fetch(parser, args)
spack.cmd.fetch.setup_parser(subparser)

spack.cmd.find module

spack.cmd.find.display_env(env, args, decorator)
spack.cmd.find.find(parser, args)
spack.cmd.find.query_arguments(args)
spack.cmd.find.setup_env(env)

Create a function for decorating specs when in an environment.

spack.cmd.find.setup_parser(subparser)

spack.cmd.flake8 module

spack.cmd.flake8.add_pattern_exemptions(line, codes)

Add a flake8 exemption to a line.

spack.cmd.flake8.changed_files(base=None, untracked=True, all_files=False)

Get list of changed files in the Spack repository.

spack.cmd.flake8.exclude_directories = ['/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/v0.13.3/lib/spack/docs/_spack_root/lib/spack/external']

List of directories to exclude from checks.

spack.cmd.flake8.filter_file(source, dest, output=False)

Filter a single file through all the patterns in pattern_exemptions.

spack.cmd.flake8.flake8(parser, args)
spack.cmd.flake8.is_package(f)

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.flake8.max_line_length = 79

this duplicates what’s in .flake8)

Type

max line length we’re enforcing (note

spack.cmd.flake8.pattern_exemptions = {re.compile('package.py$'): {'F403': [re.compile('^from spack import \\*$')], 'E501': [re.compile('^\\s*homepage\\s*='), re.compile('^\\s*url\\s*='), re.compile('^\\s*git\\s*='), re.compile('^\\s*svn\\s*='), re.compile('^\\s*hg\\s*='), re.compile('^\\s*list_url\\s*='), re.compile('^\\s*version\\('), re.compile('^\\s*variant\\('), re.compile('^\\s*provides\\('), re.compile('^\\s*extends\\('), re.compile('^\\s*depends_on\\('), re.compile('^\\s*conflicts\\('), re.compile('^\\s*resource\\('), re.compile('^\\s*patch\\(')], 'F811': [re.compile('^\\s*@when\\(.*\\)')]}, re.compile('.py$'): {'E501': [re.compile('(https?|ftp|file)\\:'), re.compile('([\\\'"])[0-9a-fA-F]{32,}\\1')]}}
This is a dict that maps:
filename pattern ->
flake8 exemption code ->

list of patterns, for which matching lines should have codes applied.

For each file, if the filename pattern matches, we’ll add per-line exemptions if any patterns in the sub-dict match.

spack.cmd.flake8.setup_parser(subparser)

spack.cmd.gpg module

spack.cmd.gpg.gpg(parser, args)
spack.cmd.gpg.gpg_create(args)

create a new key

spack.cmd.gpg.gpg_export(args)

export a secret key

spack.cmd.gpg.gpg_init(args)

add the default keys to the keyring

spack.cmd.gpg.gpg_list(args)

list keys available in the keyring

spack.cmd.gpg.gpg_sign(args)

sign a package

spack.cmd.gpg.gpg_trust(args)

add a key to the keyring

spack.cmd.gpg.gpg_untrust(args)

remove a key from the keyring

spack.cmd.gpg.gpg_verify(args)

verify a signed package

spack.cmd.gpg.setup_parser(subparser)

spack.cmd.graph module

spack.cmd.graph.graph(parser, args)
spack.cmd.graph.setup_parser(subparser)

spack.cmd.help module

spack.cmd.help.help(parser, args)
spack.cmd.help.setup_parser(subparser)

spack.cmd.info module

class spack.cmd.info.VariantFormatter(variants, max_widths=(30, 20, 30))

Bases: object

default(v)
lines
spack.cmd.info.info(parser, args)
spack.cmd.info.padder(str_list, extra=0)

Return a function to pad elements of a list.

spack.cmd.info.print_text_info(pkg)

Print out a plain text description of a package.

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

spack.cmd.install module

spack.cmd.install.default_log_file(spec)

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

spack.cmd.install.install(parser, args, **kwargs)
spack.cmd.install.install_spec(cli_args, kwargs, abstract_spec, spec)

Do the actual installation.

spack.cmd.install.setup_parser(subparser)
spack.cmd.install.update_kwargs_from_args(args, kwargs)

Parse cli arguments and construct a dictionary that will be passed to Package.do_install API

spack.cmd.license module

class spack.cmd.license.LicenseError

Bases: object

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

Spack’s license identifier

spack.cmd.license.git = <exe: ['/usr/bin/git']>

need the git command to check new files

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)
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-python$', '^bin/sbang$', '^lib/spack/spack/.*\\.py$', '^lib/spack/spack/.*\\.sh$', '^lib/spack/llnl/.*\\.py$', '^lib/spack/env/cc$', '^lib/spack/docs/(?!command_index|spack|llnl).*\\.rst$', '^lib/spack/docs/.*\\.py$', '^lib/spack/external/__init__.py$', '^lib/spack/external/ordereddict_backport.py$', '^share/spack/.*\\.sh$', '^share/spack/.*\\.bash$', '^share/spack/.*\\.csh$', '^share/spack/qa/run-[^/]*$', '^var/spack/repos/.*/package.py$']

regular expressions for licensed files.

spack.cmd.license.list_files(args)

list files in spack that should have license headers

spack.cmd.license.setup_parser(subparser)
spack.cmd.license.verify(args)

verify that files in spack have the right license header

spack.cmd.list module

spack.cmd.list.filter_by_name(pkgs, args)

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)

Decorator used to register formatters

spack.cmd.list.get_dependencies(pkg)
spack.cmd.list.github_url(pkg)

Link to a package file on github.

spack.cmd.list.html(pkg_names, out)

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)
spack.cmd.list.name_only(pkgs, out)
spack.cmd.list.rows_for_ncols(elts, ncols)

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

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

Print all packages with their latest versions.

spack.cmd.load module

spack.cmd.load.load(parser, args)
spack.cmd.load.setup_parser(subparser)

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

spack.cmd.location module

spack.cmd.location.location(parser, args)
spack.cmd.location.setup_parser(subparser)

spack.cmd.log_parse module

spack.cmd.log_parse.log_parse(parser, args)
spack.cmd.log_parse.setup_parser(subparser)

spack.cmd.maintainers module

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

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.mirror module

spack.cmd.mirror.mirror(parser, args)
spack.cmd.mirror.mirror_add(args)

Add a mirror to Spack.

spack.cmd.mirror.mirror_create(args)

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

spack.cmd.mirror.mirror_list(args)

Print out available mirrors to the console.

spack.cmd.mirror.mirror_remove(args)

Remove a mirror by name.

spack.cmd.mirror.mirror_set_url(args)

Change the URL of a mirror.

spack.cmd.mirror.setup_parser(subparser)

spack.cmd.module module

spack.cmd.module.add_deprecated_command(subparser, name)
spack.cmd.module.handle_deprecated_command(args, unknown_args)
spack.cmd.module.module(parser, args, unknown_args)
spack.cmd.module.setup_parser(subparser)

spack.cmd.patch module

spack.cmd.patch.patch(parser, args)
spack.cmd.patch.setup_parser(subparser)

spack.cmd.pkg module

class spack.cmd.pkg.GitExe

Bases: object

spack.cmd.pkg.diff_packages(rev1, rev2)
spack.cmd.pkg.get_git()

Get a git executable that runs within the packages path.

spack.cmd.pkg.list_packages(rev)
spack.cmd.pkg.packages_path()

Get the test repo if it is active, otherwise the builtin repo.

spack.cmd.pkg.pkg(parser, args)
spack.cmd.pkg.pkg_add(args)

add a package to the git stage with git add

spack.cmd.pkg.pkg_added(args)

show packages added since a commit

spack.cmd.pkg.pkg_changed(args)

show packages changed since a commit

spack.cmd.pkg.pkg_diff(args)

compare packages available in two different git revisions

spack.cmd.pkg.pkg_list(args)

list packages associated with a particular spack git revision

spack.cmd.pkg.pkg_removed(args)

show packages removed since a commit

spack.cmd.pkg.setup_parser(subparser)

spack.cmd.providers module

spack.cmd.providers.providers(parser, args)
spack.cmd.providers.setup_parser(subparser)

spack.cmd.pydoc module

spack.cmd.pydoc.pydoc(parser, args)
spack.cmd.pydoc.setup_parser(subparser)

spack.cmd.python module

spack.cmd.python.python(parser, args)
spack.cmd.python.setup_parser(subparser)

spack.cmd.reindex module

spack.cmd.reindex.reindex(parser, args)

spack.cmd.release_jobs module

spack.cmd.release_jobs.compute_spec_deps(spec_list)

Computes all the dependencies for the spec(s) and generates a JSON object which provides both a list of unique spec names as well as a comprehensive list of all the edges in the dependency graph. For example, given a single spec like ‘readline@7.0’, this function generates the following JSON object:

{
    "dependencies": [
        {
            "depends": "readline/ip6aiun",
            "spec": "readline/ip6aiun"
        },
        {
            "depends": "ncurses/y43rifz",
            "spec": "readline/ip6aiun"
        },
        {
            "depends": "ncurses/y43rifz",
            "spec": "readline/ip6aiun"
        },
        {
            "depends": "pkgconf/eg355zb",
            "spec": "ncurses/y43rifz"
        },
        {
            "depends": "pkgconf/eg355zb",
            "spec": "readline/ip6aiun"
        }
    ],
    "specs": [
        {
          "root_spec": "readline@7.0%clang@9.1.0-apple arch=darwin-...",
          "spec": "readline@7.0%clang@9.1.0-apple arch=darwin-highs...",
          "label": "readline/ip6aiun"
        },
        {
          "root_spec": "readline@7.0%clang@9.1.0-apple arch=darwin-...",
          "spec": "ncurses@6.1%clang@9.1.0-apple arch=darwin-highsi...",
          "label": "ncurses/y43rifz"
        },
        {
          "root_spec": "readline@7.0%clang@9.1.0-apple arch=darwin-...",
          "spec": "pkgconf@1.5.4%clang@9.1.0-apple arch=darwin-high...",
          "label": "pkgconf/eg355zb"
        }
    ]
}
spack.cmd.release_jobs.find_matching_config(spec, ci_mappings)
spack.cmd.release_jobs.format_root_spec(spec, main_phase, strip_compiler)
spack.cmd.release_jobs.get_cdash_build_name(spec, build_group)
spack.cmd.release_jobs.get_job_name(phase, strip_compiler, spec, osarch, build_group)
spack.cmd.release_jobs.get_spec_dependencies(specs, deps, spec_labels)
spack.cmd.release_jobs.get_spec_string(spec)
spack.cmd.release_jobs.is_main_phase(phase_name)
spack.cmd.release_jobs.populate_buildgroup(job_names, group_name, project, site, credentials, cdash_url)
spack.cmd.release_jobs.print_staging_summary(spec_labels, dependencies, stages)
spack.cmd.release_jobs.release_jobs(parser, args)
spack.cmd.release_jobs.setup_parser(subparser)
spack.cmd.release_jobs.spec_deps_key_label(s)
spack.cmd.release_jobs.spec_matches(spec, match_string)
spack.cmd.release_jobs.stage_spec_jobs(specs)
Take a set of release specs and generate a list of “stages”, where the

jobs in any stage are dependent only on jobs in previous stages. This allows us to maximize build parallelism within the gitlab-ci framework.

Parameters

specs (Iterable) – Specs to build

Returns: A tuple of information objects describing the specs, dependencies

and stages:

spec_labels: A dictionary mapping the spec labels which are made of

(pkg-name/hash-prefix), to objects containing “rootSpec” and “spec” keys. The root spec is the spec of which this spec is a dependency and the spec is the formatted spec string for this spec.

deps: A dictionary where the keys should also have appeared as keys in

the spec_labels dictionary, and the values are the set of dependencies for that spec.

stages: An ordered list of sets, each of which contains all the jobs to

built in that stage. The jobs are expressed in the same format as the keys in the spec_labels and deps objects.

spack.cmd.remove module

spack.cmd.remove.remove(parser, args)
spack.cmd.remove.setup_parser(subparser)

spack.cmd.repo module

spack.cmd.repo.repo(parser, args)
spack.cmd.repo.repo_add(args)

Add a package source to Spack’s configuration.

spack.cmd.repo.repo_create(args)

Create a new package repository.

spack.cmd.repo.repo_list(args)

Show registered repositories and their namespaces.

spack.cmd.repo.repo_remove(args)

Remove a repository from Spack’s configuration.

spack.cmd.repo.setup_parser(subparser)

spack.cmd.resource module

spack.cmd.resource.resource(parser, args)
spack.cmd.resource.resource_list(args)

list all resources known to spack (currently just patches)

spack.cmd.resource.resource_show(args)

show a resource, identified by its checksum

spack.cmd.resource.setup_parser(subparser)

spack.cmd.restage module

spack.cmd.restage.restage(parser, args)
spack.cmd.restage.setup_parser(subparser)

spack.cmd.setup module

spack.cmd.setup.setup(self, args)
spack.cmd.setup.setup_parser(subparser)
spack.cmd.setup.spack_transitive_include_path()
spack.cmd.setup.write_spconfig(package, dirty)

spack.cmd.spec module

spack.cmd.spec.nullcontext()

Empty context manager. TODO: replace with contextlib.nullcontext() if we ever require python 3.7.

spack.cmd.spec.setup_parser(subparser)
spack.cmd.spec.spec(parser, args)

spack.cmd.stage module

spack.cmd.stage.setup_parser(subparser)
spack.cmd.stage.stage(parser, args)

spack.cmd.test module

spack.cmd.test.do_list(args, unknown_args)

Print a lists of tests than what pytest offers.

spack.cmd.test.setup_parser(subparser)
spack.cmd.test.test(parser, args, unknown_args)

spack.cmd.uninstall module

spack.cmd.uninstall.add_common_arguments(subparser)
spack.cmd.uninstall.dependent_environments(specs)

Map each spec to environments that depend on it.

Parameters

specs (list) – list of Specs

Returns

mapping from spec to lists of dependent Environments

Return type

(dict)

spack.cmd.uninstall.do_uninstall(env, specs, force)

Uninstalls all the specs in a list.

Parameters
  • env (Environment) – active environment, or None if there is not one

  • specs (list) – list of specs to be uninstalled

  • force (bool) – force uninstallation (boolean)

spack.cmd.uninstall.find_matching_specs(env, specs, allow_multiple_matches=False, force=False)
Returns a list of specs matching the not necessarily

concretized specs given from cli

Parameters
  • env (Environment) – active environment, or None if there is not one

  • 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.uninstall.get_uninstall_list(args, specs, env)
spack.cmd.uninstall.inactive_dependent_environments(spec_envs)

Strip the active environment from a dependent map.

Take the output of dependent_environment() and remove the active environment from all mappings. Remove any specs in the map that now have no dependent environments. Return the result.

Parameters

(dict) – mapping from spec to lists of dependent Environments

Returns

mapping from spec to lists of inactive dependent Environments

Return type

(dict)

spack.cmd.uninstall.installed_dependents(specs, env)

Map each spec to a list of its installed dependents.

Parameters
  • specs (list) – list of Specs

  • env (Environment) – the active environment, or None

Returns

two mappings: one from specs to their dependent

environments in the active environment (or global scope if there is no environment), and one from specs to their dependents in inactive environments (empty if there is no environment

Return type

(tuple of dicts)

spack.cmd.uninstall.setup_parser(subparser)
spack.cmd.uninstall.uninstall(parser, args)
spack.cmd.uninstall.uninstall_specs(args, specs)

spack.cmd.unload module

spack.cmd.unload.setup_parser(subparser)

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

spack.cmd.unload.unload(parser, args)

spack.cmd.upload_s3 module

spack.cmd.upload_s3.get_s3_session(endpoint_url)
spack.cmd.upload_s3.setup_parser(subparser)
spack.cmd.upload_s3.update_index(args)

Update the index of an s3 buildcache

spack.cmd.upload_s3.upload_s3(parser, args)
spack.cmd.upload_s3.upload_spec(args)

Upload a spec to s3 bucket

spack.cmd.url module

spack.cmd.url.name_parsed_correctly(pkg, name)

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)

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_separators(version)

Removes 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 Version) – A version

Returns

The version with all separator characters removed

Return type

str

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

Helper function for url_list().

Parameters
  • args (argparse.Namespace) – The arguments given to spack url list

  • urls (set) – List of URLs that have already been added

  • url (str or None) – A URL to potentially add to urls depending on args

  • pkg (spack.package.PackageBase) – The Spack package

Returns

The updated set of urls

Return type

set

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

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)
spack.cmd.verify.verify(parser, args)

spack.cmd.versions module

spack.cmd.versions.setup_parser(subparser)
spack.cmd.versions.versions(parser, args)

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)

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

spack.cmd.view.setup_parser(sp)
spack.cmd.view.view(parser, args)

Produce a view of a set of packages.

Module contents

spack.cmd.all_commands()

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)

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

spack.cmd.disambiguate_spec(spec, env, local=False, installed=True)

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

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

  • env (spack.environment.Environment) – a spack environment, if one is active, or None if no environment is active

  • local (boolean, default False) – do not search chained spack instances

  • (boolean or any, or spack.database.InstallStatus or iterable (installed) – of spack.database.InstallStatus): install status argument passed to database query. See spack.database.Database._query for details.

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

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 of spack.spec.Spec) – the specs to display

  • args (optional argparse.Namespace) – 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)

  • namespace (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)

  • decorators (dict) – dictionary mappng specs to decorators

  • header_callback (function) – called at start of arch/compiler groups

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

spack.cmd.display_specs_as_json(specs, deps=False)

Convert specs to a list of json records.

spack.cmd.elide_list(line_list, max_num=10)

Takes a long list and limits it to a smaller number of elements, replacing intervening elements with ‘…’. For example:

elide_list([1,2,3,4,5,6], 4)

gives:

[1, 2, 3, '...', 6]
spack.cmd.extant_file(f)

Argparse type for files that exist.

spack.cmd.get_command(cmd_name)

Imports the command’s function from a module and returns it.

Parameters

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

spack.cmd.get_module(cmd_name)

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)
spack.cmd.iter_groups(specs, indent, all_headers)

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

spack.cmd.parse_specs(args, **kwargs)

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

spack.cmd.python_name(cmd_name)

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

spack.cmd.remove_options(parser, *options)

Remove some options from a parser.

spack.cmd.spack_is_git_repo()

Ensure that this instance of Spack is a git clone.