first commit
This commit is contained in:
26
venv/Lib/site-packages/pip/_vendor/resolvelib/__init__.py
Normal file
26
venv/Lib/site-packages/pip/_vendor/resolvelib/__init__.py
Normal file
@@ -0,0 +1,26 @@
|
||||
__all__ = [
|
||||
"__version__",
|
||||
"AbstractProvider",
|
||||
"AbstractResolver",
|
||||
"BaseReporter",
|
||||
"InconsistentCandidate",
|
||||
"Resolver",
|
||||
"RequirementsConflicted",
|
||||
"ResolutionError",
|
||||
"ResolutionImpossible",
|
||||
"ResolutionTooDeep",
|
||||
]
|
||||
|
||||
__version__ = "1.0.1"
|
||||
|
||||
|
||||
from .providers import AbstractProvider, AbstractResolver
|
||||
from .reporters import BaseReporter
|
||||
from .resolvers import (
|
||||
InconsistentCandidate,
|
||||
RequirementsConflicted,
|
||||
ResolutionError,
|
||||
ResolutionImpossible,
|
||||
ResolutionTooDeep,
|
||||
Resolver,
|
||||
)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
__all__ = ["Mapping", "Sequence"]
|
||||
|
||||
try:
|
||||
from collections.abc import Mapping, Sequence
|
||||
except ImportError:
|
||||
from collections import Mapping, Sequence
|
133
venv/Lib/site-packages/pip/_vendor/resolvelib/providers.py
Normal file
133
venv/Lib/site-packages/pip/_vendor/resolvelib/providers.py
Normal file
@@ -0,0 +1,133 @@
|
||||
class AbstractProvider(object):
|
||||
"""Delegate class to provide the required interface for the resolver."""
|
||||
|
||||
def identify(self, requirement_or_candidate):
|
||||
"""Given a requirement, return an identifier for it.
|
||||
|
||||
This is used to identify a requirement, e.g. whether two requirements
|
||||
should have their specifier parts merged.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_preference(
|
||||
self,
|
||||
identifier,
|
||||
resolutions,
|
||||
candidates,
|
||||
information,
|
||||
backtrack_causes,
|
||||
):
|
||||
"""Produce a sort key for given requirement based on preference.
|
||||
|
||||
The preference is defined as "I think this requirement should be
|
||||
resolved first". The lower the return value is, the more preferred
|
||||
this group of arguments is.
|
||||
|
||||
:param identifier: An identifier as returned by ``identify()``. This
|
||||
identifies the dependency matches which should be returned.
|
||||
:param resolutions: Mapping of candidates currently pinned by the
|
||||
resolver. Each key is an identifier, and the value is a candidate.
|
||||
The candidate may conflict with requirements from ``information``.
|
||||
:param candidates: Mapping of each dependency's possible candidates.
|
||||
Each value is an iterator of candidates.
|
||||
:param information: Mapping of requirement information of each package.
|
||||
Each value is an iterator of *requirement information*.
|
||||
:param backtrack_causes: Sequence of requirement information that were
|
||||
the requirements that caused the resolver to most recently backtrack.
|
||||
|
||||
A *requirement information* instance is a named tuple with two members:
|
||||
|
||||
* ``requirement`` specifies a requirement contributing to the current
|
||||
list of candidates.
|
||||
* ``parent`` specifies the candidate that provides (depended on) the
|
||||
requirement, or ``None`` to indicate a root requirement.
|
||||
|
||||
The preference could depend on various issues, including (not
|
||||
necessarily in this order):
|
||||
|
||||
* Is this package pinned in the current resolution result?
|
||||
* How relaxed is the requirement? Stricter ones should probably be
|
||||
worked on first? (I don't know, actually.)
|
||||
* How many possibilities are there to satisfy this requirement? Those
|
||||
with few left should likely be worked on first, I guess?
|
||||
* Are there any known conflicts for this requirement? We should
|
||||
probably work on those with the most known conflicts.
|
||||
|
||||
A sortable value should be returned (this will be used as the ``key``
|
||||
parameter of the built-in sorting function). The smaller the value is,
|
||||
the more preferred this requirement is (i.e. the sorting function
|
||||
is called with ``reverse=False``).
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def find_matches(self, identifier, requirements, incompatibilities):
|
||||
"""Find all possible candidates that satisfy the given constraints.
|
||||
|
||||
:param identifier: An identifier as returned by ``identify()``. This
|
||||
identifies the dependency matches of which should be returned.
|
||||
:param requirements: A mapping of requirements that all returned
|
||||
candidates must satisfy. Each key is an identifier, and the value
|
||||
an iterator of requirements for that dependency.
|
||||
:param incompatibilities: A mapping of known incompatibilities of
|
||||
each dependency. Each key is an identifier, and the value an
|
||||
iterator of incompatibilities known to the resolver. All
|
||||
incompatibilities *must* be excluded from the return value.
|
||||
|
||||
This should try to get candidates based on the requirements' types.
|
||||
For VCS, local, and archive requirements, the one-and-only match is
|
||||
returned, and for a "named" requirement, the index(es) should be
|
||||
consulted to find concrete candidates for this requirement.
|
||||
|
||||
The return value should produce candidates ordered by preference; the
|
||||
most preferred candidate should come first. The return type may be one
|
||||
of the following:
|
||||
|
||||
* A callable that returns an iterator that yields candidates.
|
||||
* An collection of candidates.
|
||||
* An iterable of candidates. This will be consumed immediately into a
|
||||
list of candidates.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def is_satisfied_by(self, requirement, candidate):
|
||||
"""Whether the given requirement can be satisfied by a candidate.
|
||||
|
||||
The candidate is guaranteed to have been generated from the
|
||||
requirement.
|
||||
|
||||
A boolean should be returned to indicate whether ``candidate`` is a
|
||||
viable solution to the requirement.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_dependencies(self, candidate):
|
||||
"""Get dependencies of a candidate.
|
||||
|
||||
This should return a collection of requirements that `candidate`
|
||||
specifies as its dependencies.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class AbstractResolver(object):
|
||||
"""The thing that performs the actual resolution work."""
|
||||
|
||||
base_exception = Exception
|
||||
|
||||
def __init__(self, provider, reporter):
|
||||
self.provider = provider
|
||||
self.reporter = reporter
|
||||
|
||||
def resolve(self, requirements, **kwargs):
|
||||
"""Take a collection of constraints, spit out the resolution result.
|
||||
|
||||
This returns a representation of the final resolution state, with one
|
||||
guarenteed attribute ``mapping`` that contains resolved candidates as
|
||||
values. The keys are their respective identifiers.
|
||||
|
||||
:param requirements: A collection of constraints.
|
||||
:param kwargs: Additional keyword arguments that subclasses may accept.
|
||||
|
||||
:raises: ``self.base_exception`` or its subclass.
|
||||
"""
|
||||
raise NotImplementedError
|
43
venv/Lib/site-packages/pip/_vendor/resolvelib/reporters.py
Normal file
43
venv/Lib/site-packages/pip/_vendor/resolvelib/reporters.py
Normal file
@@ -0,0 +1,43 @@
|
||||
class BaseReporter(object):
|
||||
"""Delegate class to provider progress reporting for the resolver."""
|
||||
|
||||
def starting(self):
|
||||
"""Called before the resolution actually starts."""
|
||||
|
||||
def starting_round(self, index):
|
||||
"""Called before each round of resolution starts.
|
||||
|
||||
The index is zero-based.
|
||||
"""
|
||||
|
||||
def ending_round(self, index, state):
|
||||
"""Called before each round of resolution ends.
|
||||
|
||||
This is NOT called if the resolution ends at this round. Use `ending`
|
||||
if you want to report finalization. The index is zero-based.
|
||||
"""
|
||||
|
||||
def ending(self, state):
|
||||
"""Called before the resolution ends successfully."""
|
||||
|
||||
def adding_requirement(self, requirement, parent):
|
||||
"""Called when adding a new requirement into the resolve criteria.
|
||||
|
||||
:param requirement: The additional requirement to be applied to filter
|
||||
the available candidaites.
|
||||
:param parent: The candidate that requires ``requirement`` as a
|
||||
dependency, or None if ``requirement`` is one of the root
|
||||
requirements passed in from ``Resolver.resolve()``.
|
||||
"""
|
||||
|
||||
def resolving_conflicts(self, causes):
|
||||
"""Called when starting to attempt requirement conflict resolution.
|
||||
|
||||
:param causes: The information on the collision that caused the backtracking.
|
||||
"""
|
||||
|
||||
def rejecting_candidate(self, criterion, candidate):
|
||||
"""Called when rejecting a candidate during backtracking."""
|
||||
|
||||
def pinning(self, candidate):
|
||||
"""Called when adding a candidate to the potential solution."""
|
547
venv/Lib/site-packages/pip/_vendor/resolvelib/resolvers.py
Normal file
547
venv/Lib/site-packages/pip/_vendor/resolvelib/resolvers.py
Normal file
File diff suppressed because it is too large
Load Diff
170
venv/Lib/site-packages/pip/_vendor/resolvelib/structs.py
Normal file
170
venv/Lib/site-packages/pip/_vendor/resolvelib/structs.py
Normal file
@@ -0,0 +1,170 @@
|
||||
import itertools
|
||||
|
||||
from .compat import collections_abc
|
||||
|
||||
|
||||
class DirectedGraph(object):
|
||||
"""A graph structure with directed edges."""
|
||||
|
||||
def __init__(self):
|
||||
self._vertices = set()
|
||||
self._forwards = {} # <key> -> Set[<key>]
|
||||
self._backwards = {} # <key> -> Set[<key>]
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._vertices)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._vertices)
|
||||
|
||||
def __contains__(self, key):
|
||||
return key in self._vertices
|
||||
|
||||
def copy(self):
|
||||
"""Return a shallow copy of this graph."""
|
||||
other = DirectedGraph()
|
||||
other._vertices = set(self._vertices)
|
||||
other._forwards = {k: set(v) for k, v in self._forwards.items()}
|
||||
other._backwards = {k: set(v) for k, v in self._backwards.items()}
|
||||
return other
|
||||
|
||||
def add(self, key):
|
||||
"""Add a new vertex to the graph."""
|
||||
if key in self._vertices:
|
||||
raise ValueError("vertex exists")
|
||||
self._vertices.add(key)
|
||||
self._forwards[key] = set()
|
||||
self._backwards[key] = set()
|
||||
|
||||
def remove(self, key):
|
||||
"""Remove a vertex from the graph, disconnecting all edges from/to it."""
|
||||
self._vertices.remove(key)
|
||||
for f in self._forwards.pop(key):
|
||||
self._backwards[f].remove(key)
|
||||
for t in self._backwards.pop(key):
|
||||
self._forwards[t].remove(key)
|
||||
|
||||
def connected(self, f, t):
|
||||
return f in self._backwards[t] and t in self._forwards[f]
|
||||
|
||||
def connect(self, f, t):
|
||||
"""Connect two existing vertices.
|
||||
|
||||
Nothing happens if the vertices are already connected.
|
||||
"""
|
||||
if t not in self._vertices:
|
||||
raise KeyError(t)
|
||||
self._forwards[f].add(t)
|
||||
self._backwards[t].add(f)
|
||||
|
||||
def iter_edges(self):
|
||||
for f, children in self._forwards.items():
|
||||
for t in children:
|
||||
yield f, t
|
||||
|
||||
def iter_children(self, key):
|
||||
return iter(self._forwards[key])
|
||||
|
||||
def iter_parents(self, key):
|
||||
return iter(self._backwards[key])
|
||||
|
||||
|
||||
class IteratorMapping(collections_abc.Mapping):
|
||||
def __init__(self, mapping, accessor, appends=None):
|
||||
self._mapping = mapping
|
||||
self._accessor = accessor
|
||||
self._appends = appends or {}
|
||||
|
||||
def __repr__(self):
|
||||
return "IteratorMapping({!r}, {!r}, {!r})".format(
|
||||
self._mapping,
|
||||
self._accessor,
|
||||
self._appends,
|
||||
)
|
||||
|
||||
def __bool__(self):
|
||||
return bool(self._mapping or self._appends)
|
||||
|
||||
__nonzero__ = __bool__ # XXX: Python 2.
|
||||
|
||||
def __contains__(self, key):
|
||||
return key in self._mapping or key in self._appends
|
||||
|
||||
def __getitem__(self, k):
|
||||
try:
|
||||
v = self._mapping[k]
|
||||
except KeyError:
|
||||
return iter(self._appends[k])
|
||||
return itertools.chain(self._accessor(v), self._appends.get(k, ()))
|
||||
|
||||
def __iter__(self):
|
||||
more = (k for k in self._appends if k not in self._mapping)
|
||||
return itertools.chain(self._mapping, more)
|
||||
|
||||
def __len__(self):
|
||||
more = sum(1 for k in self._appends if k not in self._mapping)
|
||||
return len(self._mapping) + more
|
||||
|
||||
|
||||
class _FactoryIterableView(object):
|
||||
"""Wrap an iterator factory returned by `find_matches()`.
|
||||
|
||||
Calling `iter()` on this class would invoke the underlying iterator
|
||||
factory, making it a "collection with ordering" that can be iterated
|
||||
through multiple times, but lacks random access methods presented in
|
||||
built-in Python sequence types.
|
||||
"""
|
||||
|
||||
def __init__(self, factory):
|
||||
self._factory = factory
|
||||
self._iterable = None
|
||||
|
||||
def __repr__(self):
|
||||
return "{}({})".format(type(self).__name__, list(self))
|
||||
|
||||
def __bool__(self):
|
||||
try:
|
||||
next(iter(self))
|
||||
except StopIteration:
|
||||
return False
|
||||
return True
|
||||
|
||||
__nonzero__ = __bool__ # XXX: Python 2.
|
||||
|
||||
def __iter__(self):
|
||||
iterable = (
|
||||
self._factory() if self._iterable is None else self._iterable
|
||||
)
|
||||
self._iterable, current = itertools.tee(iterable)
|
||||
return current
|
||||
|
||||
|
||||
class _SequenceIterableView(object):
|
||||
"""Wrap an iterable returned by find_matches().
|
||||
|
||||
This is essentially just a proxy to the underlying sequence that provides
|
||||
the same interface as `_FactoryIterableView`.
|
||||
"""
|
||||
|
||||
def __init__(self, sequence):
|
||||
self._sequence = sequence
|
||||
|
||||
def __repr__(self):
|
||||
return "{}({})".format(type(self).__name__, self._sequence)
|
||||
|
||||
def __bool__(self):
|
||||
return bool(self._sequence)
|
||||
|
||||
__nonzero__ = __bool__ # XXX: Python 2.
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._sequence)
|
||||
|
||||
|
||||
def build_iter_view(matches):
|
||||
"""Build an iterable view from the value returned by `find_matches()`."""
|
||||
if callable(matches):
|
||||
return _FactoryIterableView(matches)
|
||||
if not isinstance(matches, collections_abc.Sequence):
|
||||
matches = list(matches)
|
||||
return _SequenceIterableView(matches)
|
Reference in New Issue
Block a user