From 8f8a1d65b2d6b68dcfad6946ee9e24f76d867fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Thu, 6 Aug 2020 21:56:34 +0700 Subject: [PATCH] Dedent late download logs --- ...82ffb4-cde3-4dd5-8f37-6f4ef53e028b.trivial | 0 src/pip/_internal/operations/prepare.py | 93 +++++++++---------- 2 files changed, 45 insertions(+), 48 deletions(-) create mode 100644 news/4c82ffb4-cde3-4dd5-8f37-6f4ef53e028b.trivial diff --git a/news/4c82ffb4-cde3-4dd5-8f37-6f4ef53e028b.trivial b/news/4c82ffb4-cde3-4dd5-8f37-6f4ef53e028b.trivial new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index 5eb71ce073f..0a254052654 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -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 @@ -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(