spack.bootstrap package

Function and classes needed to bootstrap Spack itself.

class spack.bootstrap.BootstrapEnvironment[source]

Bases: Environment

Environment to install dependencies of Spack for a given interpreter and architecture

classmethod bin_dir() Path[source]

Paths to be added to PATH

classmethod bootstrap_gpg_home() Path[source]

Location of the GPG home directory used for bootstrapping

classmethod environment_root() Path[source]

Environment root directory

load() None[source]

Update PATH and sys.path.

python_dirs() Iterable[Path][source]
classmethod spack_dev_requirements() List[str][source]

Spack development requirements

classmethod spack_yaml() Path[source]

Environment spack.yaml file

update_installations() None[source]

Update the installations of this environment.

classmethod view_root() Path[source]

Location of the view

spack.bootstrap.all_core_root_specs() List[str][source]

Return a list of all the core root specs that may be used to bootstrap Spack

spack.bootstrap.ensure_bootstrap_configuration() Generator[source]

Swap the current configuration for the one used to bootstrap Spack.

The context manager is reference counted to ensure we don’t swap multiple times if there’s nested use of it in the stack. One compelling use case is bootstrapping patchelf during the bootstrap of clingo.

spack.bootstrap.ensure_clingo_importable_or_raise() None[source]

Ensure that the clingo module is available for import.

spack.bootstrap.ensure_core_dependencies() None[source]

Ensure the presence of all the core dependencies.

spack.bootstrap.ensure_environment_dependencies() None[source]

Ensure Spack dependencies from the bootstrap environment are installed and ready to use

spack.bootstrap.ensure_gpg_in_path_or_raise() Executable[source]

Ensure gpg or gpg2 are in the PATH or raise.

spack.bootstrap.ensure_patchelf_in_path_or_raise() Executable[source]

Ensure patchelf is in the PATH or raise.

spack.bootstrap.ensure_winsdk_external_or_raise() None[source]

Ensure the Windows SDK + WGL are available on system If both of these package are found, the Spack user or bootstrap configuration (depending on where Spack is running) will be updated to include all versions and variants detected. If either the WDK or WSDK are not found, this method will raise a RuntimeError.

NOTE: This modifies the Spack config in the current scope, either user or environment depending on the calling context. This is different from all other current bootstrap dependency checks.

spack.bootstrap.is_bootstrapping() bool[source]

Return True if we are in a bootstrapping context, False otherwise.

spack.bootstrap.status_message(section) Tuple[str, bool][source]

Return a status message to be printed to screen that refers to the section passed as argument and a bool which is True if there are missing dependencies.

Parameters:

section (str) – either ‘core’ or ‘buildcache’ or ‘optional’ or ‘develop’

spack.bootstrap.store_path() str[source]

Path to the store used for bootstrapped software

Submodules

spack.bootstrap.clingo module

Bootstrap concrete specs for clingo

Spack uses clingo to concretize specs. When clingo itself needs to be bootstrapped from sources, we need to rely on another mechanism to get a concrete spec that fits the current host.

This module contains the logic to get a concrete spec for clingo, starting from a prototype JSON file for a similar platform.

class spack.bootstrap.clingo.ClingoBootstrapConcretizer(configuration)[source]

Bases: object

concretize() Spec[source]
libc_external_spec() Spec[source]
prototype_path() Path[source]

Path to a prototype concrete specfile for clingo

python_external_spec() Spec[source]

Python external spec corresponding to the current running interpreter

spack.bootstrap.config module

Manage configuration swapping for bootstrapping purposes

spack.bootstrap.config.ensure_bootstrap_configuration() Generator[source]

Swap the current configuration for the one used to bootstrap Spack.

The context manager is reference counted to ensure we don’t swap multiple times if there’s nested use of it in the stack. One compelling use case is bootstrapping patchelf during the bootstrap of clingo.

spack.bootstrap.config.is_bootstrapping() bool[source]

Return True if we are in a bootstrapping context, False otherwise.

spack.bootstrap.config.root_path() str[source]

Root of all the bootstrap related folders

spack.bootstrap.config.spec_for_current_python() str[source]

For bootstrapping purposes we are just interested in the Python minor version (all patches are ABI compatible with the same minor).

See:

spack.bootstrap.config.store_path() str[source]

Path to the store used for bootstrapped software

spack.bootstrap.core module

Bootstrap Spack core dependencies from binaries.

