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_dirs() List[Path][source]

Paths to be added to PATH

classmethod environment_root() Path[source]

Environment root directory

classmethod pythonpaths() List[str][source]

Paths to be added to sys.path or PYTHONPATH

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.

update_syspath_and_environ() None[source]

Update sys.path and the PATH, PYTHONPATH environment variables to point to the environment view.

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_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_patchelf_in_path_or_raise() Executable[source]

Ensure patchelf is in the PATH or raise.

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.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.spack_python_interpreter() Generator[source]

Override the current configuration to set the interpreter under which Spack is currently running as the only Python external spec available.

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:

https://www.python.org/dev/peps/pep-0513/ https://stackoverflow.com/a/35801395/771663

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.Bootstrapper(conf: Dict[str, Any])[source]

Bases: object

Interface for “core” software bootstrappers

config_scope_name = ''
property mirror_scope: InternalConfigScope

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

try_import(module: str, abstract_spec_str: str) bool[source]

Try to import a Python module from a spec satisfying the abstract spec passed as argument.

Parameters:
  • module – Python module name to try importing

  • abstract_spec_str – abstract spec that can provide the Python module

Returns:

True if the Python module could be imported, False otherwise

try_search_path(executables: Tuple[str], abstract_spec_str: str) bool[source]

Try to search some executables in the prefix of specs satisfying the abstract spec passed as argument.

Parameters:
  • executables – executables to be found

  • abstract_spec_str – abstract spec that can provide the Python module

Returns:

True if the executables are found, False otherwise

class spack.bootstrap.core.BuildcacheBootstrapper(conf)[source]

Bases: Bootstrapper

Install the software needed during bootstrapping from a buildcache.

try_import(module: str, abstract_spec_str: str) bool[source]

Try to import a Python module from a spec satisfying the abstract spec passed as argument.

Parameters:
  • module – Python module name to try importing

  • abstract_spec_str – abstract spec that can provide the Python module

Returns:

True if the Python module could be imported, False otherwise

try_search_path(executables: Tuple[str], abstract_spec_str: str) bool[source]

Try to search some executables in the prefix of specs satisfying the abstract spec passed as argument.

Parameters:
  • executables – executables to be found

  • abstract_spec_str – abstract spec that can provide the Python module

Returns:

True if the executables are found, False otherwise

spack.bootstrap.core.IS_WINDOWS = False

Whether the current platform is Windows

spack.bootstrap.core.METADATA_YAML_FILENAME = 'metadata.yaml'

Name of the file containing metadata about the bootstrapping source

class spack.bootstrap.core.SourceBootstrapper(conf)[source]

Bases: Bootstrapper

Install the software needed during bootstrapping from sources.

try_import(module: str, abstract_spec_str: str) bool[source]

Try to import a Python module from a spec satisfying the abstract spec passed as argument.

Parameters:
  • module – Python module name to try importing

  • abstract_spec_str – abstract spec that can provide the Python module

Returns:

True if the Python module could be imported, False otherwise

try_search_path(executables: Tuple[str], abstract_spec_str: str) bool[source]

Try to search some executables in the prefix of specs satisfying the abstract spec passed as argument.

Parameters:
  • executables – executables to be found

  • abstract_spec_str – abstract spec that can provide the Python module

Returns:

True if the executables are found, False otherwise

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.bootstrapper(bootstrapper_type: str)[source]

Decorator to register classes implementing bootstrapping methods.

Parameters:

bootstrapper_type – string identifying the class

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

Return the root spec used to bootstrap clingo

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

Return a bootstrap object built according to the configuration argument

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: list, abstract_spec: str, cmd_check: Callable[[Executable], bool] | None = None)[source]

Ensure that some executables are in path or raise.

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

  • abstract_spec (str) – abstract spec that provides the executables

  • cmd_check (object) – callable predicate that takes a spack.util.executable.Executable command and validate 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() None[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)[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”

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.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_or_raise(conf: Dict[str, Any])[source]

Raise ValueError if the source is not enabled for bootstrapping

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_dirs() List[Path][source]

Paths to be added to PATH

classmethod environment_root() Path[source]

Environment root directory

classmethod pythonpaths() List[str][source]

Paths to be added to sys.path or PYTHONPATH

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.

update_syspath_and_environ() None[source]

Update sys.path and the PATH, PYTHONPATH environment variables to point to the environment view.

classmethod view_root() Path[source]

Location of the view

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

Return the root spec used to bootstrap black

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

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

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

Return the root spec used to bootstrap flake8

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

Return the root spec used to bootstrap isort

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 flake8

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’