From 906b87727b2a79277f2bf81e34e44afece06bdbd Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Mon, 25 Jul 2022 14:42:39 +0200 Subject: [PATCH 1/4] Clarify pip cache output pip cache reported 'Nothing cached' and 'Number of wheels: 0' even when things were obviously cached. The reason, as per @uranusjr's comment is 1. If a wheel is downloaded (from a secure source), pip uses the network layer cache (provided by a requests extension implemented with cachecontrol) in ${CACHE_DIR}/http. 2. If a wheel is built from source, pip caches it separately in ${CACHE_DIR}/wheels. 3. The pip cache list command is currently only capable of showing entries in the wheel cache, not the network cache. The solution is to clarify what `pip cache` is reporting about. --- src/pip/_internal/commands/cache.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pip/_internal/commands/cache.py b/src/pip/_internal/commands/cache.py index f1a489d324f..f84b7022962 100644 --- a/src/pip/_internal/commands/cache.py +++ b/src/pip/_internal/commands/cache.py @@ -105,9 +105,9 @@ def get_cache_info(self, options: Values, args: List[Any]) -> None: Package index page cache location: {http_cache_location} Package index page cache size: {http_cache_size} Number of HTTP files: {num_http_files} - Wheels location: {wheels_cache_location} - Wheels size: {wheels_cache_size} - Number of wheels: {package_count} + Built wheels location: {wheels_cache_location} + Built wheels size: {wheels_cache_size} + Number of built wheels: {package_count} """ ) .format( @@ -140,7 +140,7 @@ def list_cache_items(self, options: Values, args: List[Any]) -> None: def format_for_human(self, files: List[str]) -> None: if not files: - logger.info("Nothing cached.") + logger.info("No locally built wheels cached.") return results = [] From f2c49cdbad84323956df48a7d9c81b86faf263b4 Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Mon, 25 Jul 2022 14:47:10 +0200 Subject: [PATCH 2/4] Add news article --- news/11300.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/11300.bugfix.rst diff --git a/news/11300.bugfix.rst b/news/11300.bugfix.rst new file mode 100644 index 00000000000..f72f7ee9f4a --- /dev/null +++ b/news/11300.bugfix.rst @@ -0,0 +1 @@ +Clarify that ``pip cache``'s wheels-related output is about locally built wheels only. From d57c5dd1eea3caf099190f34ca0c21e088f7b28e Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Mon, 25 Jul 2022 15:11:54 +0200 Subject: [PATCH 3/4] Fixed the tests --- tests/functional/test_cache.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/functional/test_cache.py b/tests/functional/test_cache.py index 712e08a85cc..b23fb9f2376 100644 --- a/tests/functional/test_cache.py +++ b/tests/functional/test_cache.py @@ -210,9 +210,9 @@ def test_cache_info( result = script.pip("cache", "info") assert f"Package index page cache location: {http_cache_dir}" in result.stdout - assert f"Wheels location: {wheel_cache_dir}" in result.stdout + assert f"Built wheels location: {wheel_cache_dir}" in result.stdout num_wheels = len(wheel_cache_files) - assert f"Number of wheels: {num_wheels}" in result.stdout + assert f"Number of built wheels: {num_wheels}" in result.stdout @pytest.mark.usefixtures("populate_wheel_cache") @@ -242,9 +242,9 @@ def test_cache_list_abspath(script: PipTestEnvironment) -> None: @pytest.mark.usefixtures("empty_wheel_cache") def test_cache_list_with_empty_cache(script: PipTestEnvironment) -> None: """Running `pip cache list` with an empty cache should print - "Nothing cached." and exit.""" + "No locally built wheels cached." and exit.""" result = script.pip("cache", "list") - assert result.stdout == "Nothing cached.\n" + assert result.stdout == "No locally built wheels cached.\n" @pytest.mark.usefixtures("empty_wheel_cache") From 80c3b9615fd3137208b72649071a08f85660b3ca Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Tue, 26 Jul 2022 08:16:49 +0200 Subject: [PATCH 4/4] Textual: "locally built" rather than "built" As per @sbidoul's remark --- src/pip/_internal/commands/cache.py | 6 +++--- tests/functional/test_cache.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pip/_internal/commands/cache.py b/src/pip/_internal/commands/cache.py index f84b7022962..c5f03302d6b 100644 --- a/src/pip/_internal/commands/cache.py +++ b/src/pip/_internal/commands/cache.py @@ -105,9 +105,9 @@ def get_cache_info(self, options: Values, args: List[Any]) -> None: Package index page cache location: {http_cache_location} Package index page cache size: {http_cache_size} Number of HTTP files: {num_http_files} - Built wheels location: {wheels_cache_location} - Built wheels size: {wheels_cache_size} - Number of built wheels: {package_count} + Locally built wheels location: {wheels_cache_location} + Locally built wheels size: {wheels_cache_size} + Number of locally built wheels: {package_count} """ ) .format( diff --git a/tests/functional/test_cache.py b/tests/functional/test_cache.py index b23fb9f2376..7d20f5e3100 100644 --- a/tests/functional/test_cache.py +++ b/tests/functional/test_cache.py @@ -210,9 +210,9 @@ def test_cache_info( result = script.pip("cache", "info") assert f"Package index page cache location: {http_cache_dir}" in result.stdout - assert f"Built wheels location: {wheel_cache_dir}" in result.stdout + assert f"Locally built wheels location: {wheel_cache_dir}" in result.stdout num_wheels = len(wheel_cache_files) - assert f"Number of built wheels: {num_wheels}" in result.stdout + assert f"Number of locally built wheels: {num_wheels}" in result.stdout @pytest.mark.usefixtures("populate_wheel_cache")