This module contains logic to bootstrap software required by Spack from binaries served in the bootstrapping mirrors. The logic is quite different from an installation done from a Spack user, because of the following reasons:

  1. The binaries are all compiled on the same OS for a given platform (e.g. they are compiled on centos7 on linux), but they will be installed and used on the host OS. They are also targeted at the most generic architecture possible. That makes the binaries difficult to reuse with other specs in an environment without ad-hoc logic.

  2. Bootstrapping has a fallback procedure where we try to install software by default from the most recent binaries, and proceed to older versions of the mirror, until we try building from sources as a last resort. This allows us not to be blocked on architectures where we don’t have binaries readily available, but is also not compatible with the working of environments (they don’t have fallback procedures).

  3. Among the binaries we have clingo, so we can’t concretize that with clingo :-)

  4. clingo, GnuPG and patchelf binaries need to be verified by sha256 sum (all the other binaries we might add on top of that in principle can be verified with GPG signatures).

class spack.bootstrap.core.BootstrapRequest(abstract_spec: Spec, metadata_name: str, probe: Callable[[Spec], ResultT | None], installer_args: Dict[str, Any], concretize: Callable[[Spec], Spec])[source]

Bases: Generic[ResultT]

Software to be made available in the bootstrap store, and how to check for it.

The two kinds of request, a Python module and a set of executables, differ only in the spec to be installed, in the probe that tests whether the software can be used, in the arguments to be passed to the installer when building from sources, and in how the spec is concretized.

abstract_spec

Spec to be installed to satisfy this request

concretize

Turns the abstract spec into the concrete one to be built from sources

classmethod for_executables(executables: Sequence[str], abstract_spec_str: str) BootstrapRequest[ExecutableInfo][source]

Return a request for executables to be found in the PATH.

classmethod for_module(module: str, abstract_spec_str: str, concretize: Callable[[Spec], Spec] | None = None) BootstrapRequest[bool][source]

Return a request for a module importable in the interpreter running Spack.

Parameters:
  • module – module to be imported in the interpreter running Spack

  • abstract_spec_str – abstract spec that provides the module

  • concretize – how to concretize the spec, when building from sources. Defaults to the regular concretizer.

installer_args

Extra arguments for the installer, when building from sources

metadata_name

Name of the buildcache metadata file for this software

probe

Returns the software from the store, or None if it is not usable from there

class spack.bootstrap.core.Bootstrapper(conf: Dict[str, Any])[source]

Bases: object

Interface for “core” software bootstrappers

mirror_scope

Mirror scope to be pushed onto the bootstrapping configuration when using this bootstrapper

try_to_bootstrap(request: BootstrapRequest[ResultT]) ResultT | None[source]

Try to make the requested software available, from this source.

Parameters:

request – software to be bootstrapped, and the probe that tests for it

Returns:

What the probe of the request returned, or None if bootstrapping failed

class spack.bootstrap.core.BuildcacheBootstrapper(conf: Dict[str, Any])[source]

Bases: Bootstrapper

Install the software needed during bootstrapping from a buildcache.

try_to_bootstrap(request: BootstrapRequest[ResultT]) ResultT | None[source]

Try to make the requested software available, from this source.

Parameters:

request – software to be bootstrapped, and the probe that tests for it

Returns:

What the probe of the request returned, or None if bootstrapping failed

spack.bootstrap.core.IS_WINDOWS

Whether the current platform is Windows

spack.bootstrap.core.METADATA_YAML_FILENAME

Name of the file containing metadata about the bootstrapping source

class spack.bootstrap.core.ResultT

Whatever a bootstrapper’s store probe returns on success

alias of TypeVar(‘ResultT’)

class spack.bootstrap.core.SourceBootstrapper(conf: Dict[str, Any])[source]

Bases: Bootstrapper

Install the software needed during bootstrapping from sources.

try_to_bootstrap(request: BootstrapRequest[ResultT]) ResultT | None[source]

Try to make the requested software available, from this source.

Parameters:

request – software to be bootstrapped, and the probe that tests for it

Returns:

What the probe of the request returned, or None if bootstrapping failed

spack.bootstrap.core.all_core_root_specs() List[str][source]

Return a list of all the core root specs that may be used to bootstrap Spack

spack.bootstrap.core.bootstrapping_sources(scope: str | None = None)[source]

Return the list of configured sources of software for bootstrapping Spack

Parameters:

scope – if a valid configuration scope is given, return the list only from that scope

spack.bootstrap.core.clingo_root_spec(platform: str | None = None, target: str | None = None) str[source]

Return the root spec used to bootstrap clingo.

Parameters:
  • platform – platform the binary will run on. Defaults to the host platform.

  • target – target family the binary will run on. Defaults to the host target family.

spack.bootstrap.core.create_bootstrapper(conf: Dict[str, Any]) Bootstrapper[source]

Return a bootstrap object built according to the configuration argument

spack.bootstrap.core.enabled_bootstrapping_sources() List[Dict[str, Any]][source]

Return the configured bootstrapping sources that are enabled, in order.

spack.bootstrap.core.ensure_clingo_importable_or_raise() None[source]

