Skip to content

Commit

Permalink
Upgrade resolvelib to 0.8.0
Browse files Browse the repository at this point in the history
pradyunsg committed Oct 9, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 2253ed3 commit 394a24e
Showing 5 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions news/resolvelib.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade resolvelib to 0.8.0
2 changes: 1 addition & 1 deletion src/pip/_vendor/resolvelib/__init__.py
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
"ResolutionTooDeep",
]

__version__ = "0.7.1"
__version__ = "0.8.0"


from .providers import AbstractProvider, AbstractResolver
11 changes: 10 additions & 1 deletion src/pip/_vendor/resolvelib/providers.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,14 @@ def identify(self, requirement_or_candidate):
"""
raise NotImplementedError

def get_preference(self, identifier, resolutions, candidates, information):
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
@@ -25,6 +32,8 @@ def get_preference(self, identifier, resolutions, candidates, information):
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:
18 changes: 14 additions & 4 deletions src/pip/_vendor/resolvelib/resolvers.py
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ def __init__(self, round_count):


# Resolution state in a round.
State = collections.namedtuple("State", "mapping criteria")
State = collections.namedtuple("State", "mapping criteria backtrack_causes")


class Resolution(object):
@@ -131,6 +131,7 @@ def _push_new_state(self):
state = State(
mapping=base.mapping.copy(),
criteria=base.criteria.copy(),
backtrack_causes=base.backtrack_causes[:],
)
self._states.append(state)

@@ -185,6 +186,7 @@ def _get_preference(self, name):
self.state.criteria,
operator.attrgetter("information"),
),
backtrack_causes=self.state.backtrack_causes,
)

def _is_current_pin_satisfying(self, name, criterion):
@@ -335,7 +337,13 @@ def resolve(self, requirements, max_rounds):
self._r.starting()

# Initialize the root state.
self._states = [State(mapping=collections.OrderedDict(), criteria={})]
self._states = [
State(
mapping=collections.OrderedDict(),
criteria={},
backtrack_causes=[],
)
]
for r in requirements:
try:
self._add_to_criteria(self.state.criteria, r, parent=None)
@@ -369,11 +377,13 @@ def resolve(self, requirements, max_rounds):
# Backtrack if pinning fails. The backtrack process puts us in
# an unpinned state, so we can work on it in the next round.
success = self._backtrack()
self.state.backtrack_causes[:] = [
i for c in failure_causes for i in c.information
]

# Dead ends everywhere. Give up.
if not success:
causes = [i for c in failure_causes for i in c.information]
raise ResolutionImpossible(causes)
raise ResolutionImpossible(self.state.backtrack_causes)
else:
# Pinning was successful. Push a new state to do another pin.
self._push_new_state()
2 changes: 1 addition & 1 deletion src/pip/_vendor/vendor.txt
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ requests==2.26.0
chardet==4.0.0
idna==3.2
urllib3==1.26.7
resolvelib==0.7.1
resolvelib==0.8.0
setuptools==44.0.0
six==1.16.0
tenacity==8.0.1

0 comments on commit 394a24e

Please sign in to comment.