[Python-checkins] bpo-40448: ensurepip: Do not use cache (GH-19812)

Miss Islington (bot) webhook-mailer at python.org
Mon Jun 15 13:44:41 EDT 2020


https://github.com/python/cpython/commit/b46beb25e4cf213dbf46a0a0cf3f0ed134894f7d
commit: b46beb25e4cf213dbf46a0a0cf3f0ed134894f7d
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-06-15T10:44:34-07:00
summary:

bpo-40448: ensurepip: Do not use cache (GH-19812)


ensurepip optionally installs or upgrades 'pip' and 'setuptools' using
the version of those modules bundled with Python.  The internal PIP
installation routine by default temporarily uses its cache, if it
exists.  This is undesirable as Python builds and installations may be
independent of the user running the build, whilst PIP cache location
is dependent on the user's environment and outside of the build
environment.

At the same time, there's no value in using the cache while installing
bundled modules.

This change disables PIP caching when used in ensurepip.
(cherry picked from commit 4a3a682b12f93a03888e8b59f439bc5fe30d6055)

Co-authored-by: Krzysztof Konopko <kkonopko at users.noreply.github.com>

files:
A Misc/NEWS.d/next/Library/2020-06-15-12-22-53.bpo-40448.1dk8Bu.rst
M Lib/ensurepip/__init__.py
M Lib/test/test_ensurepip.py
M Misc/ACKS

diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
index 948f34092435a..7c5baf0b5f1a7 100644
--- a/Lib/ensurepip/__init__.py
+++ b/Lib/ensurepip/__init__.py
@@ -114,7 +114,7 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
             additional_paths.append(os.path.join(tmpdir, wheel_name))
 
         # Construct the arguments to be passed to the pip command
-        args = ["install", "--no-index", "--find-links", tmpdir]
+        args = ["install", "--no-cache-dir", "--no-index", "--find-links", tmpdir]
         if root:
             args += ["--root", root]
         if upgrade:
diff --git a/Lib/test/test_ensurepip.py b/Lib/test/test_ensurepip.py
index 8996689309285..4786d28f39a3d 100644
--- a/Lib/test/test_ensurepip.py
+++ b/Lib/test/test_ensurepip.py
@@ -40,7 +40,7 @@ def test_basic_bootstrapping(self):
 
         self.run_pip.assert_called_once_with(
             [
-                "install", "--no-index", "--find-links",
+                "install", "--no-cache-dir", "--no-index", "--find-links",
                 unittest.mock.ANY, "setuptools", "pip",
             ],
             unittest.mock.ANY,
@@ -54,7 +54,7 @@ def test_bootstrapping_with_root(self):
 
         self.run_pip.assert_called_once_with(
             [
-                "install", "--no-index", "--find-links",
+                "install", "--no-cache-dir", "--no-index", "--find-links",
                 unittest.mock.ANY, "--root", "/foo/bar/",
                 "setuptools", "pip",
             ],
@@ -66,7 +66,7 @@ def test_bootstrapping_with_user(self):
 
         self.run_pip.assert_called_once_with(
             [
-                "install", "--no-index", "--find-links",
+                "install", "--no-cache-dir", "--no-index", "--find-links",
                 unittest.mock.ANY, "--user", "setuptools", "pip",
             ],
             unittest.mock.ANY,
@@ -77,7 +77,7 @@ def test_bootstrapping_with_upgrade(self):
 
         self.run_pip.assert_called_once_with(
             [
-                "install", "--no-index", "--find-links",
+                "install", "--no-cache-dir", "--no-index", "--find-links",
                 unittest.mock.ANY, "--upgrade", "setuptools", "pip",
             ],
             unittest.mock.ANY,
@@ -88,7 +88,7 @@ def test_bootstrapping_with_verbosity_1(self):
 
         self.run_pip.assert_called_once_with(
             [
-                "install", "--no-index", "--find-links",
+                "install", "--no-cache-dir", "--no-index", "--find-links",
                 unittest.mock.ANY, "-v", "setuptools", "pip",
             ],
             unittest.mock.ANY,
@@ -99,7 +99,7 @@ def test_bootstrapping_with_verbosity_2(self):
 
         self.run_pip.assert_called_once_with(
             [
-                "install", "--no-index", "--find-links",
+                "install", "--no-cache-dir", "--no-index", "--find-links",
                 unittest.mock.ANY, "-vv", "setuptools", "pip",
             ],
             unittest.mock.ANY,
@@ -110,7 +110,7 @@ def test_bootstrapping_with_verbosity_3(self):
 
         self.run_pip.assert_called_once_with(
             [
-                "install", "--no-index", "--find-links",
+                "install", "--no-cache-dir", "--no-index", "--find-links",
                 unittest.mock.ANY, "-vvv", "setuptools", "pip",
             ],
             unittest.mock.ANY,
@@ -260,7 +260,7 @@ def test_basic_bootstrapping(self):
 
         self.run_pip.assert_called_once_with(
             [
-                "install", "--no-index", "--find-links",
+                "install", "--no-cache-dir", "--no-index", "--find-links",
                 unittest.mock.ANY, "setuptools", "pip",
             ],
             unittest.mock.ANY,
diff --git a/Misc/ACKS b/Misc/ACKS
index a6da4f1289828..a893fdce0e9ac 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -860,6 +860,7 @@ Vajrasky Kok
 Guido Kollerie
 Jacek Kołodziej
 Jacek Konieczny
+Krzysztof Konopko
 Arkady Koplyarov
 Peter A. Koren
 Марк Коренберг
diff --git a/Misc/NEWS.d/next/Library/2020-06-15-12-22-53.bpo-40448.1dk8Bu.rst b/Misc/NEWS.d/next/Library/2020-06-15-12-22-53.bpo-40448.1dk8Bu.rst
new file mode 100644
index 0000000000000..a755c5faa671c
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-06-15-12-22-53.bpo-40448.1dk8Bu.rst
@@ -0,0 +1,2 @@
+:mod:`ensurepip` now disables the use of `pip` cache when installing the
+bundled versions of `pip` and `setuptools`.  Patch by Krzysztof Konopko.



More information about the Python-checkins mailing list