gh-95299: Stop installing setuptools as a part of ensurepip and venv … · python/cpython@ece20db (original) (raw)
`@@ -20,7 +20,6 @@ def test_version(self):
`
20
20
`# Test version()
`
21
21
`with tempfile.TemporaryDirectory() as tmpdir:
`
22
22
`self.touch(tmpdir, "pip-1.2.3b1-py2.py3-none-any.whl")
`
23
``
`-
self.touch(tmpdir, "setuptools-49.1.3-py3-none-any.whl")
`
24
23
`with (unittest.mock.patch.object(ensurepip, '_PACKAGES', None),
`
25
24
`unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', tmpdir)):
`
26
25
`self.assertEqual(ensurepip.version(), '1.2.3b1')
`
`@@ -36,15 +35,12 @@ def test_get_packages_no_dir(self):
`
36
35
``
37
36
`# use bundled wheel packages
`
38
37
`self.assertIsNotNone(packages['pip'].wheel_name)
`
39
``
`-
self.assertIsNotNone(packages['setuptools'].wheel_name)
`
40
38
``
41
39
`def test_get_packages_with_dir(self):
`
42
40
`# Test _get_packages() with a wheel package directory
`
43
``
`-
setuptools_filename = "setuptools-49.1.3-py3-none-any.whl"
`
44
41
`pip_filename = "pip-20.2.2-py2.py3-none-any.whl"
`
45
42
``
46
43
`with tempfile.TemporaryDirectory() as tmpdir:
`
47
``
`-
self.touch(tmpdir, setuptools_filename)
`
48
44
`self.touch(tmpdir, pip_filename)
`
49
45
`# not used, make sure that it's ignored
`
50
46
`self.touch(tmpdir, "wheel-0.34.2-py2.py3-none-any.whl")
`
`@@ -53,15 +49,12 @@ def test_get_packages_with_dir(self):
`
53
49
`unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', tmpdir)):
`
54
50
`packages = ensurepip._get_packages()
`
55
51
``
56
``
`-
self.assertEqual(packages['setuptools'].version, '49.1.3')
`
57
``
`-
self.assertEqual(packages['setuptools'].wheel_path,
`
58
``
`-
os.path.join(tmpdir, setuptools_filename))
`
59
52
`self.assertEqual(packages['pip'].version, '20.2.2')
`
60
53
`self.assertEqual(packages['pip'].wheel_path,
`
61
54
`os.path.join(tmpdir, pip_filename))
`
62
55
``
63
56
`# wheel package is ignored
`
64
``
`-
self.assertEqual(sorted(packages), ['pip', 'setuptools'])
`
``
57
`+
self.assertEqual(sorted(packages), ['pip'])
`
65
58
``
66
59
``
67
60
`class EnsurepipMixin:
`
`@@ -92,13 +85,13 @@ def test_basic_bootstrapping(self):
`
92
85
`self.run_pip.assert_called_once_with(
`
93
86
` [
`
94
87
`"install", "--no-cache-dir", "--no-index", "--find-links",
`
95
``
`-
unittest.mock.ANY, "setuptools", "pip",
`
``
88
`+
unittest.mock.ANY, "pip",
`
96
89
` ],
`
97
90
`unittest.mock.ANY,
`
98
91
` )
`
99
92
``
100
93
`additional_paths = self.run_pip.call_args[0][1]
`
101
``
`-
self.assertEqual(len(additional_paths), 2)
`
``
94
`+
self.assertEqual(len(additional_paths), 1)
`
102
95
``
103
96
`def test_bootstrapping_with_root(self):
`
104
97
`ensurepip.bootstrap(root="/foo/bar/")
`
`@@ -107,7 +100,7 @@ def test_bootstrapping_with_root(self):
`
107
100
` [
`
108
101
`"install", "--no-cache-dir", "--no-index", "--find-links",
`
109
102
`unittest.mock.ANY, "--root", "/foo/bar/",
`
110
``
`-
"setuptools", "pip",
`
``
103
`+
"pip",
`
111
104
` ],
`
112
105
`unittest.mock.ANY,
`
113
106
` )
`
`@@ -118,7 +111,7 @@ def test_bootstrapping_with_user(self):
`
118
111
`self.run_pip.assert_called_once_with(
`
119
112
` [
`
120
113
`"install", "--no-cache-dir", "--no-index", "--find-links",
`
121
``
`-
unittest.mock.ANY, "--user", "setuptools", "pip",
`
``
114
`+
unittest.mock.ANY, "--user", "pip",
`
122
115
` ],
`
123
116
`unittest.mock.ANY,
`
124
117
` )
`
`@@ -129,7 +122,7 @@ def test_bootstrapping_with_upgrade(self):
`
129
122
`self.run_pip.assert_called_once_with(
`
130
123
` [
`
131
124
`"install", "--no-cache-dir", "--no-index", "--find-links",
`
132
``
`-
unittest.mock.ANY, "--upgrade", "setuptools", "pip",
`
``
125
`+
unittest.mock.ANY, "--upgrade", "pip",
`
133
126
` ],
`
134
127
`unittest.mock.ANY,
`
135
128
` )
`
`@@ -140,7 +133,7 @@ def test_bootstrapping_with_verbosity_1(self):
`
140
133
`self.run_pip.assert_called_once_with(
`
141
134
` [
`
142
135
`"install", "--no-cache-dir", "--no-index", "--find-links",
`
143
``
`-
unittest.mock.ANY, "-v", "setuptools", "pip",
`
``
136
`+
unittest.mock.ANY, "-v", "pip",
`
144
137
` ],
`
145
138
`unittest.mock.ANY,
`
146
139
` )
`
`@@ -151,7 +144,7 @@ def test_bootstrapping_with_verbosity_2(self):
`
151
144
`self.run_pip.assert_called_once_with(
`
152
145
` [
`
153
146
`"install", "--no-cache-dir", "--no-index", "--find-links",
`
154
``
`-
unittest.mock.ANY, "-vv", "setuptools", "pip",
`
``
147
`+
unittest.mock.ANY, "-vv", "pip",
`
155
148
` ],
`
156
149
`unittest.mock.ANY,
`
157
150
` )
`
`@@ -162,7 +155,7 @@ def test_bootstrapping_with_verbosity_3(self):
`
162
155
`self.run_pip.assert_called_once_with(
`
163
156
` [
`
164
157
`"install", "--no-cache-dir", "--no-index", "--find-links",
`
165
``
`-
unittest.mock.ANY, "-vvv", "setuptools", "pip",
`
``
158
`+
unittest.mock.ANY, "-vvv", "pip",
`
166
159
` ],
`
167
160
`unittest.mock.ANY,
`
168
161
` )
`
`@@ -239,7 +232,6 @@ def test_uninstall(self):
`
239
232
`self.run_pip.assert_called_once_with(
`
240
233
` [
`
241
234
`"uninstall", "-y", "--disable-pip-version-check", "pip",
`
242
``
`-
"setuptools",
`
243
235
` ]
`
244
236
` )
`
245
237
``
`@@ -250,7 +242,6 @@ def test_uninstall_with_verbosity_1(self):
`
250
242
`self.run_pip.assert_called_once_with(
`
251
243
` [
`
252
244
`"uninstall", "-y", "--disable-pip-version-check", "-v", "pip",
`
253
``
`-
"setuptools",
`
254
245
` ]
`
255
246
` )
`
256
247
``
`@@ -261,7 +252,6 @@ def test_uninstall_with_verbosity_2(self):
`
261
252
`self.run_pip.assert_called_once_with(
`
262
253
` [
`
263
254
`"uninstall", "-y", "--disable-pip-version-check", "-vv", "pip",
`
264
``
`-
"setuptools",
`
265
255
` ]
`
266
256
` )
`
267
257
``
`@@ -272,7 +262,7 @@ def test_uninstall_with_verbosity_3(self):
`
272
262
`self.run_pip.assert_called_once_with(
`
273
263
` [
`
274
264
`"uninstall", "-y", "--disable-pip-version-check", "-vvv",
`
275
``
`-
"pip", "setuptools",
`
``
265
`+
"pip"
`
276
266
` ]
`
277
267
` )
`
278
268
``
`@@ -312,13 +302,13 @@ def test_basic_bootstrapping(self):
`
312
302
`self.run_pip.assert_called_once_with(
`
313
303
` [
`
314
304
`"install", "--no-cache-dir", "--no-index", "--find-links",
`
315
``
`-
unittest.mock.ANY, "setuptools", "pip",
`
``
305
`+
unittest.mock.ANY, "pip",
`
316
306
` ],
`
317
307
`unittest.mock.ANY,
`
318
308
` )
`
319
309
``
320
310
`additional_paths = self.run_pip.call_args[0][1]
`
321
``
`-
self.assertEqual(len(additional_paths), 2)
`
``
311
`+
self.assertEqual(len(additional_paths), 1)
`
322
312
`self.assertEqual(exit_code, 0)
`
323
313
``
324
314
`def test_bootstrapping_error_code(self):
`
`@@ -344,7 +334,6 @@ def test_basic_uninstall(self):
`
344
334
`self.run_pip.assert_called_once_with(
`
345
335
` [
`
346
336
`"uninstall", "-y", "--disable-pip-version-check", "pip",
`
347
``
`-
"setuptools",
`
348
337
` ]
`
349
338
` )
`
350
339
``