spack.cmd package
- exception spack.cmd.CommandNameError(name)[source]
Bases:
SpackError
Exception class thrown for impermissible command names
- exception spack.cmd.CommandNotFoundError(cmd_name)[source]
Bases:
SpackError
Exception class thrown when a requested command is not recognized as such.
- exception spack.cmd.MultipleSpecsMatch[source]
Bases:
Exception
Raised when multiple specs match a constraint, in a context where this is not allowed.
- exception spack.cmd.NoSpecMatches[source]
Bases:
Exception
Raised when no spec matches a constraint, in a context where this is not allowed.
- exception spack.cmd.PythonNameError(name)[source]
Bases:
SpackError
Exception class thrown for impermissible python names
- spack.cmd.all_commands()[source]
Get a sorted list of all spack commands.
This will list the lib/spack/spack/cmd directory and find the commands there to construct the list. It does not actually import the python files – just gets the names.
- spack.cmd.disambiguate_spec(spec: Spec, env: Environment | None, local: bool = False, installed: bool | InstallRecordStatus = True, first: bool = False) Spec [source]
Given a spec, figure out which installed package it refers to.
- Parameters:
spec – a spec to disambiguate
env – a spack environment, if one is active, or None if no environment is active
local – do not search chained spack instances
installed – install status argument passed to database query.
first – returns the first matching spec, even if more than one match is found
- spack.cmd.disambiguate_spec_from_hashes(spec: Spec, hashes: List[str] | None, local: bool = False, installed: bool | InstallRecordStatus = True, first: bool = False) Spec [source]
Given a spec and a list of hashes, get concrete spec the spec refers to.
- Parameters:
spec – a spec to disambiguate
hashes – a set of hashes of specs among which to disambiguate
local – if True, do not search chained spack instances
installed – install status argument passed to database query.
first – returns the first matching spec, even if more than one match is found
- spack.cmd.display_specs(specs, args=None, **kwargs)[source]
Display human readable specs with customizable formatting.
Prints the supplied specs to the screen, formatted according to the arguments provided.
Specs are grouped by architecture and compiler, and columnized if possible.
Options can add more information to the default display. Options can be provided either as keyword arguments or as an argparse namespace. Keyword arguments take precedence over settings in the argparse namespace.
- Parameters:
specs (list) – the specs to display
args (argparse.Namespace or None) – namespace containing formatting arguments
- Keyword Arguments:
paths (bool) – Show paths with each displayed spec
deps (bool) – Display dependencies with specs
long (bool) – Display short hashes with specs
very_long (bool) – Display full hashes with specs (supersedes
long
)namespaces (bool) – Print namespaces along with names
show_flags (bool) – Show compiler flags with specs
variants (bool) – Show variants with specs
indent (int) – indent each line this much
groups (bool) – display specs grouped by arch/compiler (default True)
decorator (Callable) – function to call to decorate specs
all_headers (bool) – show headers even when arch/compiler aren’t defined
status_fn (Callable) – if provided, prepend install-status info
output (IO) – A file object to write to. Default is
sys.stdout
- spack.cmd.display_specs_as_json(specs, deps=False)[source]
Convert specs to a list of json records.
- spack.cmd.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:
via
spack -e ENV
orspack -D DIR
(arguments)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.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.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.matching_specs_from_env(specs)[source]
Same as
matching_spec_from_env
but respects spec unification rules.For each spec, if there is a matching spec in the environment it is used. If no matching spec is found, this will return the given spec but concretized in the context of the active environment and other given specs, with unification rules applied.
- spack.cmd.parse_specs(args: str | List[str], concretize: bool = False, tests: bool | Iterable[str] = False) List[Spec] [source]
Convenience function for parsing arguments from specs. Handles common exceptions and dies if there are errors.
- spack.cmd.print_how_many_pkgs(specs, pkg_type='', suffix='')[source]
Given a list of specs, this will print a message about how many specs are in that list.
- spack.cmd.python_name(cmd_name)[source]
Convert
-
to_
in command name, to make a valid identifier.
- spack.cmd.quote_kvp(string: str) str [source]
For strings like
name=value
orname==value
, quote and escape the value if needed.This is a compromise to respect quoting of key-value pairs on the CLI. The shell strips quotes from quoted arguments, so we cannot know exactly how CLI arguments were quoted. To compensate, we re-add quotes around anything staritng with
name=
orname==
, and we assume the rest of the argument is the value. This covers the common cases of passign flags, e.g.,cflags="-O2 -g"
on the command line.
- spack.cmd.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.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.
Subpackages
Submodules
spack.cmd.add module
spack.cmd.arch module
spack.cmd.audit module
spack.cmd.blame module
- spack.cmd.blame.dump_json(rows, last_mod, total_lines, emails)[source]
Dump the blame as a json object to the terminal.
spack.cmd.bootstrap module
- spack.cmd.bootstrap.LOCAL_MIRROR_DIR = 'bootstrap_cache'
Subdirectory where to create the mirror
spack.cmd.build_env module
spack.cmd.buildcache module
- exception spack.cmd.buildcache.PackageNotInstalledError(message, long_message=None)[source]
Bases:
SpackError
Raised when a spec is not installed but picked to be packaged.
- exception spack.cmd.buildcache.PackagesAreNotInstalledError(specs: List[Spec])[source]
Bases:
SpackError
Raised when a list of specs is not installed but picked to be packaged.
- spack.cmd.buildcache.check_fn(args: Namespace)[source]
check specs against remote binary mirror(s) to see if any need to be rebuilt
this command uses the process exit code to indicate its result, specifically, if the exit code is non-zero, then at least one of the indicated specs needs to be rebuilt
- spack.cmd.buildcache.copy_buildcache_file(src_url, dest_url, local_path=None)[source]
Copy from source url to destination url
- spack.cmd.buildcache.download_fn(args)[source]
download buildcache entry from a remote mirror to local folder
this command uses the process exit code to indicate its result, specifically, a non-zero exit code indicates that the command failed to download at least one of the required buildcache components
- spack.cmd.buildcache.get_buildcache_name_fn(args)[source]
get name (prefix) of buildcache entries for this spec
- spack.cmd.buildcache.manifest_copy(manifest_file_list, dest_mirror=None)[source]
Read manifest files containing information about specific specs to copy from source to destination, remove duplicates since any binary packge for a given hash should be the same as any other, and copy all files specified in the manifest files.
- spack.cmd.buildcache.save_specfile_fn(args)[source]
get full spec for dependencies and write them to files in the specified output directory
uses exit code to signal success or failure. an exit code of zero means the command was likely successful. if any errors or exceptions are encountered, or if expected command-line arguments are not provided, then the exit code will be non-zero
- spack.cmd.buildcache.setup_parser(subparser: ArgumentParser)[source]
spack.cmd.cd module
spack.cmd.change module
spack.cmd.checksum module
- spack.cmd.checksum.add_versions_to_package(pkg: PackageBase, version_lines: str, is_batch: bool)[source]
Add checksumed versions to a package’s instructions and open a user’s editor so they may double check the work of the function.
- Parameters:
pkg (spack.package_base.PackageBase) – A package class for a given package in Spack.
version_lines (str) – A string of rendered version lines.
- spack.cmd.checksum.print_checksum_status(pkg: PackageBase, version_hashes: dict)[source]
Verify checksums present in version_hashes against those present in the package’s instructions.
- Parameters:
pkg (spack.package_base.PackageBase) – A package class for a given package in Spack.
version_hashes (dict) – A dictionary of the form: version -> checksum.
spack.cmd.ci module
- spack.cmd.ci.ci_generate(args)[source]
generate jobs file from a CI-aware spack file
if you want to report the results on CDash, you will need to set the SPACK_CDASH_AUTH_TOKEN before invoking this command. the value must be the CDash authorization token needed to create a build group and register all generated jobs under it
- spack.cmd.ci.ci_rebuild(args)[source]
rebuild a spec if it is not on the remote mirror
check a single spec against the remote mirror, and rebuild it from source if the mirror does not contain the hash
- spack.cmd.ci.ci_reindex(args)[source]
rebuild the buildcache index for the remote mirror
use the active, gitlab-enabled environment to rebuild the buildcache index for the associated mirror
spack.cmd.clean module
spack.cmd.clone module
spack.cmd.commands module
- class spack.cmd.commands.BashCompletionWriter(prog: str, out: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, aliases: bool = False)[source]
Bases:
ArgparseWriter
Write argparse output as bash programmable tab completion.
- body(positionals: Sequence[str], optionals: Sequence[str], subcommands: Sequence[str]) str [source]
Return the body of the function.
- Parameters:
positionals – List of positional arguments.
optionals – List of optional arguments.
subcommands – List of subcommand parsers.
- Returns:
Function body.
- end_function(prog: str) str [source]
Return the syntax needed to end a function definition.
- Parameters:
prog – Program name
- Returns:
Function definition ending.
- format(cmd: Command) str [source]
Return the string representation of a single node in the parser tree.
- Parameters:
cmd – Parsed information about a command or subcommand.
- Returns:
String representation of this subcommand.
- optionals(optionals: Sequence[str]) str [source]
Return the syntax for reporting optional flags.
- Parameters:
optionals – List of optional arguments.
- Returns:
Syntax for optional flags.
- positionals(positionals: Sequence[str]) str [source]
Return the syntax for reporting positional arguments.
- Parameters:
positionals – List of positional arguments.
- Returns:
Syntax for positional arguments.
- class spack.cmd.commands.FishCompletionWriter(prog: str, out: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, aliases: bool = False)[source]
Bases:
ArgparseWriter
Write argparse output as bash programmable tab completion.
- complete(prog: str, positionals: List[Tuple[str, Iterable[Any] | None, int | str | None, str]], optionals: List[Tuple[Sequence[str], List[str], str, int | str | None, str]], subcommands: List[Tuple[ArgumentParser, str, str]]) str [source]
Return all the completion commands.
- Parameters:
prog – Program name.
positionals – List of positional arguments.
optionals – List of optional arguments.
subcommands – List of subcommand parsers.
- Returns:
Completion command.
- static complete_head(prog: str, index: int | None = None, nargs: int | str | None = None) str [source]
Return the head of the completion command.
- Parameters:
prog – Program name.
index – Index of positional argument.
nargs – Number of arguments.
- Returns:
Head of the completion command.
- format(cmd: Command) str [source]
Return the string representation of a single node in the parser tree.
- Parameters:
cmd – Parsed information about a command or subcommand.
- Returns:
String representation of a node.
- optionals(prog: str, optionals: List[Tuple[Sequence[str], List[str], str, int | str | None, str]]) str [source]
Return the completion for optional arguments.
- Parameters:
prog – Program name.
optionals – List of optional arguments.
- Returns:
Completion command.
- optspecs(prog: str, optionals: List[Tuple[Sequence[str], List[str], str, int | str | None, str]]) str [source]
Read the optionals and return the command to set optspec.
- Parameters:
prog – Program name.
optionals – List of optional arguments.
- Returns:
Command to set optspec variable.
- class spack.cmd.commands.SpackArgparseRstWriter(prog: str, out: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, aliases: bool = False, documented_commands: ~typing.Set[str] = {}, rst_levels: ~typing.Sequence[str] = ['-', '-', '^', '~', ':', '`'])[source]
Bases:
ArgparseRstWriter
RST writer tailored for spack documentation.
- class spack.cmd.commands.SubcommandWriter(prog: str, out: ~typing.IO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, aliases: bool = False)[source]
Bases:
ArgparseWriter
Write argparse output as a list of subcommands.
- spack.cmd.commands.bash(args: Namespace, out: IO) None [source]
Bash tab-completion script.
- Parameters:
args – Command-line arguments.
out – File object to write to.
- spack.cmd.commands.commands(parser: ArgumentParser, args: Namespace) None [source]
Main function that calls formatter functions.
- Parameters:
parser – Argument parser.
args – Command-line arguments.
- spack.cmd.commands.formatter(func: Callable[[Namespace, IO], None]) Callable[[Namespace, IO], None] [source]
Decorator used to register formatters.
- Parameters:
func – Formatting function.
- Returns:
The same function.
- spack.cmd.commands.formatters: Dict[str, Callable[[Namespace, IO], None]] = {'bash': <function bash>, 'fish': <function fish>, 'names': <function names>, 'rst': <function rst>, 'subcommands': <function subcommands>}
list of command formatters
- spack.cmd.commands.names(args: Namespace, out: IO) None [source]
Simple list of top-level commands.
- Parameters:
args – Command-line arguments.
out – File object to write to.
- spack.cmd.commands.prepend_header(args: Namespace, out: IO) None [source]
Prepend header text at the beginning of a file.
- Parameters:
args – Command-line arguments.
out – File object to write to.
- spack.cmd.commands.rst(args: Namespace, out: IO) None [source]
ReStructuredText documentation of subcommands.
- Parameters:
args – Command-line arguments.
out – File object to write to.
- spack.cmd.commands.rst_index(out: IO) None [source]
Generate an index of all commands.
- Parameters:
out – File object to write to.
- spack.cmd.commands.setup_parser(subparser: ArgumentParser) None [source]
Set up the argument parser.
- Parameters:
subparser – Preliminary argument parser.
- spack.cmd.commands.subcommands(args: Namespace, out: IO) None [source]
Hierarchical tree of subcommands.
- Parameters:
args – Command-line arguments.
out – File object to write to.
- spack.cmd.commands.update_completion(parser: ArgumentParser, args: Namespace) None [source]
Iterate through the shells and update the standard completion files.
This is a convenience method to avoid calling this command many times, and to simplify completion update for developers.
- Parameters:
parser – Argument parser.
args – Command-line arguments.
- spack.cmd.commands.update_completion_args: Dict[str, Dict[str, Any]] = {'bash': {'aliases': True, 'format': 'bash', 'header': '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/latest/lib/spack/docs/_spack_root/share/spack/bash/spack-completion.bash', 'update': '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/latest/lib/spack/docs/_spack_root/share/spack/spack-completion.bash'}, 'fish': {'aliases': True, 'format': 'fish', 'header': '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/latest/lib/spack/docs/_spack_root/share/spack/fish/spack-completion.fish', 'update': '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/latest/lib/spack/docs/_spack_root/share/spack/spack-completion.fish'}}
standard arguments for updating completion scripts we iterate through these when called with –update-completion
spack.cmd.compiler module
spack.cmd.compilers module
spack.cmd.concretize module
spack.cmd.config module
- 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_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.containerize module
spack.cmd.create module
- class spack.cmd.create.AutoreconfPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for Autotools-based packages that do not come with a
configure
script- base_class_name = 'AutotoolsPackage'
- body_def = ' def autoreconf(self, spec, prefix):\n # FIXME: Modify the autoreconf method as necessary\n autoreconf("--install", "--verbose", "--force")\n\n def configure_args(self):\n # FIXME: Add arguments other than --prefix\n # FIXME: If not needed delete this function\n args = []\n return args'
- dependencies = ' depends_on("autoconf", type="build")\n depends_on("automake", type="build")\n depends_on("libtool", type="build")\n depends_on("m4", type="build")\n\n # FIXME: Add additional dependencies if required.\n # depends_on("foo")'
- class spack.cmd.create.AutotoolsPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for Autotools-based packages that do come with a
configure
script- base_class_name = 'AutotoolsPackage'
- body_def = ' def configure_args(self):\n # FIXME: Add arguments other than --prefix\n # FIXME: If not needed delete this function\n args = []\n return args'
- class spack.cmd.create.BazelPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for Bazel-based packages
- body_def = ' def install(self, spec, prefix):\n # FIXME: Add logic to build and install here.\n bazel()'
- dependencies = ' # FIXME: Add additional dependencies if required.\n depends_on("bazel", type="build")'
- class spack.cmd.create.BuildSystemAndLanguageGuesser[source]
Bases:
object
An instance of BuildSystemAndLanguageGuesser provides a callable object to be used during
spack create
. By passing this object tospack checksum
, we can take a peek at the fetched tarball and discern the build system it uses
- class spack.cmd.create.BundlePackageTemplate(name: str, versions, languages: List[str])[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.'
- class spack.cmd.create.CMakePackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for CMake-based packages
- base_class_name = 'CMakePackage'
- body_def = ' def cmake_args(self):\n # FIXME: Add arguments other than\n # FIXME: CMAKE_INSTALL_PREFIX and CMAKE_BUILD_TYPE\n # FIXME: If not needed delete this function\n args = []\n return args'
- spack.cmd.create.CXX_EXT = {'.C', '.CPP', '.c++', '.cc', '.ccm', '.cpp', '.cxx', '.h++', '.hh', '.hpp', '.hxx', '.inl', '.ipp', '.ixx', '.tcc', '.tpp'}
C++ file extensions
- spack.cmd.create.C_EXT = {'.c'}
C file extensions
- class spack.cmd.create.CargoPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for cargo-based packages
- base_class_name = 'CargoPackage'
- body_def = ''
- spack.cmd.create.FORTRAN_EXT = {'.F', '.F77', '.F90', '.F95', '.FOR', '.FTN', '.f', '.f77', '.f90', '.f95', '.for', '.ftn'}
Fortran file extensions
- class spack.cmd.create.GoPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for Go-module-based packages
- base_class_name = 'GoPackage'
- body_def = ''
- class spack.cmd.create.IntelPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for licensed Intel software
- base_class_name = 'IntelPackage'
- body_def = ' # FIXME: Override `setup_environment` if necessary.'
- class spack.cmd.create.LuaPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for LuaRocks-based packages
- base_class_name = 'LuaPackage'
- body_def = ' def luarocks_args(self):\n # FIXME: Add arguments to `luarocks make` other than rockspec path\n # FIXME: If not needed delete this function\n args = []\n return args'
- class spack.cmd.create.MakefilePackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for Makefile packages
- base_class_name = 'MakefilePackage'
- body_def = ' def edit(self, spec, prefix):\n # FIXME: Edit the Makefile if necessary\n # FIXME: If not needed delete this function\n # makefile = FileFilter("Makefile")\n # makefile.filter("CC = .*", "CC = cc")\n pass'
- class spack.cmd.create.MavenPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for Maven-based packages
- base_class_name = 'MavenPackage'
- body_def = ' def build(self, spec, prefix):\n # FIXME: If not needed delete this function\n pass'
- class spack.cmd.create.MesonPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for meson-based packages
- base_class_name = 'MesonPackage'
- body_def = ' def meson_args(self):\n # FIXME: If not needed delete this function\n args = []\n return args'
- class spack.cmd.create.OctavePackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for octave packages
- base_class_name = 'OctavePackage'
- dependencies = ' extends("octave")\n\n # FIXME: Add additional dependencies if required.\n # depends_on("octave-foo", type=("build", "run"))'
- class spack.cmd.create.PackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
BundlePackageTemplate
Provides the default values to be used for the package file template
- base_class_name = 'Package'
- body_def = ' def install(self, spec, prefix):\n # FIXME: Unknown build system\n make()\n make("install")'
- url_line = ' url = "{url}"'
- class spack.cmd.create.PerlbuildPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PerlmakePackageTemplate
Provides appropriate overrides for Perl extensions that come with a Build.PL instead of a Makefile.PL
- dependencies = ' depends_on("perl-module-build", type="build")\n\n # FIXME: Add additional dependencies if required:\n # depends_on("perl-foo", type=("build", "run"))'
- class spack.cmd.create.PerlmakePackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for Perl extensions that come with a Makefile.PL
- base_class_name = 'PerlPackage'
- body_def = ' def configure_args(self):\n # FIXME: Add non-standard arguments\n # FIXME: If not needed delete this function\n args = []\n return args'
- dependencies = ' # FIXME: Add dependencies if required:\n # depends_on("perl-foo", type=("build", "run"))'
- class spack.cmd.create.PythonPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for python extensions
- base_class_name = 'PythonPackage'
- body_def = ' def config_settings(self, spec, prefix):\n # FIXME: Add configuration settings to be passed to the build backend\n # FIXME: If not needed, delete this function\n settings = {}\n return settings'
- dependencies = ' # FIXME: Only add the python/pip/wheel dependencies if you need specific versions\n # or need to change the dependency type. Generic python/pip/wheel dependencies are\n # added implicity by the PythonPackage base class.\n # depends_on("python@2.X:2.Y,3.Z:", type=("build", "run"))\n # depends_on("py-pip@X.Y:", type="build")\n # depends_on("py-wheel@X.Y:", type="build")\n\n # FIXME: Add a build backend, usually defined in pyproject.toml. If no such file\n # exists, use setuptools.\n # depends_on("py-setuptools", type="build")\n # depends_on("py-hatchling", type="build")\n # depends_on("py-flit-core", type="build")\n # depends_on("py-poetry-core", type="build")\n\n # FIXME: Add additional dependencies if required.\n # depends_on("py-foo", type=("build", "run"))'
- class spack.cmd.create.QMakePackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for QMake-based packages
- base_class_name = 'QMakePackage'
- body_def = ' def qmake_args(self):\n # FIXME: If not needed delete this function\n args = []\n return args'
- class spack.cmd.create.RPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for R extensions
- base_class_name = 'RPackage'
- body_def = ' def configure_args(self):\n # FIXME: Add arguments to pass to install via --configure-args\n # FIXME: If not needed delete this function\n args = []\n return args'
- dependencies = ' # FIXME: Add dependencies if required.\n # depends_on("r-foo", type=("build", "run"))'
- class spack.cmd.create.RacketPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides approriate overrides for Racket extensions
- base_class_name = 'RacketPackage'
- body_def = ' # FIXME: specify the name of the package,\n # as it should appear to ``raco pkg install``\n name = "{0}"\n # FIXME: set to true if published on pkgs.racket-lang.org\n # pkgs = False\n # FIXME: specify path to the root directory of the\n # package, if not the base directory\n # subdirectory = None\n '
- dependencies = ' # FIXME: Add dependencies if required. Only add the racket dependency\n # if you need specific versions. A generic racket dependency is\n # added implicity by the RacketPackage class.\n # depends_on("racket@8.3:", type=("build", "run"))'
- url_line = ' # FIXME: set the proper location from which to fetch your package\n git = "git@github.com:example/example.git"\n '
- class spack.cmd.create.RubyPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for Ruby packages
- base_class_name = 'RubyPackage'
- body_def = ' def build(self, spec, prefix):\n # FIXME: If not needed delete this function\n pass'
- dependencies = ' # FIXME: Add dependencies if required. Only add the ruby dependency\n # if you need specific versions. A generic ruby dependency is\n # added implicity by the RubyPackage class.\n # depends_on("ruby@X.Y.Z:", type=("build", "run"))\n # depends_on("ruby-foo", type=("build", "run"))'
- class spack.cmd.create.SIPPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for SIP packages.
- base_class_name = 'SIPPackage'
- body_def = ' def configure_args(self, spec, prefix):\n # FIXME: Add arguments other than --bindir and --destdir\n # FIXME: If not needed delete this function\n args = []\n return args'
- class spack.cmd.create.SconsPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate overrides for SCons-based packages
- base_class_name = 'SConsPackage'
- body_def = ' def build_args(self, spec, prefix):\n # FIXME: Add arguments to pass to build.\n # FIXME: If not needed delete this function\n args = []\n return args'
- class spack.cmd.create.WafPackageTemplate(name, url, versions, languages: List[str])[source]
Bases:
PackageTemplate
Provides appropriate override for Waf-based packages
- base_class_name = 'WafPackage'
- body_def = ' # FIXME: Override configure_args(), build_args(),\n # or install_args() if necessary.'
- spack.cmd.create.get_build_system(template: str, url: str, guesser: BuildSystemAndLanguageGuesser) str [source]
Determine the build system template.
If a template is specified, always use that. Otherwise, if a URL is provided, download the tarball and peek inside to guess what build system it uses. Otherwise, use a generic template by default.
- Parameters:
template –
--template
argument given tospack create
url –
url
argument given tospack create
guesser – 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:
- spack.cmd.create.get_name(name, url)[source]
Get the name of the package based on the supplied arguments.
If a name was provided, always use that. Otherwise, if a URL was provided, extract the name from that. Otherwise, use a default.
- 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.cmd.create.get_versions(args, name)[source]
Returns a list of versions and hashes for a package.
Also returns a BuildSystemAndLanguageGuesser 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 BuildSystemAndLanguageGuesser object
- Return type:
spack.cmd.debug module
spack.cmd.deconcretize module
spack.cmd.dependencies module
spack.cmd.dependents module
- spack.cmd.dependents.get_dependents(pkg_name, ideps, transitive=False, dependents=None)[source]
Get all dependents for a package.
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.dev_build module
spack.cmd.develop module
spack.cmd.diff module
- spack.cmd.diff.compare_specs(a, b, to_string=False, color=None, ignore_packages=None)[source]
Generate a comparison, including diffs (for each side) and an intersection.
We can either print the result to the console, or parse into a json object for the user to save. We return an object that shows the differences, intersection, and names for a pair of specs a and b.
- Parameters:
a (spack.spec.Spec) – the first spec to compare
b (spack.spec.Spec) – the second spec to compare
a_name (str) – the name of spec a
b_name (str) – the name of spec b
to_string (bool) – return an object that can be json dumped
color (bool) – whether to format the names for the console
- spack.cmd.diff.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.docs module
spack.cmd.edit module
spack.cmd.env module
- class spack.cmd.env.ViewAction[source]
Bases:
object
- 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_create_setup_parser(subparser)[source]
create a new environment
create a new environment or, optionally, copy an existing environment
a manifest file results in a new abstract environment while a lock file creates a new concrete environment
- spack.cmd.env.env_depfile_setup_parser(subparser)[source]
generate a depfile to exploit parallel builds across specs
requires the active environment to be concrete
- spack.cmd.env.env_loads_setup_parser(subparser)[source]
list modules for an installed environment ‘(see spack module loads)’
- spack.cmd.env.env_remove_setup_parser(subparser)[source]
remove managed environment(s)
remove existing environment(s) managed by Spack
directory environments and manifests embedded in repositories must be removed manually
- spack.cmd.env.env_rename_setup_parser(subparser)[source]
rename an existing environment
rename a managed environment or move an independent/directory environment
operation cannot be performed to or from an active environment
- spack.cmd.env.env_revert_setup_parser(subparser)[source]
restore the environment manifest to its previous format
revert the environment’s manifest to the schema format from its last ‘spack env update’
the current manifest will be overwritten by the backup copy and the backup copy will be removed
- spack.cmd.env.env_track_setup_parser(subparser)[source]
track an environment from a directory in Spack
- spack.cmd.env.env_untrack_setup_parser(subparser)[source]
track an environment from a directory in Spack
- spack.cmd.env.env_update_setup_parser(subparser)[source]
update the environment manifest to the latest schema format
update the environment to the latest schema format, which may not be readable by older versions of spack
a backup copy of the manifest is retained in case there is a need to revert this operation
- spack.cmd.env.env_view_setup_parser(subparser)[source]
manage the environment’s view
provide the path when enabling a view with a non-default path
- spack.cmd.env.subcommand_functions = {}
Dictionary mapping subcommand names and aliases to functions
- spack.cmd.env.subcommands = ['activate', 'deactivate', 'create', ['remove', 'rm'], ['rename', 'mv'], ['list', 'ls'], ['status', 'st'], 'loads', 'view', 'update', 'revert', 'depfile', 'track', 'untrack']
List of subcommands of spack env
spack.cmd.extensions module
spack.cmd.external module
- exception spack.cmd.external.NoManifestFileError(message, long_message=None)[source]
Bases:
SpackError
spack.cmd.fetch module
spack.cmd.find module
- spack.cmd.find.display_env(env, args, decorator, results)[source]
Display extra find output when running in an environment.
In an environment, spack find outputs a preliminary section showing the root specs of the environment (this is in addition to the section listing out specs matching the query parameters).
spack.cmd.gc module
spack.cmd.gpg module
spack.cmd.graph module
spack.cmd.help module
spack.cmd.info module
spack.cmd.install module
- spack.cmd.install.compute_tests_install_kwargs(specs, cli_test_arg)[source]
Translate the test cli argument into the proper install argument
- spack.cmd.install.concrete_specs_from_cli(args, install_kwargs)[source]
Return abstract and concrete spec parsed from the command line.
- spack.cmd.install.concrete_specs_from_file(args)[source]
Return the list of concrete specs read from files.
- spack.cmd.install.default_log_file(spec)[source]
Computes the default filename for the log file and creates the corresponding directory if not present
- spack.cmd.install.install_kwargs_from_args(args)[source]
Translate command line arguments into a dictionary that will be passed to the package installer.
- spack.cmd.install.install_with_active_env(env: Environment, args, install_kwargs, reporter_factory)[source]
spack.cmd.license module
- class spack.cmd.license.ErrorType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
- GENERAL_MISMATCH = 3
- NOT_IN_FIRST_N_LINES = 2
- SPDX_MISMATCH = 1
- spack.cmd.license.apache2_mit_spdx = '(Apache-2.0 OR MIT)'
Spack’s license identifier
- spack.cmd.license.license_line_regexes = ['Copyright (Spack|sbang) [Pp]roject [Dd]evelopers\\. See COPYRIGHT file for details.', '', 'SPDX-License-Identifier: \\(Apache-2\\.0 OR MIT\\)']
regexes for valid license lines at tops of files
- spack.cmd.license.license_lines = 6
SPDX license id must appear in the first <license_lines> lines of a file
- spack.cmd.license.licensed_files = ['^bin/spack$', '^bin/spack\\.bat$', '^bin/spack\\.ps1$', '^bin/spack_pwsh\\.ps1$', '^bin/sbang$', '^bin/spack-python$', '^bin/haspywin\\.py$', '^lib/spack/spack_installable/main\\.py$', '^lib/spack/spack/(?!(test/)?util/unparse).*\\.py$', '^lib/spack/spack/.*\\.sh$', '^lib/spack/spack/.*\\.lp$', '^lib/spack/llnl/.*\\.py$', '^lib/spack/env/cc$', '^lib/spack/spack/test/data/style/broken.dummy', '^lib/spack/spack/test/data/unparse/.*\\.txt', '^lib/spack/docs/(?!command_index|spack|llnl).*\\.rst$', '^lib/spack/docs/.*\\.py$', '^lib/spack/docs/spack.yaml$', '^lib/spack/external/__init__.py$', '^share/spack/.*\\.sh$', '^share/spack/.*\\.bash$', '^share/spack/.*\\.csh$', '^share/spack/.*\\.fish$', '^share/spack/setup-env\\.ps1$', '^share/spack/qa/run-[^/]*$', '^share/spack/qa/*.py$', '^share/spack/bash/spack-completion.in$', '^.github/actions/.*\\.py$', '^var/spack/repos/.*/package.py$']
regular expressions for licensed files.
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.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.load module
spack.cmd.location module
spack.cmd.log_parse module
spack.cmd.logs module
spack.cmd.maintainers module
spack.cmd.make_installer module
spack.cmd.mark module
spack.cmd.mirror module
- spack.cmd.mirror.concrete_specs_from_user(args)[source]
Return the list of concrete specs that the user wants to mirror. The list is passed either from command line or from a text file.
- spack.cmd.mirror.create_mirror_for_individual_specs(mirror_specs, path, skip_unstable_versions)[source]
- spack.cmd.mirror.extend_with_dependencies(specs)[source]
Extend the input list by adding all the dependencies explicitly.
- 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.module module
spack.cmd.patch module
spack.cmd.pkg module
spack.cmd.providers module
spack.cmd.pydoc module
spack.cmd.python module
- spack.cmd.python.ipython_interpreter(args)[source]
An ipython interpreter is intended to be interactive, so it doesn’t support running a script or arguments
- spack.cmd.python.propagate_exceptions_from(console)[source]
Set sys.excepthook to let uncaught exceptions return 1 to the shell.
- Parameters:
console (code.InteractiveConsole) – the console that needs a change in sys.excepthook
spack.cmd.reindex module
spack.cmd.remove module
spack.cmd.repo module
spack.cmd.resource module
spack.cmd.restage module
spack.cmd.solve module
- spack.cmd.solve.show_options = ('asp', 'opt', 'output', 'solutions')
output options
spack.cmd.spec module
spack.cmd.stage module
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.
- spack.cmd.style.cwd_relative(path, root, initial_working_dir)[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.mypy_ignores = ['[annotation-unchecked]']
warnings to ignore in mypy
- 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
- class spack.cmd.style.tool(name: str, required: bool = False, external: bool = True)[source]
Bases:
object
- property executable: Executable | None
- spack.cmd.style.tool_names = ['import', 'isort', 'black', 'flake8', 'mypy']
Order in which tools should be run. flake8 is last so that it can double-check the results of other tools (if, e.g., –fix was provided) The list maps an executable name to a method to ensure the tool is bootstrapped or present in the environment.
spack.cmd.test module
- 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_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_env module
spack.cmd.tutorial module
spack.cmd.undevelop module
spack.cmd.uninstall module
- spack.cmd.uninstall.all_specs_in_env(env: Environment, specs: List[Spec]) List[Spec] [source]
Given a list of specs, return those that are in the env
- spack.cmd.uninstall.dependent_environments(specs: List[Spec], current_env: Environment | None = None) Dict[Environment, List[Spec]] [source]
- spack.cmd.uninstall.find_matching_specs(env: Environment | None, specs: List[Spec], allow_multiple_matches: bool = False, origin=None) List[Spec] [source]
- Returns a list of specs matching the not necessarily
concretized specs given from cli
- Parameters:
env – optional active environment
specs – list of specs to be matched against installed packages
allow_multiple_matches – if True multiple matches are admitted
origin – origin of the spec
- Returns:
list of specs
- Return type:
- spack.cmd.uninstall.get_uninstall_list(args, specs: List[Spec], env: Environment | None)[source]
Returns unordered uninstall_list and remove_list: these may overlap (some things may be both uninstalled and removed from the current environment).
It is assumed we are in an environment if –remove is specified (this method raises an exception otherwise).
spack.cmd.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.unload module
spack.cmd.url module
- spack.cmd.url.name_parsed_correctly(pkg, name)[source]
Determine if the name of a package was correctly parsed.
- Parameters:
pkg (spack.package_base.PackageBase) – The Spack package
name (str) – The name that was extracted from the URL
- Returns:
True if the name was correctly parsed, else False
- Return type:
- 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.
- 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:
- spack.cmd.url.url_list_parsing(args, urls, url, pkg)[source]
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 onargs
pkg (spack.package_base.PackageBase) – The Spack package
- Returns:
The updated set of
urls
- Return type:
- spack.cmd.url.version_parsed_correctly(pkg, version)[source]
Determine if the version of a package was correctly parsed.
- Parameters:
pkg (spack.package_base.PackageBase) – The Spack package
version (str) – The version that was extracted from the URL
- Returns:
True if the name was correctly parsed, else False
- Return type:
spack.cmd.verify module
spack.cmd.versions module
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.