Skip to content

Commit

Permalink
Prepare lazy wheels more so they are downloaded
Browse files Browse the repository at this point in the history
This keeps all knowledge about preparation and types of requirements in
`RequirementPreparer`, so there's one place to look when we're ready to
start breaking it apart later.
  • Loading branch information
chrahunt committed Aug 2, 2020
1 parent c7ade15 commit 8b838eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,21 @@ def prepare_linked_requirement(self, req, parallel_builds=False):
self._log_preparing_link(req)
wheel_dist = self._fetch_metadata(link)
if wheel_dist is not None:
req.needs_more_preparation = True
return wheel_dist
return self._prepare_linked_requirement(req, parallel_builds)

def prepare_linked_requirement_more(self, req, parallel_builds=False):
# type: (InstallRequirement, bool) -> None
"""Prepare a linked requirement more, if needed."""
if not req.needs_more_preparation:
return
self._prepare_linked_requirement(req, parallel_builds)

def _prepare_linked_requirement(self, req, parallel_builds):
# type: (InstallRequirement, bool) -> Distribution
assert req.link
link = req.link
if link.is_wheel and self.wheel_download_dir:
# Download wheels to a dedicated dir when doing `pip wheel`.
download_dir = self.wheel_download_dir
Expand Down
3 changes: 3 additions & 0 deletions src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ def __init__(
# but after loading this flag should be treated as read only.
self.use_pep517 = use_pep517

# This requirement needs more preparation before it can be built
self.needs_more_preparation = False

def __str__(self):
# type: () -> str
if self.req:
Expand Down
3 changes: 3 additions & 0 deletions src/pip/_internal/resolution/resolvelib/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def resolve(self, root_reqs, check_supported_wheels):

req_set.add_named_requirement(ireq)

for actual_req in req_set.all_requirements:
self.factory.preparer.prepare_linked_requirement_more(actual_req)

return req_set

def get_installation_order(self, req_set):
Expand Down

0 comments on commit 8b838eb

Please sign in to comment.