rez.solver

The dependency resolving module.

This gives direct access to the solver. You should use the resolve() function in resolve.py instead, which will use cached data where possible to provide you with a faster resolve.

See SOLVER.md for an in-depth description of how this module works.

class rez.solver.Cycle(packages)[source]

Bases: rez.solver.FailureReason

The solve contains a cyclic dependency.

description()[source]
involved_requirements()[source]
class rez.solver.DependencyConflict(dependency, conflicting_request)[source]

Bases: rez.solver._Common

A common dependency shared by all variants in a scope, conflicted with another scope in the current phase.

class rez.solver.DependencyConflicts(conflicts)[source]

Bases: rez.solver.FailureReason

A common dependency in a scope conflicted with another scope in the current phase.

description()[source]
involved_requirements()[source]
class rez.solver.FailureReason[source]

Bases: rez.solver._Common

description()[source]
involved_requirements()[source]
class rez.solver.PackageVariant(variant, building)[source]

Bases: rez.solver._Common

A variant of a package.

property conflict_request_fams
get(pkg_name)[source]
property handle
property index
property name
property request_fams
requires_list

Simple property caching descriptor.

Example

>>> class Foo(object):
>>>     @cached_property
>>>     def bah(self):
>>>         print('bah')
>>>         return 1
>>>
>>> f = Foo()
>>> f.bah
bah
1
>>> f.bah
1
property version
class rez.solver.PackageVariantCache(solver)[source]

Bases: object

get_variant_slice(package_name, range_)[source]

Get a list of variants from the cache.

Parameters
  • package_name (str) – Name of package.

  • range (VersionRange) – Package version range.

Returns

_PackageVariantSlice object.

class rez.solver.Reduction(name, version, variant_index, dependency, conflicting_request)[source]

Bases: rez.solver._Common

A variant was removed because its dependencies conflicted with another scope in the current phase.

involved_requirements()[source]
reducee_str()[source]
class rez.solver.Solver(package_requests, package_paths, context=None, package_filter=None, package_orderers=None, callback=None, building=False, optimised=True, verbosity=0, buf=None, package_load_callback=None, prune_unfailed=True, suppress_passive=False, print_stats=False)[source]

Bases: rez.solver._Common

Solver.

A package solver takes a list of package requests (the ‘request’), then runs a resolve algorithm in order to determine the ‘resolve’ - the list of non-conflicting packages that include all dependencies.

property cyclic_fail

Return True if the solve failed due to a cycle, False otherwise.

dump()[source]

Print a formatted summary of the current solve state.

failure_description(failure_index=None)[source]

Get a description of the failure.

This differs from failure_reason - in some cases, such as when a callback forces a failure, there is more information in the description than there is from failure_reason.

failure_packages(failure_index=None)[source]

Get packages involved in a failure.

Parameters

failure_index – See failure_reason.

Returns

A list of Requirement objects.

failure_reason(failure_index=None)[source]

Get the reason for a failure.

Parameters

failure_index

Index of the fail to return the graph for (can be negative). If None, the most appropriate failure is chosen according to these rules: - If the fail is cyclic, the most recent fail (the one containing

the cycle) is used;

  • If a callback has caused a failure, the most recent fail is used;

  • Otherwise, the first fail is used.

Returns

A FailureReason subclass instance describing the failure.

get_fail_graph(failure_index=None)[source]

Returns a graph showing a solve failure.

Parameters

failure_index – See failure_reason

Returns

A pygraph.digraph object.

get_graph()[source]

Returns the most recent solve graph.

This gives a graph showing the latest state of the solve. The specific graph returned depends on the solve status. When status is: unsolved: latest unsolved graph is returned; solved: final solved graph is returned; failed: most appropriate failure graph is returned (see failure_reason); cyclic: last failure is returned (contains cycle).

Returns

A pygraph.digraph object.

max_verbosity = 3
property num_fails

Return the number of failed solve steps that have been executed. Note that num_solves is inclusive of failures.

property num_solves

Return the number of solve steps that have been executed.

reset()[source]

Reset the solver, removing any current solve.

property resolved_ephemerals

Return the list of final ephemeral package ranges.

Note that conflict ephemerals are not included.

Returns

Final non-conflict ephemerals, or None if the resolve did not complete or was unsuccessful.

Return type

List of Requirement

property resolved_packages

Return a list of resolved variants.

Returns

Resolved variants, or None if the resolve did not complete or was unsuccessful.

Return type

list of PackageVariant

solve()[source]

Attempt to solve the request.

property solve_stats
solve_step()[source]

Perform a single solve step.

property status

Return the current status of the solve.

Returns

Enum representation of the state of the solver.

Return type

SolverStatus

timed(target)[source]
class rez.solver.SolverCallbackReturn(value, names=None, module=None, type=None)[source]

Bases: rez.vendor.enum.Enum

Enum returned by the callback callable passed to a Solver instance.

class rez.solver.SolverState(num_solves, num_fails, phase)[source]

Bases: object

Represent the current state of the solver instance for use with a callback.

class rez.solver.SolverStatus(value, names=None, module=None, type=None)[source]

Bases: rez.vendor.enum.Enum

Enum to represent the current state of a solver instance. The enum also includes a human readable description of what the state represents.

class rez.solver.TotalReduction(reductions)[source]

Bases: rez.solver.FailureReason

All of a scope’s variants were reduced away.

description()[source]
involved_requirements()[source]
class rez.solver.VariantSelectMode(value, names=None, module=None, type=None)[source]

Bases: rez.vendor.enum.Enum

Variant selection mode.