spack.solver package

Submodules

spack.solver.asp module

class spack.solver.asp.AspFunction(name, args=None)[source]

Bases: spack.solver.asp.AspObject

symbol(positive=True)[source]
class spack.solver.asp.AspFunctionBuilder[source]

Bases: object

class spack.solver.asp.AspObject[source]

Bases: object

Object representing a piece of ASP code.

class spack.solver.asp.DeclaredVersion(version, idx, origin)

Bases: tuple

Named tuple to contain information on declared versions

property idx

Alias for field number 1

property origin

Alias for field number 2

property version

Alias for field number 0

class spack.solver.asp.PyclingoDriver(cores=True, asp=None)[source]

Bases: object

fact(head, assumption=False)[source]

ASP fact (a rule without a body).

Parameters
  • head (AspFunction) – ASP function to generate as fact

  • assumption (bool) – If True and using cores, use this fact as a choice point in ASP and include it in unsatisfiable cores

h1(name)[source]
h2(name)[source]
newline()[source]
solve(solver_setup, specs, dump=None, nmodels=0, timers=False, stats=False, tests=False, reuse=False)[source]
title(name, char)[source]
class spack.solver.asp.Result(specs, asp=None)[source]

Bases: object

Result of an ASP solve.

format_core(core)[source]

Format an unsatisfiable core for human readability

Returns a list of strings, where each string is the human readable representation of a single fact in the core, including a newline.

Modeled after traceback.format_stack.

format_minimal_cores()[source]

List of facts for each core

Separate cores are separated by an empty line

minimal_cores()[source]

Return a list of subset-minimal unsatisfiable cores.

minimize_core(core)[source]

Return a subset-minimal subset of the core.

Clingo cores may be thousands of lines when two facts are sufficient to ensure unsatisfiability. This algorithm reduces the core to only those essential facts.

raise_if_unsat()[source]

Raise an appropriate error if the result is unsatisfiable.

The error is a UnsatisfiableSpecError, and includes the minimized cores resulting from the solve, formatted to be human readable.

property specs

List of concretized specs satisfying the initial abstract request.

class spack.solver.asp.SpackSolverSetup[source]

Bases: object

Class to set up and run a Spack concretization solve.

available_compilers()[source]

Facts about available compilers.

build_version_dict(possible_pkgs, specs)[source]

Declare any versions in specs not declared in packages.

compiler_defaults()[source]

Set compiler defaults, given a list of possible compilers.

compiler_supports_os()[source]
condition(required_spec, imposed_spec=None, name=None)[source]

Generate facts for a dependency or virtual provider condition.

Parameters
  • required_spec (spack.spec.Spec) – the spec that triggers this condition

  • imposed_spec (spack.spec.Spec or None) – the spec with constraints that are imposed when this condition is triggered

  • name (str or None) – name for required_spec (required if required_spec is anonymous, ignored if not)

Returns

id of the condition created by this function

Return type

int

conflict_rules(pkg)[source]
define_compiler_version_constraints()[source]
define_concrete_input_specs(specs, possible)[source]
define_installed_packages(specs, possible)[source]

Add facts about all specs already in the database.

Parameters

possible (dict) – result of Package.possible_dependencies() for specs in this solve.

define_target_constraints()[source]
define_variant_values()[source]

Validate variant values from the command line.

Also add valid variant values from the command line to the possible values for a variant.

define_version_constraints()[source]

Define what version_satisfies(…) means in ASP logic.

define_virtual_constraints()[source]

Define versions for constraints on virtuals.

Must be called before define_version_constraints().

external_packages()[source]

Facts on external packages, as read from packages.yaml

flag_defaults()[source]
generate_possible_compilers(specs)[source]
impose(condition_id, imposed_spec, node=True, name=None, body=False)[source]
os_defaults(specs)[source]
package_compiler_defaults(pkg)[source]

Facts about packages’ compiler prefs.

