diff --git a/src/pip/_internal/resolution/resolvelib/candidates.py b/src/pip/_internal/resolution/resolvelib/candidates.py index 5d510db868f..ff2b4019add 100644 --- a/src/pip/_internal/resolution/resolvelib/candidates.py +++ b/src/pip/_internal/resolution/resolvelib/candidates.py @@ -153,7 +153,15 @@ def __init__( self._ireq = ireq self._name = name self._version = version - self.dist = self._prepare() + self._is_prepared = False + self._dist = None + + @property + def dist(self) -> Distribution: + if not self._is_prepared: + self._dist = self._prepare() + self._is_prepared = True + return self._dist def __str__(self) -> str: return f"{self.name} {self.version}"