Skip to content

Commit

Permalink
Make .dist lazily resolver again
Browse files Browse the repository at this point in the history
Preparing a distribution also fetches it if it's not already installed.
We only want to do it when we absolutely need it.
  • Loading branch information
uranusjr committed Dec 15, 2020
1 parent eb2e3d0 commit 60a5dbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/9284.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New resolver: Only download distributions when we really need to inspect them.
10 changes: 9 additions & 1 deletion src/pip/_internal/resolution/resolvelib/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(
self._ireq = ireq
self._name = name
self._version = version
self.dist = self._prepare()
self._dist = None # type: Optional[Distribution]

def __str__(self):
# type: () -> str
Expand Down Expand Up @@ -169,6 +169,14 @@ def __ne__(self, other):
# type: (Any) -> bool
return not self.__eq__(other)

@property
def dist(self):
# type: () -> Distribution
if self._dist is not None:
return self._dist
self._dist = dist = self._prepare()
return dist

@property
def source_link(self):
# type: () -> Optional[Link]
Expand Down

0 comments on commit 60a5dbc

Please sign in to comment.