Ensure that the clingo module is available for import.

spack.bootstrap.core.ensure_core_dependencies() None[source]

Ensure the presence of all the core dependencies.

spack.bootstrap.core.ensure_executables_in_path_or_raise(executables: Sequence[str], abstract_spec: str, cmd_check: Callable[[Executable], bool] | None = None) Executable[source]

Ensure that some executables are in path or raise.

Parameters:
  • executables – executables to be searched in the PATH, in order. The function exits on the first one found.

  • abstract_spec – abstract spec that provides the executables

  • cmd_check – callable predicate that takes a spack.util.executable.Executable command and validates it. Should return True if the executable is acceptable, False otherwise. Can be used to, e.g., ensure a suitable version of the command before accepting for bootstrapping.

Raises:

RuntimeError – if the executables cannot be ensured to be in PATH

Returns:

Executable object

spack.bootstrap.core.ensure_gpg_in_path_or_raise() Executable[source]

Ensure gpg or gpg2 are in the PATH or raise.

spack.bootstrap.core.ensure_module_importable_or_raise(module: str, abstract_spec: str | None = None, concretize: Callable[[Spec], Spec] | None = None)[source]

Make the requested module available for import, or raise.

This function tries to import a Python module in the current interpreter using, in order, the methods configured in bootstrap.yaml.

If none of the methods succeed, an exception is raised. The function exits on first success.

Parameters:
  • module – module to be imported in the current interpreter

  • abstract_spec – abstract spec that might provide the module. If not given it defaults to “module”

  • concretize – how to concretize the spec, when building from sources. Defaults to the regular concretizer.

Raises:

ImportError – if the module couldn’t be imported

spack.bootstrap.core.ensure_patchelf_in_path_or_raise() Executable[source]

Ensure patchelf is in the PATH or raise.

spack.bootstrap.core.ensure_winsdk_external_or_raise() None[source]

Ensure the Windows SDK + WGL are available on system If both of these package are found, the Spack user or bootstrap configuration (depending on where Spack is running) will be updated to include all versions and variants detected. If either the WDK or WSDK are not found, this method will raise a RuntimeError.

NOTE: This modifies the Spack config in the current scope, either user or environment depending on the calling context. This is different from all other current bootstrap dependency checks.

spack.bootstrap.core.gnupg_root_spec() str[source]

Return the root spec used to bootstrap GnuPG

spack.bootstrap.core.patchelf_root_spec() str[source]

Return the root spec used to bootstrap patchelf

spack.bootstrap.core.source_is_enabled(conf: Dict[str, Any]) bool[source]

Returns True if the source is enabled for bootstrapping, False otherwise

spack.bootstrap.core.verify_patchelf(patchelf: Executable) bool[source]

Older patchelf versions can produce broken binaries, so we verify the version here.

Parameters:

patchelf – patchelf executable

spack.bootstrap.environment module

Bootstrap non-core Spack dependencies from an environment.

class spack.bootstrap.environment.BootstrapEnvironment[source]

Bases: Environment

Environment to install dependencies of Spack for a given interpreter and architecture

classmethod bin_dir() Path[source]

Paths to be added to PATH

classmethod bootstrap_gpg_home() Path[source]

Location of the GPG home directory used for bootstrapping

classmethod environment_root() Path[source]

Environment root directory

load() None[source]

Update PATH and sys.path.

python_dirs() Iterable[Path][source]
classmethod spack_dev_requirements() List[str][source]

Spack development requirements

classmethod spack_yaml() Path[source]

Environment spack.yaml file

update_installations() None[source]

Update the installations of this environment.

classmethod view_root() Path[source]

Location of the view

spack.bootstrap.environment.dev_bootstrap_mirror_names() List[str][source]

Return the mirror names used for bootstrapping dev requirements

spack.bootstrap.environment.download_and_trust_key()[source]

Fetches and verifies the validity of Spack’s public key

spack.bootstrap.environment.ensure_environment_dependencies() None[source]

Ensure Spack dependencies from the bootstrap environment are installed and ready to use

spack.bootstrap.environment.mypy_root_spec() str[source]

Return the root spec used to bootstrap mypy

spack.bootstrap.environment.pytest_root_spec() str[source]

Return the root spec used to bootstrap pytest

spack.bootstrap.environment.ruff_root_spec() str[source]

Return the root spec used to bootstrap ruff

spack.bootstrap.status module

Query the status of bootstrapping on this machine

spack.bootstrap.status.status_message(section) Tuple[str, bool][source]

Return a status message to be printed to screen that refers to the section passed as argument and a bool which is True if there are missing dependencies.

Parameters:

section (str) – either ‘core’ or ‘buildcache’ or ‘optional’ or ‘develop’