Skip to content

Commit 85d5bd3

Browse files
committed
Merge branch 'main' into feature/importlib-metadata-6.4.1
2 parents 198537e + 4e04393 commit 85d5bd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+579
-316
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Lib/test/xmltestdata/* noeol
3434

3535
# Shell scripts should have LF even on Windows because of Cygwin
3636
Lib/venv/scripts/common/activate text eol=lf
37+
Lib/venv/scripts/posix/* text eol=lf
3738

3839
# CRLF files
3940
[attr]dos text eol=crlf

.github/workflows/project-updater.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
# if an issue has any of these labels, it will be added
2121
# to the corresponding project
2222
- { project: 2, label: "release-blocker, deferred-blocker" }
23-
- { project: 3, label: expert-subinterpreters }
24-
- { project: 29, label: expert-asyncio }
2523
- { project: 32, label: sprint }
2624

2725
steps:

.github/workflows/verify-ensurepip-wheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Verify bundled pip and setuptools
1+
name: Verify bundled wheels
22

33
on:
44
workflow_dispatch:
@@ -29,5 +29,5 @@ jobs:
2929
- uses: actions/setup-python@v4
3030
with:
3131
python-version: '3'
32-
- name: Compare checksums of bundled pip and setuptools to ones published on PyPI
32+
- name: Compare checksum of bundled wheels to the ones published on PyPI
3333
run: ./Tools/build/verify_ensurepip_wheels.py

Doc/conf.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,14 @@
254254
# Options for the link checker
255255
# ----------------------------
256256

257-
# Ignore certain URLs.
258-
linkcheck_ignore = [r'https://bugs.python.org/(issue)?\d+']
259-
257+
linkcheck_allowed_redirects = {
258+
# bpo-NNNN -> BPO -> GH Issues
259+
r'https://bugs.python.org/issue\?@action=redirect&bpo=\d+': 'https://github.com/python/cpython/issues/\d+',
260+
# GH-NNNN used to refer to pull requests
261+
r'https://github.com/python/cpython/issues/\d+': 'https://github.com/python/cpython/pull/\d+',
262+
# :source:`something` linking files in the repository
263+
r'https://github.com/python/cpython/tree/.*': 'https://github.com/python/cpython/blob/.*'
264+
}
260265

261266
# Options for extensions
262267
# ----------------------

Doc/library/optparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ Features of note:
20272027
values.ensure_value(attr, value)
20282028

20292029
If the ``attr`` attribute of ``values`` doesn't exist or is ``None``, then
2030-
ensure_value() first sets it to ``value``, and then returns 'value. This is
2030+
ensure_value() first sets it to ``value``, and then returns ``value``. This is
20312031
very handy for actions like ``"extend"``, ``"append"``, and ``"count"``, all
20322032
of which accumulate data in a variable and expect that variable to be of a
20332033
certain type (a list for the first two, an integer for the latter). Using

Doc/library/string.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@ Some simple format string examples::
254254
"Units destroyed: {players[0]}" # First element of keyword argument 'players'.
255255

256256
The *conversion* field causes a type coercion before formatting. Normally, the
257-
job of formatting a value is done by the :meth:`__format__` method of the value
257+
job of formatting a value is done by the :meth:`~object.__format__` method of the value
258258
itself. However, in some cases it is desirable to force a type to be formatted
259259
as a string, overriding its own definition of formatting. By converting the
260-
value to a string before calling :meth:`__format__`, the normal formatting logic
260+
value to a string before calling :meth:`~object.__format__`, the normal formatting logic
261261
is bypassed.
262262

263263
Three conversion flags are currently supported: ``'!s'`` which calls :func:`str`

Doc/library/venv.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,14 @@ creation according to their needs, the :class:`EnvBuilder` class.
284284

285285
.. method:: upgrade_dependencies(context)
286286

287-
Upgrades the core venv dependency packages (currently ``pip`` and
288-
``setuptools``) in the environment. This is done by shelling out to the
287+
Upgrades the core venv dependency packages (currently ``pip``)
288+
in the environment. This is done by shelling out to the
289289
``pip`` executable in the environment.
290290

291291
.. versionadded:: 3.9
292+
.. versionchanged:: 3.12
293+
294+
``setuptools`` is no longer a core venv dependency.
292295

293296
.. method:: post_setup(context)
294297

Doc/using/venv-create.inc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,16 @@ The command, if run with ``-h``, will show the available options::
6161
environment (pip is bootstrapped by default)
6262
--prompt PROMPT Provides an alternative prompt prefix for this
6363
environment.
64-
--upgrade-deps Upgrade core dependencies: pip setuptools to the
64+
--upgrade-deps Upgrade core dependencies (pip) to the
6565
latest version in PyPI
6666
6767
Once an environment has been created, you may wish to activate it, e.g. by
6868
sourcing an activate script in its bin directory.
6969
70+
.. versionchanged:: 3.12
71+
72+
``setuptools`` is no longer a core venv dependency.
73+
7074
.. versionchanged:: 3.9
7175
Add ``--upgrade-deps`` option to upgrade pip + setuptools to the latest on PyPI
7276
@@ -104,4 +108,3 @@ invoked to bootstrap ``pip`` into the virtual environment.
104108
Multiple paths can be given to ``venv``, in which case an identical virtual
105109
environment will be created, according to the given options, at each provided
106110
path.
107-

Doc/whatsnew/3.12.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ csv
258258

259259
* Add :data:`~csv.QUOTE_NOTNULL` and :data:`~csv.QUOTE_STRINGS` flags to
260260
provide finer grained control of ``None`` and empty strings by
261-
:class:`~csv.reader` and :class:`~csv.writer` objects.
261+
:class:`~csv.writer` objects.
262262

263263
inspect
264264
-------
@@ -731,6 +731,24 @@ Removed
731731
project can be installed: it still provides ``distutils``.
732732
(Contributed by Victor Stinner in :gh:`92584`.)
733733

734+
* Remove the bundled setuptools wheel from :mod:`ensurepip`,
735+
and stop installing setuptools in environments created by :mod:`venv`.
736+
737+
``pip (>= 22.1)`` does not require setuptools to be installed in the
738+
environment. ``setuptools``-based (and ``distutils``-based) packages
739+
can still be used with ``pip install``, since pip will provide
740+
``setuptools`` in the build environment it uses for building a
741+
package.
742+
743+
``easy_install``, ``pkg_resources``, ``setuptools`` and ``distutils``
744+
are no longer provided by default in environments created with
745+
``venv`` or bootstrapped with ``ensurepip``, since they are part of
746+
the ``setuptools`` package. For projects relying on these at runtime,
747+
the ``setuptools`` project should be declared as a dependency and
748+
installed separately (typically, using pip).
749+
750+
(Contributed by Pradyun Gedam in :gh:`95299`.)
751+
734752
* Removed many old deprecated :mod:`unittest` features:
735753

736754
- A number of :class:`~unittest.TestCase` method aliases:

Lib/dataclasses.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,8 +1128,13 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen,
11281128

11291129
if not getattr(cls, '__doc__'):
11301130
# Create a class doc-string.
1131-
cls.__doc__ = (cls.__name__ +
1132-
str(inspect.signature(cls)).replace(' -> None', ''))
1131+
try:
1132+
# In some cases fetching a signature is not possible.
1133+
# But, we surely should not fail in this case.
1134+
text_sig = str(inspect.signature(cls)).replace(' -> None', '')
1135+
except (TypeError, ValueError):
1136+
text_sig = ''
1137+
cls.__doc__ = (cls.__name__ + text_sig)
11331138

11341139
if match_args:
11351140
# I could probably compute this once

Lib/ensurepip/__init__.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99

1010

1111
__all__ = ["version", "bootstrap"]
12-
_PACKAGE_NAMES = ('setuptools', 'pip')
13-
_SETUPTOOLS_VERSION = "65.5.0"
12+
_PACKAGE_NAMES = ('pip',)
1413
_PIP_VERSION = "23.0.1"
1514
_PROJECTS = [
16-
("setuptools", _SETUPTOOLS_VERSION, "py3"),
1715
("pip", _PIP_VERSION, "py3"),
1816
]
1917

@@ -153,17 +151,17 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
153151

154152
_disable_pip_configuration_settings()
155153

156-
# By default, installing pip and setuptools installs all of the
154+
# By default, installing pip installs all of the
157155
# following scripts (X.Y == running Python version):
158156
#
159-
# pip, pipX, pipX.Y, easy_install, easy_install-X.Y
157+
# pip, pipX, pipX.Y
160158
#
161159
# pip 1.5+ allows ensurepip to request that some of those be left out
162160
if altinstall:
163-
# omit pip, pipX and easy_install
161+
# omit pip, pipX
164162
os.environ["ENSUREPIP_OPTIONS"] = "altinstall"
165163
elif not default_pip:
166-
# omit pip and easy_install
164+
# omit pip
167165
os.environ["ENSUREPIP_OPTIONS"] = "install"
168166

169167
with tempfile.TemporaryDirectory() as tmpdir:
@@ -271,14 +269,14 @@ def _main(argv=None):
271269
action="store_true",
272270
default=False,
273271
help=("Make an alternate install, installing only the X.Y versioned "
274-
"scripts (Default: pipX, pipX.Y, easy_install-X.Y)."),
272+
"scripts (Default: pipX, pipX.Y)."),
275273
)
276274
parser.add_argument(
277275
"--default-pip",
278276
action="store_true",
279277
default=False,
280278
help=("Make a default pip install, installing the unqualified pip "
281-
"and easy_install in addition to the versioned scripts."),
279+
"in addition to the versioned scripts."),
282280
)
283281

284282
args = parser.parse_args(argv)
Binary file not shown.

Lib/test/test_dataclasses.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,6 +2297,19 @@ class C:
22972297

22982298
self.assertDocStrEqual(C.__doc__, "C(x:collections.deque=<factory>)")
22992299

2300+
def test_docstring_with_no_signature(self):
2301+
# See https://github.com/python/cpython/issues/103449
2302+
class Meta(type):
2303+
__call__ = dict
2304+
class Base(metaclass=Meta):
2305+
pass
2306+
2307+
@dataclass
2308+
class C(Base):
2309+
pass
2310+
2311+
self.assertDocStrEqual(C.__doc__, "C")
2312+
23002313

23012314
class TestInit(unittest.TestCase):
23022315
def test_base_has_init(self):

Lib/test/test_ensurepip.py

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def test_version(self):
2020
# Test version()
2121
with tempfile.TemporaryDirectory() as tmpdir:
2222
self.touch(tmpdir, "pip-1.2.3b1-py2.py3-none-any.whl")
23-
self.touch(tmpdir, "setuptools-49.1.3-py3-none-any.whl")
2423
with (unittest.mock.patch.object(ensurepip, '_PACKAGES', None),
2524
unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', tmpdir)):
2625
self.assertEqual(ensurepip.version(), '1.2.3b1')
@@ -36,15 +35,12 @@ def test_get_packages_no_dir(self):
3635

3736
# use bundled wheel packages
3837
self.assertIsNotNone(packages['pip'].wheel_name)
39-
self.assertIsNotNone(packages['setuptools'].wheel_name)
4038

4139
def test_get_packages_with_dir(self):
4240
# Test _get_packages() with a wheel package directory
43-
setuptools_filename = "setuptools-49.1.3-py3-none-any.whl"
4441
pip_filename = "pip-20.2.2-py2.py3-none-any.whl"
4542

4643
with tempfile.TemporaryDirectory() as tmpdir:
47-
self.touch(tmpdir, setuptools_filename)
4844
self.touch(tmpdir, pip_filename)
4945
# not used, make sure that it's ignored
5046
self.touch(tmpdir, "wheel-0.34.2-py2.py3-none-any.whl")
@@ -53,15 +49,12 @@ def test_get_packages_with_dir(self):
5349
unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', tmpdir)):
5450
packages = ensurepip._get_packages()
5551

56-
self.assertEqual(packages['setuptools'].version, '49.1.3')
57-
self.assertEqual(packages['setuptools'].wheel_path,
58-
os.path.join(tmpdir, setuptools_filename))
5952
self.assertEqual(packages['pip'].version, '20.2.2')
6053
self.assertEqual(packages['pip'].wheel_path,
6154
os.path.join(tmpdir, pip_filename))
6255

6356
# wheel package is ignored
64-
self.assertEqual(sorted(packages), ['pip', 'setuptools'])
57+
self.assertEqual(sorted(packages), ['pip'])
6558

6659

6760
class EnsurepipMixin:
@@ -92,13 +85,13 @@ def test_basic_bootstrapping(self):
9285
self.run_pip.assert_called_once_with(
9386
[
9487
"install", "--no-cache-dir", "--no-index", "--find-links",
95-
unittest.mock.ANY, "setuptools", "pip",
88+
unittest.mock.ANY, "pip",
9689
],
9790
unittest.mock.ANY,
9891
)
9992

10093
additional_paths = self.run_pip.call_args[0][1]
101-
self.assertEqual(len(additional_paths), 2)
94+
self.assertEqual(len(additional_paths), 1)
10295

10396
def test_bootstrapping_with_root(self):
10497
ensurepip.bootstrap(root="/foo/bar/")
@@ -107,7 +100,7 @@ def test_bootstrapping_with_root(self):
107100
[
108101
"install", "--no-cache-dir", "--no-index", "--find-links",
109102
unittest.mock.ANY, "--root", "/foo/bar/",
110-
"setuptools", "pip",
103+
"pip",
111104
],
112105
unittest.mock.ANY,
113106
)
@@ -118,7 +111,7 @@ def test_bootstrapping_with_user(self):
118111
self.run_pip.assert_called_once_with(
119112
[
120113
"install", "--no-cache-dir", "--no-index", "--find-links",
121-
unittest.mock.ANY, "--user", "setuptools", "pip",
114+
unittest.mock.ANY, "--user", "pip",
122115
],
123116
unittest.mock.ANY,
124117
)
@@ -129,7 +122,7 @@ def test_bootstrapping_with_upgrade(self):
129122
self.run_pip.assert_called_once_with(
130123
[
131124
"install", "--no-cache-dir", "--no-index", "--find-links",
132-
unittest.mock.ANY, "--upgrade", "setuptools", "pip",
125+
unittest.mock.ANY, "--upgrade", "pip",
133126
],
134127
unittest.mock.ANY,
135128
)
@@ -140,7 +133,7 @@ def test_bootstrapping_with_verbosity_1(self):
140133
self.run_pip.assert_called_once_with(
141134
[
142135
"install", "--no-cache-dir", "--no-index", "--find-links",
143-
unittest.mock.ANY, "-v", "setuptools", "pip",
136+
unittest.mock.ANY, "-v", "pip",
144137
],
145138
unittest.mock.ANY,
146139
)
@@ -151,7 +144,7 @@ def test_bootstrapping_with_verbosity_2(self):
151144
self.run_pip.assert_called_once_with(
152145
[
153146
"install", "--no-cache-dir", "--no-index", "--find-links",
154-
unittest.mock.ANY, "-vv", "setuptools", "pip",
147+
unittest.mock.ANY, "-vv", "pip",
155148
],
156149
unittest.mock.ANY,
157150
)
@@ -162,7 +155,7 @@ def test_bootstrapping_with_verbosity_3(self):
162155
self.run_pip.assert_called_once_with(
163156
[
164157
"install", "--no-cache-dir", "--no-index", "--find-links",
165-
unittest.mock.ANY, "-vvv", "setuptools", "pip",
158+
unittest.mock.ANY, "-vvv", "pip",
166159
],
167160
unittest.mock.ANY,
168161
)
@@ -239,7 +232,6 @@ def test_uninstall(self):
239232
self.run_pip.assert_called_once_with(
240233
[
241234
"uninstall", "-y", "--disable-pip-version-check", "pip",
242-
"setuptools",
243235
]
244236
)
245237

@@ -250,7 +242,6 @@ def test_uninstall_with_verbosity_1(self):
250242
self.run_pip.assert_called_once_with(
251243
[
252244
"uninstall", "-y", "--disable-pip-version-check", "-v", "pip",
253-
"setuptools",
254245
]
255246
)
256247

@@ -261,7 +252,6 @@ def test_uninstall_with_verbosity_2(self):
261252
self.run_pip.assert_called_once_with(
262253
[
263254
"uninstall", "-y", "--disable-pip-version-check", "-vv", "pip",
264-
"setuptools",
265255
]
266256
)
267257

@@ -272,7 +262,7 @@ def test_uninstall_with_verbosity_3(self):
272262
self.run_pip.assert_called_once_with(
273263
[
274264
"uninstall", "-y", "--disable-pip-version-check", "-vvv",
275-
"pip", "setuptools",
265+
"pip"
276266
]
277267
)
278268

@@ -312,13 +302,13 @@ def test_basic_bootstrapping(self):
312302
self.run_pip.assert_called_once_with(
313303
[
314304
"install", "--no-cache-dir", "--no-index", "--find-links",
315-
unittest.mock.ANY, "setuptools", "pip",
305+
unittest.mock.ANY, "pip",
316306
],
317307
unittest.mock.ANY,
318308
)
319309

320310
additional_paths = self.run_pip.call_args[0][1]
321-
self.assertEqual(len(additional_paths), 2)
311+
self.assertEqual(len(additional_paths), 1)
322312
self.assertEqual(exit_code, 0)
323313

324314
def test_bootstrapping_error_code(self):
@@ -344,7 +334,6 @@ def test_basic_uninstall(self):
344334
self.run_pip.assert_called_once_with(
345335
[
346336
"uninstall", "-y", "--disable-pip-version-check", "pip",
347-
"setuptools",
348337
]
349338
)
350339

0 commit comments

Comments
 (0)