spack.solver package¶
Submodules¶
spack.solver.asp module¶
- class spack.solver.asp.ConcreteSpecsByHash[source]¶
Bases:
MappingMapping containing concrete specs keyed by DAG hash.
The mapping is ensured to be consistent, i.e. if a spec in the mapping has a dependency with hash X, it is ensured to be the same object in memory as the spec keyed by X.
- add(spec: Spec) bool[source]¶
Adds a new concrete spec to the mapping. Returns True if the spec was just added, False if the spec was already in the mapping.
Calling this function marks the spec as added explicitly.
- Parameters:
spec – spec to be added
- Raises:
ValueError – if the spec is not concrete
- class spack.solver.asp.ConcretizationCache(root: str | None = None)[source]¶
Bases:
objectStore for Spack concretization results and statistics
Serializes solver result objects and statistics to json and stores at a given endpoint in a cache associated by the sha256 of the asp problem and the involved control files.
- cleanup()[source]¶
Prunes the concretization cache according to configured entry count limits. Cleanup is done in LRU ordering.
- fetch(problem: str) Tuple[Result, Dict] | Tuple[None, None][source]¶
Returns the concretization cache result for a lookup based on the given problem.
Checks the concretization cache for the given problem, and either returns the Python objects cached on disk representing the concretization results and statistics or returns none if no cache entry was found.
- read_transaction(path: Path, timeout: float | None = None) ReadTransaction[source]¶
Read transactions for concretization cache entries.
- Parameters:
path – absolute or relative path to the concretization cache entry to be locked
timeout – give up after this many seconds
- store(problem: str, result: Result, statistics: List) None[source]¶
Creates entry in concretization cache for problem if none exists, storing the concretization Result object and statistics in the cache as serialized json joined as a single file.
Hash membership is computed based on the sha256 of the provided asp problem.
- class spack.solver.asp.ConditionContext[source]¶
Bases:
SourceContextTracks context in which a condition (i.e.
SpackSolverSetup.condition) is generated (e.g. for adepends_on).This may modify the required/imposed specs generated as relevant for the context.
- impose_context() ConditionIdContext[source]¶
- requirement_context() ConditionIdContext[source]¶
- transform_imposed: Callable[[str, Spec, List[AspFunction]], List[AspFunction]] | None¶
- transform_required: Callable[[str, Spec, List[AspFunction]], List[AspFunction]] | None¶
- class spack.solver.asp.ConditionIdContext[source]¶
Bases:
SourceContextDerived from a
ConditionContext: for clause-sets generated by imposed/required specs, stores an associated transform.This is primarily used for tracking whether we are generating clauses in the context of a required spec, or for an imposed spec.
Is not a subclass of
ConditionContextbecause it exists in a lower-level context with less information.- transform: Callable[[str, Spec, List[AspFunction]], List[AspFunction]] | None¶
- class spack.solver.asp.ConstraintOrigin(*values)[source]¶
Bases:
EnumGenerates identifiers that can be passed into the solver attached to constraints, and then later retrieved to determine the origin of those constraints when
SpecBuildercreates Specs from the solve result.- CONDITIONAL_SPEC¶
- DEPENDS_ON¶
- REQUIRE¶
- static append_type_suffix(pkg_id: str, kind: ConstraintOrigin) str[source]¶
Given a package identifier and a constraint kind, generate a string ID.
- spack.solver.asp.DEFAULT_OUTPUT_CONFIGURATION¶
Default output configuration for a solve
- exception spack.solver.asp.DeprecatedVersionError(message: str, long_message: str | None = None)[source]¶
Bases:
SpackErrorRaised when user directly requests a deprecated version.
- class spack.solver.asp.ErrorHandler(model, input_specs: List[Spec])[source]¶
Bases:
object
- exception spack.solver.asp.InternalConcretizerError(msg)[source]¶
Bases:
UnsatisfiableSpecErrorErrors that indicate a bug in Spack.
- exception spack.solver.asp.InvalidDependencyError(message: str, long_message: str | None = None)[source]¶
Bases:
SpackErrorRaised when an explicit dependency is not a possible dependency.
- exception spack.solver.asp.InvalidExternalError(message: str, long_message: str | None = None)[source]¶
Bases:
SpackErrorRaised when there is no possible compiler
- exception spack.solver.asp.InvalidSpliceError(message: str, long_message: str | None = None)[source]¶
Bases:
SpackErrorFor cases in which the splice configuration is invalid.
- exception spack.solver.asp.InvalidVersionError(message: str, long_message: str | None = None)[source]¶
Bases:
SpackErrorRaised when a version can’t be satisfied by any possible versions.
- exception spack.solver.asp.NoCompilerFoundError(message: str, long_message: str | None = None)[source]¶
Bases:
SpackErrorRaised when there is no possible compiler
- class spack.solver.asp.OptimizationCriteria(priority: int, value: int, name: str, kind: OptimizationKind)[source]¶
Bases:
NamedTupleA named tuple describing an optimization criteria.
- kind: OptimizationKind¶
Alias for field number 3
- class spack.solver.asp.OptimizationKind[source]¶
Bases:
objectEnum for the optimization KIND of a criteria.
It’s not using enum.Enum since it must be serializable.
- BUILD¶
- CONCRETE¶
- OTHER¶
- class spack.solver.asp.OutputConfiguration(timers: bool, stats: bool, out: IOBase | None, setup_only: bool)[source]¶
Bases:
NamedTupleData class that contains configuration on what a clingo solve should output.
- exception spack.solver.asp.OutputDoesNotSatisfyInputError(input_to_output: List[Tuple[Spec, Spec | None]])[source]¶
Bases:
InternalConcretizerError
- class spack.solver.asp.ProblemInstanceBuilder[source]¶
Bases:
objectProvides an interface to construct a problem instance.
Once all the facts and rules have been added, the problem instance can be retrieved with:
>>> builder = ProblemInstanceBuilder() >>> ... >>> problem_instance = builder.value()
The problem instance can be added directly to the “control” structure of clingo.
- fact(atom: AspFunction) None[source]¶
- class spack.solver.asp.PyclingoDriver(conc_cache: ConcretizationCache | None = None)[source]¶
Bases:
object- solve(setup: SpackSolverSetup, specs: List[Spec], reuse: List[Spec] | None = None, packages_with_externals=None, output: OutputConfiguration | None = None, control: Any | None = None, allow_deprecated: bool = False) Tuple[Result, Timer | None, Dict | None][source]¶
Set up the input and solve for dependencies of
specs.- Parameters:
setup – An object to set up the ASP problem.
specs – List of
Specobjects to solve for.reuse – list of concrete specs that can be reused
output – configuration object to set the output of this solve.
control – configuration for the solver. If None, default values will be used
allow_deprecated – if True, allow deprecated versions in the solve
- Returns:
A tuple of the solve result, the timer for the different phases of the solve, and the internal statistics from clingo.
- class spack.solver.asp.Result(specs)[source]¶
Bases:
objectResult of an ASP solve.
- static format_unsolved(unsolved_specs)[source]¶
Create a message providing info on unsolved user specs and for each one show the associated candidate spec from the solver (if there is one).
- property specs¶
List of concretized specs satisfying the initial abstract request.
- to_dict() dict[source]¶
Produces dict representation of Result object
Does not include anything related to unsatisfiability as we are only interested in storing satisfiable results
- property unsolved_specs¶
List of tuples pairing abstract input specs that were not solved with their associated candidate spec from the solver (if the solve completed).
- class spack.solver.asp.Solver(*, specs_factory: Callable[[Callable[[Spec], bool], Configuration], List[SpecFilter]] | None = None)[source]¶
Bases:
objectThis is the main external interface class for solving.
It manages solver configuration and preferences in one place. It sets up the solve and passes the setup method to the driver, as well.
- solve(specs: Sequence[Spec], **kwargs) Result[source]¶
Convenience function for concretizing a set of specs and ignoring timing and statistics. Uses the same kwargs as solve_with_stats.
- solve_in_rounds(specs: Sequence[Spec], out: IOBase | None = None, timers: bool = False, stats: bool = False, tests: bool | Iterable[str] = False, allow_deprecated: bool = False) Generator[Result, None, None][source]¶
Solve for a stable model of specs in multiple rounds.
This relaxes the assumption of solve that everything must be consistent and solvable in a single round. Each round tries to maximize the reuse of specs from previous rounds.
The function is a generator that yields the result of each round.
- Parameters:
specs (list) – list of Specs to solve.
out – Optionally write the generate ASP program to a file-like object.
timers (bool) – print timing if set to True
stats (bool) – print internal statistics if set to True
tests (bool) – add test dependencies to the solve
allow_deprecated (bool) – allow deprecated version in the solve
- solve_with_stats(specs: Sequence[Spec], out: IOBase | None = None, timers: bool = False, stats: bool = False, tests: bool | Iterable[str] = False, setup_only: bool = False, allow_deprecated: bool = False) Tuple[Result, Timer | None, Dict | None][source]¶
Concretize a set of specs and track the timing and statistics for the solve
- Parameters:
specs – List of
Specobjects to solve for.out – Optionally write the generate ASP program to a file-like object.
timers – Print out coarse timers for different solve phases.
stats – Print out detailed stats from clingo.
tests – If True, concretize test dependencies for all packages. If a tuple of package names, concretize test dependencies for named packages (defaults to False: do not concretize test dependencies).
setup_only – if True, stop after setup and don’t solve (default False).
allow_deprecated – allow deprecated version in the solve
- exception spack.solver.asp.SolverError(provided)[source]¶
Bases:
InternalConcretizerErrorFor cases where the solver is unable to produce a solution.
Such cases are unexpected because we allow for solutions with errors, so for example user specs that are over-constrained should still get a solution.
- class spack.solver.asp.SpackSolverSetup(tests: bool | Iterable[str] = False)[source]¶
Bases:
objectClass to set up and run a Spack concretization solve.
- collect_virtual_constraints()[source]¶
Define versions for constraints on virtuals.
Must be called before define_version_constraints().
- condition(required_spec: Spec, imposed_spec: Spec | None = None, *, required_name: str | None = None, imposed_name: str | None = None, msg: str | None = None, context: ConditionContext | None = None) int[source]¶
Generate facts for a dependency or virtual provider condition.
- Parameters:
required_spec – the constraints that triggers this condition
imposed_spec – the constraints that are imposed when this condition is triggered
required_name – name for
required_spec(required if required_spec is anonymous, ignored if not)imposed_name – name for
imposed_spec(required if imposed_spec is anonymous, ignored if not)msg – description of the condition
context – if provided, indicates how to modify the clause-sets for the required/imposed specs based on the type of constraint they are generated for (e.g.
depends_on)
- Returns:
id of the condition created by this function
- Return type:
- define_ad_hoc_versions_from_specs(specs, origin, *, allow_deprecated: bool, require_checksum: bool)[source]¶
Add concrete versions to possible versions from lists of CLI/dev specs.
- define_package_versions_and_validate_preferences(possible_pkgs: Set[str], *, require_checksum: bool, allow_deprecated: bool)[source]¶
Declare any versions in specs not declared in packages.
- define_runtime_constraints() List[Spec][source]¶
Define the constraints to be imposed on the runtimes, and returns a list of injected packages.
- define_variant_values()[source]¶
Validate variant values from the command line.
Add valid variant values from the command line to the possible values for variant definitions.
- deprecated_versions: Dict[str, Set[GitVersion | StandardVersion]]¶
- emit_facts_from_requirement_rules(rules: List[RequirementRule])[source]¶
Generate facts to enforce requirements.
- Parameters:
rules – rules for which we want facts to be emitted
- external_packages(packages_with_externals)[source]¶
Facts on external packages, from packages.yaml and implicit externals.
- generate_conditional_dep_conditions(spec: Spec, condition_id: int)[source]¶
Generate a subcondition in the trigger for any conditional dependencies.
Dependencies are always modeled by a condition. For conditional dependencies, the when-spec is added as a subcondition of the trigger to ensure the dependency is only activated when the subcondition holds.
- git_commit_versions: Dict[str, Dict[GitVersion | StandardVersion, str]]¶
- input_spec_version_check(specs, allow_deprecated: bool) None[source]¶
Raise an error early if no versions available in the solve can satisfy the inputs.
- package_provider_rules(pkg: Type[PackageBase]) None[source]¶
- pkg_class(pkg_name: str) Type[PackageBase][source]¶
- pkg_version_rules(pkg: Type[PackageBase]) None[source]¶
Declares known versions, their origins, and their weights.
- possible_versions: Dict[str, Dict[GitVersion | StandardVersion, List[Provenance]]]¶
- preferred_variants(pkg_name)[source]¶
Facts on concretization preferences, as read from packages.yaml
- reusable_and_possible: ConcreteSpecsByHash¶
- setup(specs: Sequence[Spec], *, reuse: List[Spec] | None = None, packages_with_externals=None, allow_deprecated: bool = False) ProblemInstanceBuilder[source]¶
Generate an ASP program with relevant constraints for specs.
This calls methods on the solve driver to set up the problem with facts and rules from all possible dependencies of the input specs, as well as constraints from the specs themselves.
- Parameters:
specs – list of Specs to solve
reuse – list of concrete specs that can be reused
packages_with_externals – precomputed packages config with implicit externals
allow_deprecated – if True adds deprecated versions into the solve
- Returns:
A ProblemInstanceBuilder populated with facts and rules for an ASP solve.
- spec_clauses(spec: Spec, *, name: str | None = None, body: bool = False, transitive: bool = True, expand_hashes: bool = False, concrete_build_deps=False, include_runtimes=False, required_from: str | None = None, context: SourceContext | None = None) List[AspFunction][source]¶
Wrap a call to
_spec_clauses()into a try/except block with better error handling.Arguments are as for
_spec_clauses()exceptrequired_from.- Parameters:
required_from – name of package that caused this call.
- spec_versions(spec: Spec, *, name: str | None = None) List[AspFunction][source]¶
Return list of clauses expressing spec’s version constraints.
- validate_and_define_versions_from_requirements(*, allow_deprecated: bool, require_checksum: bool)[source]¶
If package requirements mention concrete versions that are not mentioned elsewhere, then we need to collect those to mark them as possible versions. If they are abstract and statically have no match, then we need to throw an error. This function assumes all possible versions are already registered in self.possible_versions.
- variant_rules(pkg: Type[PackageBase])[source]¶
- versions_from_yaml: Dict[str, List[GitVersion | StandardVersion]]¶
- class spack.solver.asp.SpecBuilder(specs, hash_lookup=None)[source]¶
Bases:
objectClass with actions to rebuild a spec from ASP results.
- ignored_attributes¶
Regex for attributes that don’t need actions b/c they aren’t used to construct specs.
- static make_node(*, pkg: str) NodeId[source]¶
Given a package name, returns the string representation of the “min_dupe_id” node in the ASP encoding.
- Parameters:
pkg – name of a package
- reorder_flags()[source]¶
For each spec, determine the order of compiler flags applied to it.
The solver determines which flags are on nodes; this routine imposes order afterwards. The order is:
Flags applied in compiler definitions should come first
Flags applied by dependents are ordered topologically (with a dependency on
traverseto resolve the partial order into a stable total order)Flags from requirements are then applied (requirements always come from the package and never a parent)
Command-line flags should come last
Additionally, for each source (requirements, compiler, command line, and dependents), flags from that source should retain their order and grouping: e.g. for
y cflags="-z -a"-zand-ashould never have any intervening flags inserted, and should always appear in that order.
- exception spack.solver.asp.UnsatisfiableSpecError(msg)[source]¶
Bases:
UnsatisfiableSpecErrorThere was an issue with the spec that was requested (i.e. a user error).
- spack.solver.asp.build_criteria_names(costs, arg_tuples)[source]¶
Construct an ordered mapping from criteria names to costs.
- spack.solver.asp.build_priority_offset¶
Priority offset for “build” criteria (regular criterio shifted to higher priority for specs we have to build)
- spack.solver.asp.dag_closure_by_deptype(name: str, spec: Spec, facts: List[AspFunction]) List[AspFunction][source]¶
- spack.solver.asp.default_clingo_control()[source]¶
Return a control object with the default settings used in Spack
- spack.solver.asp.dependency_holds(*, dependency_flags: int, pkg_cls: Type[PackageBase]) Callable[[str, Spec, List[AspFunction]], List[AspFunction]][source]¶
- spack.solver.asp.extend_flag_list(flag_list, new_flags)[source]¶
Extend a list of flags, preserving order and precedence.
Add new_flags at the end of flag_list. If any flags in new_flags are already in flag_list, they are moved to the end so that they take higher precedence on the compile line.
- spack.solver.asp.fixed_priority_offset¶
Priority offset of “fixed” criteria (those w/o build criteria)
- spack.solver.asp.high_fixed_priority_offset¶
High fixed priority offset for criteria that supersede all build criteria
- spack.solver.asp.identity_for_facts(name: str, spec: Spec, facts: List[AspFunction]) List[AspFunction][source]¶
- spack.solver.asp.remove_facts(*to_be_removed: str) Callable[[str, Spec, List[AspFunction]], List[AspFunction]][source]¶
Returns a transformation function that removes facts from the input list of facts.
spack.solver.core module¶
Low-level wrappers around clingo API and other basic functionality related to ASP
- class spack.solver.core.AspFunction(name: str, args: Tuple[Any, ...] = ())[source]¶
Bases:
objectA term in the ASP logic program
- args¶
- name¶
- class spack.solver.core.AspVar(name: str)[source]¶
Bases:
objectRepresents a variable in an ASP rule, allows for conditionally generating rules
- name¶
- class spack.solver.core.NodeFlag(flag_type, flag, flag_group, source)[source]¶
Bases:
NamedTuple
- class spack.solver.core.NodeId(id: str, pkg: str)[source]¶
Bases:
NamedTupleRepresents a node in the DAG
- class spack.solver.core.SourceContext(*, source: str | None = None)[source]¶
Bases:
objectTracks context in which a Spec’s clause-set is generated (i.e. with
SpackSolverSetup.spec_clauses).Facts generated for the spec may include this context.
- spack.solver.core.ast_sym(node)¶
- spack.solver.core.ast_type(node)¶
- spack.solver.core.clingo() ModuleType[source]¶
Lazy imports the Python module for clingo, and returns it.
- spack.solver.core.extract_args(model, predicate_name)[source]¶
Extract the arguments to predicates with the provided name from a model.
Pull out all the predicates with name
predicate_namefrom the model, and return their intermediate representation.
- spack.solver.core.fn¶
Global AspFunction builder
- spack.solver.core.intermediate_repr(sym)[source]¶
Returns an intermediate representation of clingo models for Spack’s spec builder.
Currently, transforms symbols from clingo models either to strings or to NodeId objects.
- Returns:
This will turn a
clingo.Symbolinto a string or NodeId, or a sequence ofclingo.Symbolobjects into a tuple of those objects.
- spack.solver.core.parse_files(*args, **kwargs)[source]¶
Wrapper around clingo parse_files, that dispatches the function according to clingo API version.
spack.solver.input_analysis module¶
Classes to analyze the input of a solve, and provide information to set up the ASP problem
- class spack.solver.input_analysis.Counter(specs: List[Spec], tests: bool | Iterable[str], possible_graph: PossibleDependencyGraph)[source]¶
Bases:
objectComputes the possible packages and the maximum number of duplicates allowed for each of them.
- Parameters:
specs – abstract specs to concretize
tests – if True, add test dependencies to the list of possible packages
- possible_packages_facts(gen: ProblemInstanceBuilder, fn) None[source]¶
Emit facts associated with the possible packages
- class spack.solver.input_analysis.FullDuplicatesCounter(specs: List[Spec], tests: bool | Iterable[str], possible_graph: PossibleDependencyGraph)[source]¶
Bases:
MinimalDuplicatesCounter
- class spack.solver.input_analysis.MinimalDuplicatesCounter(specs: List[Spec], tests: bool | Iterable[str], possible_graph: PossibleDependencyGraph)[source]¶
Bases:
NoDuplicatesCounter
- class spack.solver.input_analysis.NoDuplicatesCounter(specs: List[Spec], tests: bool | Iterable[str], possible_graph: PossibleDependencyGraph)[source]¶
Bases:
Counter- possible_packages_facts(gen: ProblemInstanceBuilder, fn) None[source]¶
Emit facts associated with the possible packages
- class spack.solver.input_analysis.NoStaticAnalysis(*, configuration: Configuration, repo: RepoPath)[source]¶
Bases:
PossibleDependencyGraphImplementation that tries to minimize the setup time (i.e. defaults to give fast answers), rather than trying to reduce the ASP problem size with more complex analysis.
- can_be_installed(*, pkg_name) bool[source]¶
Returns True if a package can be installed, False otherwise.
- candidate_targets() List[Microarchitecture][source]¶
Returns a list of targets that are candidate for concretization
- is_allowed_on_this_platform(*, pkg_name: str) bool[source]¶
Returns true if a package is allowed on the current host
- possible_dependencies(*specs: Spec | str, allowed_deps: int, transitive: bool = True, strict_depflag: bool = False, expand_virtuals: bool = True) PossibleGraph[source]¶
Returns the set of possible dependencies, and the set of possible virtuals.
Runtime packages, which may be injected by compilers, needs to be added to specs if the dependency is not explicit in the package.py recipe.
- Parameters:
transitive – return transitive dependencies if True, only direct dependencies if False
allowed_deps – dependency types to consider
strict_depflag – if True, only the specific dep type is considered, if False any deptype that intersects with allowed deptype is considered
expand_virtuals – expand virtual dependencies into all possible implementations
- class spack.solver.input_analysis.PossibleDependencyGraph[source]¶
Bases:
objectReturns information needed to set up an ASP problem
- candidate_targets() List[Microarchitecture][source]¶
Returns a list of targets that are candidate for concretization
- possible_dependencies(*specs: Spec | str, allowed_deps: int, transitive: bool = True, strict_depflag: bool = False, expand_virtuals: bool = True) PossibleGraph[source]¶
Returns the set of possible dependencies, and the set of possible virtuals.
Runtime packages, which may be injected by compilers, needs to be added to specs if the dependency is not explicit in the package.py recipe.
- Parameters:
transitive – return transitive dependencies if True, only direct dependencies if False
allowed_deps – dependency types to consider
strict_depflag – if True, only the specific dep type is considered, if False any deptype that intersects with allowed deptype is considered
expand_virtuals – expand virtual dependencies into all possible implementations
- class spack.solver.input_analysis.PossibleGraph(real_pkgs, virtuals, edges)[source]¶
Bases:
NamedTuple
- class spack.solver.input_analysis.StaticAnalysis(*, configuration: Configuration, repo: RepoPath, store: Store, binary_index: BinaryIndexCache)[source]¶
Bases:
NoStaticAnalysisPerforms some static analysis of the configuration, store, etc. to provide more precise answers on whether some packages can be installed, or used as a provider.
It increases the setup time, but might decrease the grounding and solve time considerably, especially when requirements restrict the possible choices for providers.
- can_be_installed(*, pkg_name) bool[source]¶
Returns True if a package can be installed, False otherwise.
- spack.solver.input_analysis.create_counter(specs: List[Spec], tests: bool | Iterable[str], possible_graph: PossibleDependencyGraph) Counter[source]¶
- spack.solver.input_analysis.create_graph_analyzer() PossibleDependencyGraph[source]¶
spack.solver.requirements module¶
- class spack.solver.requirements.RequirementKind(*values)[source]¶
Bases:
EnumPurpose / provenance of a requirement
- DEFAULT¶
Default requirement expressed under the ‘all’ attribute of packages.yaml
- PACKAGE¶
Requirement expressed on a specific package
- VIRTUAL¶
Requirement expressed on a virtual package
- class spack.solver.requirements.RequirementOrigin(*values)[source]¶
Bases:
EnumOrigin of a requirement
- CONFLICT_YAML¶
- DIRECTIVE¶
- INPUT_SPECS¶
- PREFER_YAML¶
- REQUIRE_YAML¶
- class spack.solver.requirements.RequirementParser(configuration: Configuration)[source]¶
Bases:
objectParses requirements from package.py files and configuration, and returns rules.
- reject_requirement_constraint(pkg_name: str, *, constraint: Spec, kind: RequirementKind) bool[source]¶
Returns True if a requirement constraint should be rejected
- rules(pkg: PackageBase) List[RequirementRule][source]¶
- rules_from_conflict(pkg: PackageBase) List[RequirementRule][source]¶
- rules_from_input_specs(pkg: PackageBase) List[RequirementRule][source]¶
- rules_from_package_py(pkg: PackageBase) List[RequirementRule][source]¶
- rules_from_prefer(pkg: PackageBase) List[RequirementRule][source]¶
- rules_from_require(pkg: PackageBase) List[RequirementRule][source]¶
- rules_from_virtual(virtual_str: str) List[RequirementRule][source]¶
- class spack.solver.requirements.RequirementRule(pkg_name: str, policy: str, origin: RequirementOrigin, requirements: Sequence[Spec], condition: Spec, kind: RequirementKind, message: str | None)[source]¶
Bases:
NamedTupleData class to collect information on a requirement
- kind: RequirementKind¶
Alias for field number 5
- origin: RequirementOrigin¶
Alias for field number 2
- spack.solver.requirements.conflict(pkg_name: str, constraint: Spec, condition: Spec = spack.spec.EMPTY_SPEC, origin: RequirementOrigin = RequirementOrigin.CONFLICT_YAML, kind: RequirementKind = RequirementKind.PACKAGE, message: str | None = None) RequirementRule[source]¶
Returns a conflict rule
- spack.solver.requirements.parse_spec_from_yaml_string(string: str, *, named: bool = False) Spec[source]¶
Parse a spec from YAML and add file/line info to errors, if it’s available.
Parse a
Specfrom the supplied string, but also intercept any syntax errors and add file/line information for debugging using file/line annotations from the string.- Parameters:
string – a string representing a
Specfrom config YAML.named – if True, the spec must have a name
- spack.solver.requirements.preference(pkg_name: str, constraint: Spec, condition: Spec = spack.spec.EMPTY_SPEC, origin: RequirementOrigin = RequirementOrigin.PREFER_YAML, kind: RequirementKind = RequirementKind.PACKAGE, message: str | None = None) RequirementRule[source]¶
Returns a preference rule
spack.solver.reuse module¶
- class spack.solver.reuse.ReusableSpecsSelector(*, configuration: Configuration, external_parser: ExternalSpecsParser, packages_with_externals: Any, factory: Callable[[Callable[[Spec], bool], Configuration], List[SpecFilter]] | None = None)[source]¶
Bases:
objectSelects specs that can be reused during concretization.
- spack.solver.reuse.create_external_parser(packages_with_externals: Any, completion_mode: str) ExternalSpecsParser[source]¶
Get externals from a pre-processed packages.yaml (with implicit externals).
- spack.solver.reuse.spec_filter_from_buildcache(*, packages_with_externals, include, exclude) SpecFilter[source]¶
Constructs a filter that takes the specs from the configured buildcaches.
- spack.solver.reuse.spec_filter_from_environment(*, packages_with_externals, include, exclude, env) SpecFilter[source]¶
- spack.solver.reuse.spec_filter_from_packages_yaml(*, external_parser: ExternalSpecsParser, packages_with_externals, include, exclude) SpecFilter[source]¶
- spack.solver.reuse.spec_filter_from_store(configuration, *, packages_with_externals, include, exclude) SpecFilter[source]¶
Constructs a filter that takes the specs from the current store.
spack.solver.runtimes module¶
- class spack.solver.runtimes.RuntimePropertyRecorder(setup)[source]¶
Bases:
objectAn object of this class is injected in callbacks to compilers, to let them declare properties of the runtimes they support and of the runtimes they provide, and to add runtime dependencies to the nodes using said compiler.
The usage of the object is the following. First, a runtime package name or the wildcard “*” are passed as an argument to __call__, to set which kind of package we are referring to. Then we can call one method with a directive-like API.
Examples
>>> pkg = RuntimePropertyRecorder(setup) >>> # Every package compiled with %gcc has a link dependency on 'gcc-runtime' >>> pkg("*").depends_on( ... "gcc-runtime", ... when="%gcc", ... type="link", ... description="If any package uses %gcc, it depends on gcc-runtime" ... ) >>> # The version of gcc-runtime is the same as the %gcc used to "compile" it >>> pkg("gcc-runtime").requires("@=9.4.0", when="%gcc@=9.4.0")
- consume_facts()[source]¶
Consume the facts collected by this object, and emits rules and facts for the runtimes.
- depends_on(dependency_str: str, *, when: str, type: str, description: str) None[source]¶
Injects conditional dependencies on packages.
Conditional dependencies can be either “real” packages or virtual dependencies.
- Parameters:
dependency_str – the dependency spec to inject
when – anonymous condition to be met on a package to have the dependency
type – dependency type
description – human-readable description of the rule for adding the dependency