10000 bpo-40448: ensurepip: Do not use cache (GH-19812) · python/cpython@4a3a682 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a3a682

Browse files
author
Krzysztof Konopko
authored
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.
1 parent bf69a8f commit 4a3a682

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

Lib/ensurepip/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
119119
additional_paths.append(os.path.join(tmpdir, wheel_name))
120120

121121
# Construct the arguments to be passed to the pip command
122-
args = ["install", "--no-index", "--find-links", tmpdir]
122+
args = ["install", "--no-cache-dir", "--no-index", "--find-links", tmpdir]
123123
if root:
124124
args += ["--root", root]
125125
if upgrade:

Lib/test/test_ensurepip.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_basic_bootstrapping(self):
4040

4141
self.run_pip.assert_called_once_with(
4242
[
43-
"install", "--no-index", "--find-links",
43+
"install", "--no-cache-dir", "--no-index", "--find-links",
4444
unittest.mock.ANY, "setuptools", "pip",
4545
],
4646
unittest.mock.ANY,
@@ -54,7 +54,7 @@ def test_bootstrapping_with_root(self):
5454

5555
self.run_pip.assert_called_once_with(
5656
[
57-
"install", "--no-index", "--find-links",
57+
"install", "--no-cache-dir", "--no-index", "--find-links",
5858
unittest.mock.ANY, "--root", "/foo/bar/",
5959
"setuptools", "pip",
6060
],
@@ -66,7 +66,7 @@ def test_bootstrapping_with_user(self):
6666

6767
self.run_pip.assert_called_once_with(
6868
[
69-
"install", "--no-index", "--find-links",
69+
"install", "--no-cache-dir", "--no-index", "--find-links",
7070
unittest.mock.ANY, "--user", "setuptools", "pip",
7171
],
7272
unittest.mock.ANY,
@@ -77,7 +77,7 @@ def test_bootstrapping_with_upgrade(self):
7777

7878
self.run_pip.assert_called_once_with(
7979
[
80-
"install", "--no-index", "--find-links",
80+
"install", "--no-cache-dir", "--no-index", "--find-links",
8181
unittest.mock.ANY, "--upgrade", "setuptools", "pip",
8282
],
8383
unittest.mock.ANY,
@@ -88,7 +88,7 @@ def test_bootstrapping_with_verbosity_1(self):
8888

8989
self.run_pip.assert_called_once_with(
9090
[
91-
"install", "--no-index", "--find-links",
91+
"install", "--no-cache-dir", "--no-index", "--find-links",
9292
unittest.mock.ANY, "-v", "setuptools", "pip",
9393
],
9494
unittest.mock.ANY,
@@ -99,7 +99,7 @@ def test_bootstrapping_with_verbosity_2(self):
9999

100100
self.run_pip.assert_called_once_with(
101101
[
102-
"install", "--no-index", "--find-links",
102+
"install", "--no-cache-dir", "--no-index", "--find-links",
103103
unittest.mock.ANY, "-vv", "setuptools", "pip",
104104
],
105105
unittest.mock.ANY,
@@ -110,7 +110,7 @@ def test_bootstrapping_with_verbosity_3(self):
110110

111111
self.run_pip.assert_called_once_with(
112112
[
113-
"install", "--no-index", "--find-links",
113+
"install", "--no-cache-dir", "--no-index", "--find-links",
114114
unittest.mock.ANY, "-vvv", "setuptools", "pip",
115115
],
116116
unittest.mock.ANY,
@@ -260,7 +260,7 @@ def test_basic_bootstrapping(self):
260260

261261
self.run_pip.assert_called_once_with(
262262
[
263-
"install", "--no-index", "--find-links",
263+
"install", "--no-cache-dir", "--no-index", "--find-links",
264264
unittest.mock.ANY, "setuptools", "pip",
265265
],
266266
unittest.mock.ANY,

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ Vajrasky Kok
910910
Guido Kollerie
911911
Jacek Kołodziej
912912
Jacek Konieczny
913+
Krzysztof Konopko
913914
Arkady Koplyarov
914915
Peter A. Koren
915916
Марк Коренберг
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:mod:`ensurepip` now disables the use of `pip` cache when installing the
2+
bundled versions of `pip` and `setuptools`. Patch by Krzysztof Konopko.

0 commit comments

Comments
 (0)
0