package_dependencies_rules(pkg, tests)[source]

Translate ‘depends_on’ directives into ASP logic.

package_provider_rules(pkg)[source]
pkg_rules(pkg, tests)[source]
pkg_version_rules(pkg)[source]

Output declared versions of a package.

This uses self.possible_versions so that we include any versions that arise from a spec.

platform_defaults()[source]
preferred_targets(pkg_name)[source]
preferred_variants(pkg_name)[source]

Facts on concretization preferences, as read from packages.yaml

provider_defaults()[source]
setup(driver, specs, tests=False, reuse=False)[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) – list of Specs to solve

spec_clauses(*args, **kwargs)[source]

Wrap a call to _spec_clauses() into a try/except block that raises a comprehensible error message in case of failure.

spec_versions(spec)[source]

Return list of clauses expressing spec’s version constraints.

target_defaults(specs)[source]

Add facts about targets and target compatibility.

target_ranges(spec, single_target_fn)[source]
virtual_preferences(pkg_name, func)[source]

Call func(vspec, provider, i) for each of pkg’s provider prefs.

virtual_providers()[source]
class spack.solver.asp.SpecBuilder(specs)[source]

Bases: object

Class with actions to rebuild a spec from ASP results.

build_specs(function_tuples)[source]
depends_on(pkg, dep, type)[source]
deprecated(pkg, version)[source]
external_spec_selected(pkg, idx)[source]

This means that the external spec and index idx has been selected for this package.

hash(pkg, h)[source]
ignored_attributes = ['opt_criterion']

Attributes that don’t need actions

no_flags(pkg, flag_type)[source]
node(pkg)[source]
node_compiler(pkg, compiler)[source]
node_compiler_version(pkg, compiler, version)[source]
node_flag(pkg, flag_type, flag)[source]
node_flag_compiler_default(pkg)[source]
node_flag_source(pkg, source)[source]
node_os(pkg, os)[source]
node_platform(pkg, platform)[source]
node_target(pkg, target)[source]
reorder_flags()[source]

Order compiler flags on specs in predefined order.

We order flags so that any node’s flags will take priority over those of its dependents. That is, the deepest node in the DAG’s flags will appear last on the compile line, in the order they were specified.

The solver determines wihch flags are on nodes; this routine imposes order afterwards.

variant_value(pkg, name, value)[source]
version(pkg, version)[source]
spack.solver.asp.all_compilers_in_config()[source]
spack.solver.asp.ast_getter(*names)[source]
spack.solver.asp.ast_sym(node)
spack.solver.asp.ast_type(node)
spack.solver.asp.bootstrap_clingo()[source]
spack.solver.asp.build_criteria_names(costs, tuples)[source]

Construct an ordered mapping from criteria names to indices in the cost list.

spack.solver.asp.build_priority_offset = 200

Priority offset for “build” criteria (regular criterio shifted to higher priority for specs we have to build)

spack.solver.asp.check_packages_exist(specs)[source]

Ensure all packages mentioned in specs exist.

spack.solver.asp.check_same_flags(flag_dict_1, flag_dict_2)[source]

Return True if flag dicts contain the same flags regardless of order.

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 = 100

Priority offset of “fixed” criteria (those w/o build criteria)

spack.solver.asp.fn
spack.solver.asp.issequence(obj)[source]
spack.solver.asp.listify(args)[source]
spack.solver.asp.packagize(pkg)[source]
spack.solver.asp.solve(specs, dump=(), models=0, timers=False, stats=False, tests=False, reuse=False)[source]

Solve for a stable model of specs.

Parameters
  • specs (list) – list of Specs to solve.

  • dump (tuple) – what to dump

  • models (int) – number of models to search (default: 0)

spack.solver.asp.specify(spec)[source]
spack.solver.asp.version_provenance = VersionProvenance(external=1, packages_yaml=2, package_py=3, spec=0)

Enumeration like object to mark version provenance

Module contents