spack.modules package¶
This package contains code for creating environment modules, which can include Tcl non-hierarchical modules, Lua hierarchical modules, and others.
- class spack.modules.LmodModulefileWriter(spec: Spec, module_set_name: str, explicit: bool | None = None)[source]¶
Bases:
BaseModuleFileWriterWriter class for lmod module files.
- class spack.modules.TclModulefileWriter(spec: Spec, module_set_name: str, explicit: bool | None = None)[source]¶
Bases:
BaseModuleFileWriterWriter class for tcl module files.
- spack.modules.disable_modules()[source]¶
Disable the generation of modulefiles within the context manager.
Submodules¶
spack.modules.common module¶
Here we consolidate the logic for creating an abstract description of the information that module systems need.
This information maps a single spec to:
a unique module filename
the module file content
and is divided among four classes:
a configuration class that provides a convenient interface to query details about the configuration for the spec under consideration.
a layout class that provides the information associated with module file names and directories
a context class that provides the dictionary used by the template engine to generate the module file
a writer that collects and uses the information above to either write or remove the module file
Each of the four classes needs to be sub-classed when implementing a new module type.
- class spack.modules.common.BaseConfiguration(spec: Spec, module_set_name: str, explicit: bool)[source]¶
Bases:
objectManipulates the information needed to generate a module file to make querying easier. It needs to be sub-classed for specific module types.
- property conflicts¶
Conflicts for this module file
- property context¶
- default_projections¶
- property defaults¶
Returns the specs configured as defaults or [].
- property env¶
List of environment modifications that should be done in the module.
- property exclude_env_vars¶
List of variables that should be left unmodified.
- property excluded¶
Returns True if the module has been excluded, False otherwise.
- property hash¶
Hash tag for the module or None
Returns True if the module has been hidden, False otherwise.
- property literals_to_load¶
List of literal modules to be loaded.
- property module¶
- property projections¶
Projection from specs to module names
- property specs_to_load¶
List of specs that should be loaded in the module file.
- property specs_to_prereq¶
List of specs that should be prerequisite of the module file.
- property suffixes¶
List of suffixes that should be appended to the module file name.
- property template¶
Returns the name of the template to use for the module file or None if not specified in the configuration.
- property verbose¶
Returns True if the module file needs to be verbose, False otherwise
- class spack.modules.common.BaseContext(configuration)[source]¶
Bases:
ContextProvides the base context needed for template rendering.
This class needs to be sub-classed for specific module types. The following attributes need to be implemented:
fields
- property autoload¶
List of modules that needs to be loaded automatically.
- property category¶
- property configure_options¶
- property conflicts¶
List of conflicts for the module file.
- property environment_modifications¶
List of environment modifications to be processed.
- property has_manpath_modifications¶
True if MANPATH environment variable is modified.
- property long_description¶
- modification_needs_formatting(modification)[source]¶
Returns True if environment modification entry needs to be formatted.
- property short_description¶
- property spec¶
- property tags¶
- property timestamp¶
- property verbose¶
Verbosity level.
- class spack.modules.common.BaseFileLayout(configuration)[source]¶
Bases:
objectProvides information on the layout of module files. Needs to be sub-classed for specific module types.
- property filename¶
Name of the module file for the current spec.
- property spec¶
Spec under consideration
- property use_name¶
Returns the ‘use’ name of the module i.e. the name you have to type to console to use it. This implementation fits the needs of most non-hierarchical layouts.
- class spack.modules.common.BaseModuleFileWriter(spec: Spec, module_set_name: str, explicit: bool | None = None)[source]¶
Bases:
object- property module¶
Update modulerc file corresponding to module to add or remove command that hides module depending on its hidden state.
- Parameters:
remove (bool) – if True, hiddenness information for module is removed from modulerc.
- exception spack.modules.common.DefaultTemplateNotDefined[source]¶
Bases:
AttributeError,ModulesErrorRaised if the attribute
default_templatehas not been specified in the derived classes.
- exception spack.modules.common.HideCmdFormatNotDefined[source]¶
Bases:
AttributeError,ModulesErrorRaised if the attribute
hide_cmd_formathas not been specified in the derived classes.
- class spack.modules.common.ModuleIndexEntry(path, use_name)¶
Bases:
tuple- path¶
Alias for field number 0
- use_name¶
Alias for field number 1
- exception spack.modules.common.ModuleNotFoundError(message: str, long_message: str | None = None)[source]¶
Bases:
ModulesErrorRaised when a module cannot be found for a spec
- exception spack.modules.common.ModulercHeaderNotDefined[source]¶
Bases:
AttributeError,ModulesErrorRaised if the attribute
modulerc_headerhas not been specified in the derived classes.
- exception spack.modules.common.ModulesError(message: str, long_message: str | None = None)[source]¶
Bases:
SpackErrorBase error for modules.
- exception spack.modules.common.ModulesTemplateNotFoundError(message: str, long_message: str | None = None)[source]¶
Bases:
ModulesError,RuntimeErrorRaised if the template for a module file was not found.
- class spack.modules.common.UpstreamModuleIndex(local_db, module_indices)[source]¶
Bases:
objectThis is responsible for taking the individual module indices of all upstream Spack installations and locating the module for a given spec based on which upstream install it is located in.
- spack.modules.common.dependencies(spec: Spec, request: str = 'all') List[Spec][source]¶
Returns the list of dependent specs for a given spec.
- Parameters:
spec – spec to be analyzed
request – one of
"none","run","direct","all"
- Returns:
list of requested dependencies
- spack.modules.common.disable_modules()[source]¶
Disable the generation of modulefiles within the context manager.
- spack.modules.common.merge_config_rules(configuration, spec)[source]¶
Parses the module specific part of a configuration and returns a dictionary containing the actions to be performed on the spec passed as an argument.
- Parameters:
configuration – module specific configuration (e.g. entries under the top-level ‘tcl’ key)
spec – spec for which we need to generate a module file
- Returns:
actions to be taken on the spec passed as an argument
- Return type:
spack.modules.lmod module¶
- exception spack.modules.lmod.CoreCompilersNotFoundError(message: str, long_message: str | None = None)[source]¶
Bases:
SpackError,KeyErrorError raised if the key
core_compilershas not been specified in the configuration file.
- class spack.modules.lmod.LmodConfiguration(spec: Spec, module_set_name: str, explicit: bool)[source]¶
Bases:
BaseConfigurationConfiguration class for lmod module files.
- property available¶
Returns a dictionary of the services that are currently available.
- property core_compilers: List[Spec]¶
Returns the list of “Core” compilers
- Raises:
CoreCompilersNotFoundError – if the key was not specified in the configuration file or the sequence is empty
- property core_specs¶
Returns the list of “Core” specs
- default_projections¶
- property filter_hierarchy_specs¶
Returns the dict of specs with modified hierarchies
Returns True if the module has been hidden, False otherwise.
- property hierarchy_tokens¶
Returns the list of tokens that are part of the modulefile hierarchy.
compileris always present.
- property missing¶
Returns the list of tokens that are not available.
- property provides¶
Returns a dictionary mapping all the services provided by this spec to the spec itself.
- property requires¶
Returns a dictionary mapping all the requirements of this spec to the actual provider.
The
compilerkey is always present among the requirements.
- class spack.modules.lmod.LmodContext(configuration)[source]¶
Bases:
BaseContextContext class for lmod module files.
- property conditionally_unlocked_paths¶
Returns the list of paths that are unlocked conditionally. Each item in the list is a tuple with the structure (condition, path).
- property has_conditional_modifications¶
True if this module modifies MODULEPATH conditionally to the presence of other services in the environment, False otherwise.
- property has_modulepath_modifications¶
True if this module modifies MODULEPATH, False otherwise.
- property missing¶
Returns a list of missing services.
- property name_part¶
Name of this provider.
- property provides¶
Returns the dictionary of provided services.
- property unlocked_paths¶
Returns the list of paths that are unlocked unconditionally.
- property version_part¶
Version of this provider.
- class spack.modules.lmod.LmodFileLayout(configuration)[source]¶
Bases:
BaseFileLayoutFile layout for lmod module files.
- property arch_dirname¶
Returns the root folder for THIS architecture
- property available_path_parts¶
List of path parts that are currently available. Needed to construct the file name.
- property filename¶
Returns the filename for the current module file
- property modulerc¶
Returns the modulerc file associated with current module file
- property unlocked_paths¶
Returns a dictionary mapping conditions to a list of unlocked paths.
The paths that are unconditionally unlocked are under the key ‘None’. The other keys represent the list of services you need loaded to unlock the corresponding paths.
- class spack.modules.lmod.LmodModulefileWriter(spec: Spec, module_set_name: str, explicit: bool | None = None)[source]¶
Bases:
BaseModuleFileWriterWriter class for lmod module files.
- spack.modules.lmod.guess_core_compilers(name, store=False) List[Spec][source]¶
Guesses the list of core compilers installed in the system.
- Parameters:
store (bool) – if True writes the core compilers to the modules.yaml configuration file
- Returns:
List of found core compilers
- spack.modules.lmod.make_configuration(spec: Spec, module_set_name: str, explicit: bool | None = None) BaseConfiguration[source]¶
Returns the lmod configuration for spec
spack.modules.tcl module¶
This module implements the classes necessary to generate Tcl non-hierarchical modules.
- class spack.modules.tcl.TclConfiguration(spec: Spec, module_set_name: str, explicit: bool)[source]¶
Bases:
BaseConfigurationConfiguration class for tcl module files.
- class spack.modules.tcl.TclContext(configuration)[source]¶
Bases:
BaseContextContext class for tcl module files.
- property prerequisites¶
List of modules that needs to be loaded automatically.
- class spack.modules.tcl.TclFileLayout(configuration)[source]¶
Bases:
BaseFileLayoutFile layout for tcl module files.
- property modulerc¶
Returns the modulerc file associated with current module file
- class spack.modules.tcl.TclModulefileWriter(spec: Spec, module_set_name: str, explicit: bool | None = None)[source]¶
Bases:
BaseModuleFileWriterWriter class for tcl module files.
- spack.modules.tcl.make_configuration(spec: Spec, module_set_name: str, explicit: bool | None = None) BaseConfiguration[source]¶
Returns the tcl configuration for spec