Skip to content

Commit

Permalink
Merge pull request pypa#9369 from uranusjr/resolvelib-054
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed Jan 23, 2021
1 parent e4edf1f commit 084463b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions news/9180.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error when an existing incompatibility is unable to be applied to a backtracked state.
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.5.4.
2 changes: 1 addition & 1 deletion src/pip/_vendor/resolvelib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"ResolutionTooDeep",
]

__version__ = "0.5.3"
__version__ = "0.5.4"


from .providers import AbstractProvider, AbstractResolver
Expand Down
36 changes: 22 additions & 14 deletions src/pip/_vendor/resolvelib/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def _backtrack(self):
information from Y to Y'.
4a. If this causes Y' to conflict, we need to backtrack again. Make Y'
the new Z and go back to step 2.
4b. If the incompatibilites apply cleanly, end backtracking.
4b. If the incompatibilities apply cleanly, end backtracking.
"""
while len(self._states) >= 3:
# Remove the state that triggered backtracking.
Expand All @@ -271,28 +271,36 @@ def _backtrack(self):
for k, v in broken_state.criteria.items()
]

# Also mark the newly known incompatibility.
incompatibilities_from_broken.append((name, [candidate]))

self._r.backtracking(candidate)

# Create a new state from the last known-to-work one, and apply
# the previously gathered incompatibility information.
self._push_new_state()
for k, incompatibilities in incompatibilities_from_broken:
try:
crit = self.state.criteria[k]
except KeyError:
continue
self.state.criteria[k] = crit.excluded_of(incompatibilities)
def _patch_criteria():
for k, incompatibilities in incompatibilities_from_broken:
if not incompatibilities:
continue
try:
criterion = self.state.criteria[k]
except KeyError:
continue
criterion = criterion.excluded_of(incompatibilities)
if criterion is None:
return False
self.state.criteria[k] = criterion
return True

# Mark the newly known incompatibility.
criterion = self.state.criteria[name].excluded_of([candidate])
self._push_new_state()
success = _patch_criteria()

# It works! Let's work on this new state.
if criterion:
self.state.criteria[name] = criterion
if success:
return True

# State does not work after adding the new incompatibility
# information. Try the still previous state.
# State does not work after applying known incompatibilities.
# Try the still previous state.

# No way to backtrack anymore.
return False
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ requests==2.25.0
chardet==3.0.4
idna==2.10
urllib3==1.26.2
resolvelib==0.5.3
resolvelib==0.5.4
retrying==1.3.3
setuptools==44.0.0
six==1.15.0
Expand Down

0 comments on commit 084463b

Please sign in to comment.