From c07ef581e729ea26110afeed5f084d3162a87f1f Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Thu, 10 Sep 2020 17:15:32 +0530 Subject: [PATCH 1/5] Factor out logger.into into a single call This makes it easier to conditionally print this information. --- src/pip/_internal/operations/prepare.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index 5eb71ce073f..95ffec562dc 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -373,12 +373,15 @@ def _download_should_save(self): def _log_preparing_link(self, req): # type: (InstallRequirement) -> None - """Log the way the link prepared.""" + """Provide context for the requirement being prepared.""" if req.link.is_file: - path = req.link.file_path - logger.info('Processing %s', display_path(path)) + message = "Processing %s" + information = str(display_path(req.link.file_path)) else: - logger.info('Collecting %s', req.req or req) + message = "Collecting %s" + information = str(req.req or req) + + logger.info(message, information) def _get_download_dir(self, link): # type: (Link) -> Optional[str] From 963e390abe3c7ac00c90a189b3557981e92f5dde Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Thu, 10 Sep 2020 17:21:04 +0530 Subject: [PATCH 2/5] Improve how cached wheels are presented This is specifically for the case of look ups done in the new resolver. --- src/pip/_internal/operations/prepare.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index 95ffec562dc..756adfa43e5 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -374,7 +374,7 @@ def _download_should_save(self): def _log_preparing_link(self, req): # type: (InstallRequirement) -> None """Provide context for the requirement being prepared.""" - if req.link.is_file: + if req.link.is_file and not req.original_link_is_in_wheel_cache: message = "Processing %s" information = str(display_path(req.link.file_path)) else: @@ -383,6 +383,10 @@ def _log_preparing_link(self, req): logger.info(message, information) + if req.original_link_is_in_wheel_cache: + with indent_log(): + logger.info("Using cached %s", req.link.filename) + def _get_download_dir(self, link): # type: (Link) -> Optional[str] if link.is_wheel and self.wheel_download_dir: From 3d32960c80ffed7946d84c636318153619fa5bf6 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Thu, 10 Sep 2020 17:21:42 +0530 Subject: [PATCH 3/5] Only Print "Collecting ..." when the requirement changes --- src/pip/_internal/operations/prepare.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index 756adfa43e5..6f899e6ff12 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -357,6 +357,9 @@ def __init__( # Memoized downloaded files, as mapping of url: (path, mime type) self._downloaded = {} # type: Dict[str, Tuple[str, str]] + # Previous "header" printed for a link-based InstallRequirement + self._previous_requirement_header = None + @property def _download_should_save(self): # type: () -> bool @@ -381,7 +384,9 @@ def _log_preparing_link(self, req): message = "Collecting %s" information = str(req.req or req) - logger.info(message, information) + if (message, information) != self._previous_requirement_header: + self._previous_requirement_header = (message, information) + logger.info(message, information) if req.original_link_is_in_wheel_cache: with indent_log(): From cc472fd54ae4cc860b014fcb23378ba73a538a3d Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Thu, 10 Sep 2020 17:32:58 +0530 Subject: [PATCH 4/5] Use a symmetric type and make mypy happy --- src/pip/_internal/operations/prepare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index 6f899e6ff12..bf89091aa94 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -358,7 +358,7 @@ def __init__( self._downloaded = {} # type: Dict[str, Tuple[str, str]] # Previous "header" printed for a link-based InstallRequirement - self._previous_requirement_header = None + self._previous_requirement_header = ("", "") @property def _download_should_save(self): From 0fc1044ff44a83b3c4f5ed340217c940def6ad37 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Wed, 16 Sep 2020 17:49:15 +0530 Subject: [PATCH 5/5] :newspaper: --- news/8861.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/8861.bugfix diff --git a/news/8861.bugfix b/news/8861.bugfix new file mode 100644 index 00000000000..d623419fae5 --- /dev/null +++ b/news/8861.bugfix @@ -0,0 +1 @@ +Tweak the output during dependency resolution in the new resolver.