spack.cmd package

Submodules

spack.cmd.activate module

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

spack.cmd.add module

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

spack.cmd.analyze module

spack.cmd.analyze.analyze(parser, args, **kwargs)[source]
spack.cmd.analyze.analyze_spec(spec, analyzers=None, outdir=None, monitor=None, overwrite=False)[source]

Do an analysis for a spec, optionally adding monitoring.

We also allow the user to specify a custom output directory. analyze_spec(spec, args.analyzers, args.outdir, monitor)

Parameters
spack.cmd.analyze.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.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.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

spack.cmd.buildcache.buildcache(parser, args)[source]
spack.cmd.buildcache.buildcache_copy(args)[source]

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-file’ argument.

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

Syncs binaries (and associated metadata) from one mirror to another. Requires an active environment in order to know which specs to sync.

Parameters
  • src (str) – Source mirror URL

  • dest (str) – Destination mirror URL

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

Update a buildcache index.

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

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)[source]

create a binary package from an existing install

spack.cmd.buildcache.download_buildcache_files(concrete_spec, local_dest, require_cdashid, mirror_url=None)[source]
spack.cmd.buildcache.find_matching_specs(pkgs, allow_multiple_matches=False, env=None)[source]
Returns a list of specs matching the not necessarily

concretized specs given from cli

Parameters
  • pkgs (str) – spec to be matched against installed packages

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

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

Returns

list of specs

Return type

list

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

Get name (prefix) of buildcache entries for this spec

spack.cmd.buildcache.get_concrete_spec(args)[source]
spack.cmd.buildcache.get_tarball(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. Normally, just the tarball and .spec.json files are required, but if the –require-cdashid argument was provided, then a .cdashid file is also required.

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

get public keys available on mirrors

spack.cmd.buildcache.install_tarball(spec, args)[source]
spack.cmd.buildcache.installtarball(args)[source]

install from a binary package

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

list binary packages available from mirrors

spack.cmd.buildcache.match_downloaded_specs(pkgs, allow_multiple_matches=False, force=False, other_arch=False)[source]
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)[source]

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_specfiles(args)[source]

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)[source]
spack.cmd.buildcache.update_index(mirror_url, update_keys=False)[source]

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

spack.cmd.checksum.checksum(parser, args)[source]
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 spack environment file containing CI info. Before invoking this command, you can set the environment variable SPACK_CDASH_AUTH_TOKEN to contain the CDash authorization token for creating a build group for the generated workload and registering all generated jobs under that build group. If this environment variable is not set, no build group will be created on CDash.

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

Check a single spec against the remote mirror, and rebuild it from source if the mirror does not contain the full hash match of the spec as computed locally.

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

Rebuild the buildcache index associated with the mirror in the active, gitlab-enabled environment.

spack.cmd.ci.ci_reproduce(args)[source]
spack.cmd.ci.get_env_var(variable_name)[source]
spack.cmd.ci.setup_parser(subparser)[source]

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: argparse.Action

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

spack.cmd.clean.clean(parser, args)[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, out=None, aliases=False)[source]

Bases: llnl.util.argparsewriter.ArgparseCompletionWriter

Write argparse output as bash programmable tab completion.

body(positionals, optionals, subcommands)[source]

Returns the body of the function.

Parameters
  • positionals (list) – list of positional arguments

  • optionals (list) – list of optional arguments

  • subcommands (list) – list of subcommand parsers

Returns

the function body

Return type

str

optionals(optionals)[source]

Returns the syntax for reporting optional flags.

Parameters

optionals (list) – list of optional arguments

Returns

the syntax for optional flags

Return type

str

positionals(positionals)[source]

Returns the syntax for reporting positional arguments.

Parameters

positionals (list) – list of positional arguments

Returns

the syntax for positional arguments

Return type

str

subcommands(subcommands)[source]

Returns the syntax for reporting subcommands.

Parameters

subcommands (list) – list of subcommand parsers

Returns

the syntax for subcommand parsers

Return type

str

class spack.cmd.commands.SpackArgparseRstWriter(prog, out=None, aliases=False, documented_commands=[], rst_levels=['-', '-', '^', '~', ':', '`'])[source]

Bases: llnl.util.argparsewriter.ArgparseRstWriter

RST writer tailored for spack documentation.

usage(*args)[source]
class spack.cmd.commands.SubcommandWriter(prog, out=None, aliases=False)[source]

Bases: llnl.util.argparsewriter.ArgparseWriter

format(cmd)[source]

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

Override this in subclasses to define how each subcommand should be displayed.

Parameters

(Command) – parsed information about a command or subcommand

Returns

the string representation of this subcommand

Return type

str

spack.cmd.commands.bash(args, out)[source]
spack.cmd.commands.commands(parser, args)[source]
spack.cmd.commands.formatter(func)[source]

Decorator used to register formatters

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

list of command formatters

