Skip to content

Commit

Permalink
Merge pull request #8722 from McSinyx/late-dl-indent
Browse files Browse the repository at this point in the history
Dedent late download logs
  • Loading branch information
xavfernandez authored Sep 16, 2020
2 parents a13f201 + 8f8a1d6 commit 33890bf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 48 deletions.
Empty file.
93 changes: 45 additions & 48 deletions src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,10 @@ def prepare_linked_requirement(self, req, parallel_builds=False):
self._log_preparing_link(req)
with indent_log():
wheel_dist = self._fetch_metadata_using_lazy_wheel(link)
if wheel_dist is not None:
req.needs_more_preparation = True
return wheel_dist
return self._prepare_linked_requirement(req, parallel_builds)
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_requirements_more(self, reqs, parallel_builds=False):
# type: (Iterable[InstallRequirement], bool) -> None
Expand Down Expand Up @@ -519,51 +519,48 @@ def _prepare_linked_requirement(self, req, parallel_builds):
link = req.link
download_dir = self._get_download_dir(link)

with indent_log():
self._ensure_link_req_src_dir(req, download_dir, parallel_builds)
hashes = self._get_linked_req_hashes(req)
if link.url not in self._downloaded:
try:
local_file = unpack_url(
link, req.source_dir, self._download,
download_dir, hashes,
)
except NetworkConnectionError as exc:
raise InstallationError(
'Could not install requirement {} because of HTTP '
'error {} for URL {}'.format(req, exc, link)
)
else:
file_path, content_type = self._downloaded[link.url]
if hashes:
hashes.check_against_path(file_path)
local_file = File(file_path, content_type)

# For use in later processing, preserve the file path on the
# requirement.
if local_file:
req.local_file_path = local_file.path

dist = _get_prepared_distribution(
req, self.req_tracker, self.finder, self.build_isolation,
)

if download_dir:
if link.is_existing_dir():
logger.info('Link is a directory, ignoring download_dir')
elif local_file:
download_location = os.path.join(
download_dir, link.filename
)
if not os.path.exists(download_location):
shutil.copy(local_file.path, download_location)
download_path = display_path(download_location)
logger.info('Saved %s', download_path)
self._ensure_link_req_src_dir(req, download_dir, parallel_builds)
hashes = self._get_linked_req_hashes(req)
if link.url not in self._downloaded:
try:
local_file = unpack_url(
link, req.source_dir, self._download,
download_dir, hashes,
)
except NetworkConnectionError as exc:
raise InstallationError(
'Could not install requirement {} because of HTTP '
'error {} for URL {}'.format(req, exc, link)
)
else:
file_path, content_type = self._downloaded[link.url]
if hashes:
hashes.check_against_path(file_path)
local_file = File(file_path, content_type)

# For use in later processing,
# preserve the file path on the requirement.
if local_file:
req.local_file_path = local_file.path

dist = _get_prepared_distribution(
req, self.req_tracker, self.finder, self.build_isolation,
)

if self._download_should_save:
# Make a .zip of the source_dir we already created.
if link.is_vcs:
req.archive(self.download_dir)
if download_dir:
if link.is_existing_dir():
logger.info('Link is a directory, ignoring download_dir')
elif local_file:
download_location = os.path.join(download_dir, link.filename)
if not os.path.exists(download_location):
shutil.copy(local_file.path, download_location)
download_path = display_path(download_location)
logger.info('Saved %s', download_path)

if self._download_should_save:
# Make a .zip of the source_dir we already created.
if link.is_vcs:
req.archive(self.download_dir)
return dist

def prepare_editable_requirement(
Expand Down

0 comments on commit 33890bf

Please sign in to comment.