Repository: pypa/pip
Pull request #10957 (2022-03-11 07:54:54)

Improve caching topic page
x-ref #9475


Patch:
diff --git a/NEWS.rst b/NEWS.rst
index 5f274c0ef..55ab46927 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -9,20 +9,6 @@
 
 .. towncrier release notes start
 
-22.0.4 (2022-03-06)
-===================
-
-Deprecations and Removals
--------------------------
-
-- Drop the doctype check, that presented a warning for index pages that use non-compliant HTML 5. (`#10903 <https://github.com/pypa/pip/issues/10903>`_)
-
-Vendored Libraries
-------------------
-
-- Downgrade distlib to 0.3.3.
-
-
 22.0.3 (2022-02-03)
 ===================
 
diff --git a/docs/html/topics/caching.md b/docs/html/topics/caching.md
index d584859c3..929ac3541 100644
--- a/docs/html/topics/caching.md
+++ b/docs/html/topics/caching.md
@@ -50,6 +50,43 @@ pip now caches wheels when building from an immutable Git reference
 (i.e. a commit hash).
 ```
 
+## Where is the cache stored
+
+```{caution}
+The exact filesystem structure of pip's cache's contents is considered to be
+an implementation detail and may change between any two versions of pip.
+```
+
+### `pip cache dir`
+
+```{versionadded} 20.1
+
+```
+
+You can use `pip cache dir` to get the cache directory that pip is currently configured to use.
+
+### Default paths
+
+````{tab} Unix
+```
+~/.cache/pip
+```
+
+pip will also respect `XDG_CACHE_HOME`.
+````
+
+````{tab} MacOS
+```
+~/Library/Caches/pip
+```
+````
+
+````{tab} Windows
+```
+%LocalAppData%\pip\Cache
+```
+````
+
 ## Avoiding caching
 
 pip tries to use its cache whenever possible, and it is designed do the right
@@ -81,8 +118,23 @@ It is also a good idea to remove the offending cached wheel using the
 
 The {ref}`pip cache` command can be used to manage pip's cache.
 
-The exact filesystem structure of pip's cache is considered to be an
-implementation detail and may change between any two versions of pip.
+### General overview
+
+`pip cache info` provides an overview of the contents of pip's cache, such as the total size and location of various parts of it.
+
+### Removing a single package
+
+`pip cache remove setuptools` removes all wheel files related to setuptools from pip's cache.
+
+### Removing the cache
+
+`pip cache purge` will clear all wheel files from pip's cache.
+
+### Listing cached files
+
+`pip cache list` will list all wheel files from pip's cache.
+
+`pip cache list setuptools` will list all setuptools-related wheel files from pip's cache.
 
 ## Disabling caching
 
diff --git a/docs/html/user_guide.rst b/docs/html/user_guide.rst
index aa5d41c8c..059fd7cdc 100644
--- a/docs/html/user_guide.rst
+++ b/docs/html/user_guide.rst
@@ -84,7 +84,7 @@ in many corporate environments requires an outbound HTTP proxy server.
 pip can be configured to connect through a proxy server in various ways:
 
 * using the ``--proxy`` command-line option to specify a proxy in the form
-  ``scheme://[user:passwd@]proxy.server:port``
+  ``[user:passwd@]proxy.server:port``
 * using ``proxy`` in a :ref:`config-file`
 * by setting the standard environment-variables ``http_proxy``, ``https_proxy``
   and ``no_proxy``.
diff --git a/news/10903.removal.rst b/news/10903.removal.rst
new file mode 100644
index 000000000..42c996f6e
--- /dev/null
+++ b/news/10903.removal.rst
@@ -0,0 +1,1 @@
+Drop the doctype check, that presented a warning for index pages that use non-compliant HTML 5.
diff --git a/news/10951.doc.rst b/news/10951.doc.rst
deleted file mode 100644
index f132abd11..000000000
--- a/news/10951.doc.rst
+++ /dev/null
@@ -1,1 +0,0 @@
-Add ``scheme://`` requirement to ``--proxy`` option's description
diff --git a/news/9615.feature.rst b/news/9615.feature.rst
deleted file mode 100644
index 075a6cd42..000000000
--- a/news/9615.feature.rst
+++ /dev/null
@@ -1,1 +0,0 @@
-Explains why specified version cannot be retrieved when *Requires-Python* is not satisfied.
diff --git a/news/distlib.vendor.rst b/news/distlib.vendor.rst
new file mode 100644
index 000000000..6ac450952
--- /dev/null
+++ b/news/distlib.vendor.rst
@@ -0,0 +1,1 @@
+Downgrade distlib to 0.3.3.
diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py
index 64bd47d2b..71b1d1906 100644
--- a/src/pip/_internal/cli/cmdoptions.py
+++ b/src/pip/_internal/cli/cmdoptions.py
@@ -272,7 +272,7 @@ proxy: Callable[..., Option] = partial(
     dest="proxy",
     type="str",
     default="",
-    help="Specify a proxy in the form scheme://[user:passwd@]proxy.server:port.",
+    help="Specify a proxy in the form [user:passwd@]proxy.server:port.",
 )
 
 retries: Callable[..., Option] = partial(
diff --git a/src/pip/_internal/index/package_finder.py b/src/pip/_internal/index/package_finder.py
index 2dfc03c36..223d06df6 100644
--- a/src/pip/_internal/index/package_finder.py
+++ b/src/pip/_internal/index/package_finder.py
@@ -222,8 +222,9 @@ class LinkEvaluator:
             ignore_requires_python=self._ignore_requires_python,
         )
         if not supports_python:
-            reason = f"{version} Requires-Python {link.requires_python}"
-            return (False, reason)
+            # Return None for the reason text to suppress calling
+            # _log_skipped_link().
+            return (False, None)
 
         logger.debug("Found link %s, version: %s", link, version)
 
@@ -609,7 +610,7 @@ class PackageFinder:
         self.format_control = format_control
 
         # These are boring links that have already been logged somehow.
-        self._logged_links: Set[Tuple[Link, str]] = set()
+        self._logged_links: Set[Link] = set()
 
     # Don't include an allow_yanked default value to make sure each call
     # site considers whether yanked releases are allowed. This also causes
@@ -689,11 +690,6 @@ class PackageFinder:
     def set_prefer_binary(self) -> None:
         self._candidate_prefs.prefer_binary = True
 
-    def skipped_links_requires_python(self) -> List[str]:
-        return sorted(
-            {reason for _, reason in self._logged_links if "Requires-Python" in reason}
-        )
-
     def make_link_evaluator(self, project_name: str) -> LinkEvaluator:
         canonical_name = canonicalize_name(project_name)
         formats = self.format_control.get_allowed_formats(canonical_name)
@@ -724,11 +720,11 @@ class PackageFinder:
         return no_eggs + eggs
 
     def _log_skipped_link(self, link: Link, reason: str) -> None:
-        if (link, reason) not in self._logged_links:
+        if link not in self._logged_links:
             # Put the link at the end so the reason is more visible and because
             # the link string is usually very long.
             logger.debug("Skipping link: %s: %s", reason, link)
-            self._logged_links.add((link, reason))
+            self._logged_links.add(link)
 
     def get_install_candidate(
         self, link_evaluator: LinkEvaluator, link: Link
@@ -739,7 +735,8 @@ class PackageFinder:
         """
         is_candidate, result = link_evaluator.evaluate_link(link)
         if not is_candidate:
-            self._log_skipped_link(link, result)
+            if result:
+                self._log_skipped_link(link, reason=result)
             return None
 
         return InstallationCandidate(
diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py
index d3648e158..261d8d560 100644
--- a/src/pip/_internal/resolution/resolvelib/factory.py
+++ b/src/pip/_internal/resolution/resolvelib/factory.py
@@ -617,15 +617,8 @@ class Factory:
             req_disp = f"{req} (from {parent.name})"
 
         cands = self._finder.find_all_candidates(req.project_name)
-        skips = self._finder.skipped_links_requires_python()
         versions = [str(v) for v in sorted({c.version for c in cands})]
 
-        if skips:
-            logger.critical(
-                "Ignored the following versions that require a different python "
-                "version: %s",
-                "; ".join(skips) or "none",
-            )
         logger.critical(
             "Could not find a version that satisfies the requirement %s "
             "(from versions: %s)",


Test patch:
diff --git a/tests/unit/test_index.py b/tests/unit/test_index.py
index 7fbcd3766..fa98f28c8 100644
--- a/tests/unit/test_index.py
+++ b/tests/unit/test_index.py
@@ -120,7 +120,7 @@ class TestLinkEvaluator:
         [
             ((3, 6, 5), False, (True, "1.12")),
             # Test an incompatible Python.
-            ((3, 6, 4), False, (False, "1.12 Requires-Python == 3.6.5")),
+            ((3, 6, 4), False, (False, None)),
             # Test an incompatible Python with ignore_requires_python=True.
             ((3, 6, 4), True, (True, "1.12")),
         ],