spack.cmd.commands.names(args, out)[source]
spack.cmd.commands.prepend_header(args, out)[source]
spack.cmd.commands.rst(args, out)[source]
spack.cmd.commands.rst_index(out)[source]
spack.cmd.commands.setup_parser(subparser)[source]
spack.cmd.commands.subcommands(args, out)[source]
spack.cmd.commands.update_completion(parser, args)[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.

spack.cmd.commands.update_completion_args = {'bash': {'aliases': True, 'format': 'bash', 'header': '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/v0.17.0/lib/spack/docs/_spack_root/share/spack/bash/spack-completion.in', 'update': '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/v0.17.0/lib/spack/docs/_spack_root/share/spack/spack-completion.bash'}}

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_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.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: 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)[source]

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)[source]

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[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: 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)[source]

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)[source]

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.MavenPackageTemplate(name, url, versions)[source]

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

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)[source]

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)[source]

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)[source]

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, url, *args, **kwargs)[source]

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. Only add the python dependency\n    # if you need specific versions. A generic python dependency is\n    # added implicity by the PythonPackage class.\n    # depends_on('python@2.X:2.Y,3.Z:', type=('build', 'run'))\n    # depends_on('py-setuptools', type='build')\n    # depends_on('py-foo',        type=('build', 'run'))"
class spack.cmd.create.QMakePackageTemplate(name, url, versions)[source]

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, url, *args, **kwargs)[source]

Bases: spack.cmd.create.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.RubyPackageTemplate(name, *args, **kwargs)[source]

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

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)[source]

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)[source]
spack.cmd.create.get_build_system(args, 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
  • 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)[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

args (argparse.Namespace) – The arguments 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(args)[source]

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)[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.deactivate module

spack.cmd.deactivate.deactivate(parser, args)[source]
spack.cmd.deactivate.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.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)[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.docs module

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

spack.cmd.edit module

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

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)[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_list(args)[source]
spack.cmd.env.env_list_setup_parser(subparser)[source]

list available 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 spack.yaml files embedded in repositories should be removed manually.

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

remove 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'], ['list', 'ls'], ['status', 'st'], 'loads', 'view', 'update', 'revert']

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

spack.cmd.external.external(parser, args)[source]
spack.cmd.external.external_find(args)[source]
spack.cmd.external.external_list(args)[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)[source]
spack.cmd.find.find(parser, args)[source]
spack.cmd.find.query_arguments(args)[source]
spack.cmd.find.setup_env(env)[source]

Create a function for decorating specs when in an environment.

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

spack.cmd.flake8 module

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

spack.cmd.gc module

spack.cmd.gc.gc(parser, args)[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(variants)[source]

Bases: object

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

Return a function to pad elements of a list.

spack.cmd.info.print_text_info(pkg)[source]

Print out a plain text description of a package.

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.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, **kwargs)[source]
spack.cmd.install.install_specs(cli_args, kwargs, specs)[source]

Do the actual installation.

Parameters
  • cli_args (argparse.Namespace) – argparse namespace with command arguments

  • kwargs (dict) – keyword arguments

  • specs (list) – list of (abstract, concrete) spec tuples

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

Parse cli arguments and construct a dictionary that will be passed to the package installer.

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.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)[source]
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$', '^lib/spack/spack/.*\\.py$', '^lib/spack/spack/.*\\.sh$', '^lib/spack/spack/.*\\.lp$', '^lib/spack/llnl/.*\\.py$', '^lib/spack/env/cc$', '^lib/spack/docs/(?!command_index|spack|llnl).*\\.rst$', '^lib/spack/docs/.*\\.py$', '^lib/spack/docs/spack.yaml$', '^lib/spack/external/__init__.py$', '^lib/spack/external/ordereddict_backport.py$', '^share/spack/.*\\.sh$', '^share/spack/.*\\.bash$', '^share/spack/.*\\.csh$', '^share/spack/.*\\.fish$', '^share/spack/qa/run-[^/]*$', '^share/spack/bash/spack-completion.in$', '^share/spack/templates/misc/coconcretization.pyt$', '^.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.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.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

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_url(args)[source]

Change the URL of a mirror.

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

spack.cmd.module module

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

spack.cmd.monitor module

spack.cmd.monitor.monitor(parser, args, **kwargs)[source]
spack.cmd.monitor.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

class spack.cmd.pkg.GitExe[source]

Bases: object

spack.cmd.pkg.diff_packages(rev1, rev2)[source]
spack.cmd.pkg.get_git()[source]

Get a git executable that runs within the packages path.

spack.cmd.pkg.list_packages(rev)[source]
spack.cmd.pkg.packages_path()[source]

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

spack.cmd.pkg.pkg(parser, 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_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.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.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.nullcontext()[source]

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

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.print_style_header(file_list, args)[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_order = [('isort', 'py-isort@4.3.5:'), ('mypy', 'py-mypy@0.900:'), ('black', 'py-black'), ('flake8', 'py-flake8')]

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 spack spec needed to install it.

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.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.first_line(docstring)[source]

Return the first line of the docstring.

spack.cmd.test.has_test_method(pkg)[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.confirm_removal(specs)[source]

Display the list of specs to be removed and ask for confirmation.

Parameters

specs (list) – specs to be removed

spack.cmd.uninstall.dependent_environments(specs)[source]

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)[source]

Uninstalls all the specs in a list.

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

concretized specs given from cli

Parameters
  • env (spack.environment.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

Return type

list

spack.cmd.uninstall.get_uninstall_list(args, specs, env)[source]
spack.cmd.uninstall.inactive_dependent_environments(spec_envs)[source]

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

spec_envs (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)[source]

Map each spec to a list of its installed dependents.

Parameters
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

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.

Module contents

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

Bases: spack.error.SpackError

Exception class thrown for impermissible command names

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

Bases: spack.error.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
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
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 (typing.Callable) – called at start of arch/compiler groups

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

  • output (typing.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.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.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, **kwargs)[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='')[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.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.