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
- 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() None [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.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’
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.
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.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.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:
The binaries are all compiled on the same OS for a given platform (e.g. they are compiled on
centos7
onlinux
), 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.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).
Among the binaries we have clingo, so we can’t concretize that with clingo :-)
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.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 returnTrue
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.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.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 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
- 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.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’