Skip to content

Commit

Permalink
Explicitly download wheels of link candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
McSinyx committed Aug 1, 2020
1 parent d8484e0 commit 158931d
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions src/pip/_internal/resolution/resolvelib/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
from pip._internal.req.req_install import check_invalid_constraint_type
from pip._internal.req.req_set import RequirementSet
from pip._internal.resolution.base import BaseResolver
from pip._internal.resolution.resolvelib.candidates import (
InstallRequirementBackedCandidate,
)
from pip._internal.resolution.resolvelib.provider import PipProvider
from pip._internal.utils.misc import dist_is_editable
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

from .factory import Factory

if MYPY_CHECK_RUNNING:
from typing import Dict, Iterable, List, Optional, Set, Tuple
from typing import Dict, List, Optional, Set, Tuple

from pip._vendor.packaging.specifiers import SpecifierSet
from pip._vendor.resolvelib.resolvers import Result
Expand All @@ -28,7 +31,6 @@
from pip._internal.operations.prepare import RequirementPreparer
from pip._internal.req.req_install import InstallRequirement
from pip._internal.resolution.base import InstallRequirementProvider
from pip._internal.resolution.resolvelib.base import Candidate


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -126,17 +128,36 @@ def resolve(self, root_reqs, check_supported_wheels):
six.raise_from(error, e)

return self._make_req_set(
self._result.mapping.values(),
self._get_ireq_backed_candidates(),
check_supported_wheels,
)

def _make_req_set(self, candidates, check_supported_wheels):
# type: (Iterable[Candidate], bool) -> RequirementSet
def _get_ireq_backed_candidates(self):
# type: () -> List[InstallRequirementBackedCandidate]
"""Return list of pinned, InstallRequirement-backed candidates.
The candidates returned by this method
must have everything ready for installation.
"""
assert self._result is not None, "must call resolve() first"
candidates = [
candidate for candidate in self._result.mapping.values()
if isinstance(candidate, InstallRequirementBackedCandidate)
]
if self.factory.use_lazy_wheel:
for candidate in candidates:
self.factory.preparer.downloader(candidate.link)
return candidates

def _make_req_set(
self,
candidates, # type: List[InstallRequirementBackedCandidate]
check_supported_wheels, # type: bool
):
# type: (...) -> RequirementSet
req_set = RequirementSet(check_supported_wheels=check_supported_wheels)
for candidate in candidates:
ireq = candidate.get_install_requirement()
if ireq is None:
continue

# Check if there is already an installation under the same name,
# and set a flag for later stages to uninstall it, if needed.
Expand Down

0 comments on commit 158931d

Please sign in to comment.