2 """Delegate class to provide the required interface for the resolver."""
4 def identify(self, requirement_or_candidate):
5 """Given a requirement, return an identifier for it.
7 This is used to identify a requirement, e.g. whether two requirements
8 should have their specifier parts merged.
10 raise NotImplementedError
20 """Produce a sort key for given requirement based on preference.
22 The preference is defined as "I think this requirement should be
23 resolved first". The lower the return value is, the more preferred
24 this group of arguments is.
26 :param identifier: An identifier as returned by ``identify()``. This
27 identifies the dependency matches which should be returned.
28 :param resolutions: Mapping of candidates currently pinned by the
29 resolver. Each key is an identifier, and the value is a candidate.
30 The candidate may conflict with requirements from ``information``.
31 :param candidates: Mapping of each dependency's possible candidates.
32 Each value is an iterator of candidates.
33 :param information: Mapping of requirement information of each package.
34 Each value is an iterator of *requirement information*.
35 :param backtrack_causes: Sequence of requirement information that were
36 the requirements that caused the resolver to most recently backtrack.
38 A *requirement information* instance is a named tuple with two members:
40 * ``requirement`` specifies a requirement contributing to the current
42 * ``parent`` specifies the candidate that provides (depended on) the
43 requirement, or ``None`` to indicate a root requirement.
45 The preference could depend on various issues, including (not
46 necessarily in this order):
48 * Is this package pinned in the current resolution result?
49 * How relaxed is the requirement? Stricter ones should probably be
50 worked on first? (I don't know, actually.)
51 * How many possibilities are there to satisfy this requirement? Those
52 with few left should likely be worked on first, I guess?
53 * Are there any known conflicts for this requirement? We should
54 probably work on those with the most known conflicts.
56 A sortable value should be returned (this will be used as the ``key``
57 parameter of the built-in sorting function). The smaller the value is,
58 the more preferred this requirement is (i.e. the sorting function
59 is called with ``reverse=False``).
61 raise NotImplementedError
63 def find_matches(self, identifier, requirements, incompatibilities):
64 """Find all possible candidates that satisfy the given constraints.
66 :param identifier: An identifier as returned by ``identify()``. This
67 identifies the dependency matches of which should be returned.
68 :param requirements: A mapping of requirements that all returned
69 candidates must satisfy. Each key is an identifier, and the value
70 an iterator of requirements for that dependency.
71 :param incompatibilities: A mapping of known incompatibilities of
72 each dependency. Each key is an identifier, and the value an
73 iterator of incompatibilities known to the resolver. All
74 incompatibilities *must* be excluded from the return value.
76 This should try to get candidates based on the requirements' types.
77 For VCS, local, and archive requirements, the one-and-only match is
78 returned, and for a "named" requirement, the index(es) should be
79 consulted to find concrete candidates for this requirement.
81 The return value should produce candidates ordered by preference; the
82 most preferred candidate should come first. The return type may be one
85 * A callable that returns an iterator that yields candidates.
86 * An collection of candidates.
87 * An iterable of candidates. This will be consumed immediately into a
90 raise NotImplementedError
93 """Whether the given requirement can be satisfied by a candidate.
95 The candidate is guaranteed to have been generated from the
98 A boolean should be returned to indicate whether ``candidate`` is a
99 viable solution to the requirement.
101 raise NotImplementedError
104 """Get dependencies of a candidate.
106 This should return a collection of requirements that `candidate`
107 specifies as its dependencies.
109 raise NotImplementedError
113 """The thing that performs the actual resolution work."""
115 base_exception = Exception
122 """Take a collection of constraints, spit out the resolution result.
124 This returns a representation of the final resolution state, with one
125 guarenteed attribute ``mapping`` that contains resolved candidates as
126 values. The keys are their respective identifiers.
128 :param requirements: A collection of constraints.
129 :param kwargs: Additional keyword arguments that subclasses may accept.
131 :raises: ``self.base_exception`` or its subclass.
133 raise NotImplementedError
get_preference(self, identifier, resolutions, candidates, information, backtrack_causes)
get_dependencies(self, candidate)
identify(self, requirement_or_candidate)
is_satisfied_by(self, requirement, candidate)
find_matches(self, identifier, requirements, incompatibilities)
resolve(self, requirements, **kwargs)
__init__(self, provider, reporter)