Skip to content

Commit d869e0c

Browse files
committed
Merge master
2 parents b2c0487 + 0aee48f commit d869e0c

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

news/9117.bugfix.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
New resolver: The "Requirement already satisfied" log is not printed only once
2+
for each package during resolution.

news/9249.feature.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a mechanism to delay resolving certain packages, and use it for setuptools.

src/pip/_internal/resolution/resolvelib/factory.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,11 @@ def __init__(
9797
self._force_reinstall = force_reinstall
9898
self._ignore_requires_python = ignore_requires_python
9999

100+
self._build_failures = {} # type: Cache[InstallationError]
100101
self._link_candidate_cache = {} # type: Cache[LinkCandidate]
101102
self._editable_candidate_cache = {} # type: Cache[EditableCandidate]
102-
self._build_failures = {} # type: Cache[InstallationError]
103+
self._installed_candidate_cache = {
104+
} # type: Dict[str, AlreadyInstalledCandidate]
103105

104106
if not ignore_installed:
105107
self._installed_dists = {
@@ -121,7 +123,11 @@ def _make_candidate_from_dist(
121123
template, # type: InstallRequirement
122124
):
123125
# type: (...) -> Candidate
124-
base = AlreadyInstalledCandidate(dist, template, factory=self)
126+
try:
127+
base = self._installed_candidate_cache[dist.key]
128+
except KeyError:
129+
base = AlreadyInstalledCandidate(dist, template, factory=self)
130+
self._installed_candidate_cache[dist.key] = base
125131
if extras:
126132
return ExtrasCandidate(base, extras)
127133
return base

src/pip/_internal/resolution/resolvelib/provider.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,18 @@ def _get_restrictive_rating(requirements):
117117
restrictive = _get_restrictive_rating(req for req, _ in information)
118118
transitive = all(parent is not None for _, parent in information)
119119
key = next(iter(candidates)).name if candidates else ""
120-
return (restrictive, transitive, key)
120+
121+
# HACK: Setuptools have a very long and solid backward compatibility
122+
# track record, and extremely few projects would request a narrow,
123+
# non-recent version range of it since that would break a lot things.
124+
# (Most projects specify it only to request for an installer feature,
125+
# which does not work, but that's another topic.) Intentionally
126+
# delaying Setuptools helps reduce branches the resolver has to check.
127+
# This serves as a temporary fix for issues like "apache-airlfow[all]"
128+
# while we work on "proper" branch pruning techniques.
129+
delay_this = (key == "setuptools")
130+
131+
return (delay_this, restrictive, transitive, key)
121132

122133
def find_matches(self, requirements):
123134
# type: (Sequence[Requirement]) -> Iterable[Candidate]

0 commit comments

Comments
 (0)