Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade vendored resolvelib to 0.5.4 #9369

Merged
merged 2 commits into from
Dec 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -15,7 +15,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