Skip to content

Commit deb0aa8

Browse files
committed
Merge branch 'main' of https://github.com/pypa/setuptools into pkg_resources-explicit-public-return-annotations
2 parents e402f44 + 48f95c0 commit deb0aa8

12 files changed

+72
-50
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 71.0.0
2+
current_version = 71.0.4
33
commit = True
44
tag = True
55

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ recursive-include setuptools *.py *.exe *.xml *.tmpl
22
recursive-include tests *.py
33
recursive-include setuptools/tests *.html
44
recursive-include docs *.py *.txt *.rst *.conf *.css *.css_t Makefile indexsidebar.html
5-
recursive-include setuptools/_vendor *.py *.txt
5+
recursive-include setuptools/_vendor *
66
recursive-include pkg_resources *.py *.txt
77
recursive-include pkg_resources/tests/data *
88
recursive-include tools *

NEWS.rst

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,46 @@
1+
v71.0.4
2+
=======
3+
4+
Bugfixes
5+
--------
6+
7+
- Removed lingering unused code around Distribution._patched_dist. (#4489)
8+
9+
10+
v71.0.3
11+
=======
12+
13+
Bugfixes
14+
--------
15+
16+
- Reset the backports module when enabling vendored packages. (#4476)
17+
18+
19+
v71.0.2
20+
=======
21+
22+
Bugfixes
23+
--------
24+
25+
- Include all vendored files in the sdist. (#4480)
26+
27+
28+
v71.0.1
29+
=======
30+
31+
Bugfixes
32+
--------
33+
34+
- Restored package data that went missing in 71.0. This change also incidentally causes tests to be installed once again. (#4475)
35+
36+
137
v71.0.0
238
=======
339

440
Deprecations and Removals
541
-------------------------
642

7-
- Now setuptools declares its own dependencies in the ``core`` extra. Dependencies are still vendored for bootstrapping purposes, but setuptools will prefer installed dependencies if present. The ``core`` extra is used for informational purposes and should *not* be declared in package metadata (e.g. ``build-requires``). Downstream packagers can de-vendor by simply removing the ``setuptools/_vendor`` directory. (#2825)
43+
- Now setuptools declares its own dependencies in the ``core`` extra. Dependencies are still vendored for bootstrapping purposes, but setuptools will prefer installed dependencies if present. The ``core`` extra is used for informational purposes and should *not* be declared in package metadata (e.g. ``build-requires``). Downstream packagers can de-vendor by simply removing the ``setuptools/_vendor`` directory. Since Setuptools now prefers installed dependencies, those installing to an environment with old, incompatible dependencies will not work. In that case, either uninstall the incompatible dependencies or upgrade them to satisfy those declared in ``core``. (#2825)
844

945

1046
v70.3.0

pkg_resources/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
import _imp
7777

7878
sys.path.extend(((vendor_path := os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setuptools', '_vendor')) not in sys.path) * [vendor_path]) # fmt: skip
79+
# workaround for #4476
80+
sys.modules.pop('backports', None)
7981

8082
# capture these to bypass sandboxing
8183
from os import utime
@@ -103,7 +105,7 @@
103105
from platformdirs import user_cache_dir as _user_cache_dir
104106

105107
if TYPE_CHECKING:
106-
from _typeshed import StrPath, BytesPath, StrOrBytesPath
108+
from _typeshed import BytesPath, StrPath, StrOrBytesPath
107109
from typing_extensions import Self
108110

109111
warnings.warn(
@@ -2647,6 +2649,7 @@ def _normalize_cached(filename: StrPath) -> str: ...
26472649
@overload
26482650
def _normalize_cached(filename: BytesPath) -> bytes: ...
26492651
def _normalize_cached(filename: StrOrBytesPath) -> str | bytes: ...
2652+
26502653
else:
26512654

26522655
@functools.lru_cache(maxsize=None)

pyproject.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ backend-path = ["."]
55

66
[project]
77
name = "setuptools"
8-
version = "71.0.0"
8+
version = "71.0.4"
99
authors = [
1010
{ name = "Python Packaging Authority", email = "[email protected]" },
1111
]
@@ -175,9 +175,7 @@ PKG-INFO = "setuptools.command.egg_info:write_pkg_info"
175175
"dependency_links.txt" = "setuptools.command.egg_info:overwrite_arg"
176176

177177
[tool.setuptools]
178-
# disabled as it causes tests to be included #2505
179-
# include_package_data = true
180-
include-package-data = false
178+
include-package-data = true
181179

182180
[tool.setuptools.packages.find]
183181
include = [
@@ -191,10 +189,6 @@ exclude = [
191189
]
192190
namespaces = true
193191

194-
[tool.setuptools.package-data]
195-
# ensure that `setuptools/_vendor/jaraco/text/Lorem ipsum.txt` is installed
196-
"*" = ["*.txt"]
197-
198192
[tool.distutils.sdist]
199193
formats = "zip"
200194

pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ addopts=
44
--doctest-modules
55
--import-mode importlib
66
--doctest-glob=pkg_resources/api_tests.txt
7-
-r sxX
87
consider_namespace_packages=true
98
filterwarnings=
109
# Fail on warnings

ruff.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exclude = [
77
[lint]
88
extend-select = [
99
"C901",
10+
"PERF401",
1011
"W",
1112

1213
# local
@@ -51,12 +52,16 @@ ignore = [
5152
# Only enforcing return type annotations for public modules
5253
"**/tests/**" = ["ANN2"]
5354
"tools/**" = ["ANN2"]
55+
# Suppress nuisance warnings about module-import-not-at-top-of-file (E402) due to workaround for #4476
56+
"setuptools/__init__.py" = ["E402"]
57+
"pkg_resources/__init__.py" = ["E402"]
5458

5559
[lint.flake8-annotations]
5660
ignore-fully-untyped = true
5761

5862
[format]
59-
# Enable preview to get hugged parenthesis unwrapping
63+
# Enable preview to get hugged parenthesis unwrapping and other nice surprises
64+
# See https://github.com/jaraco/skeleton/pull/133#issuecomment-2239538373
6065
preview = true
61-
# https://docs.astral.sh/ruff/settings/#format-quote-style
66+
# https://docs.astral.sh/ruff/settings/#format_quote-style
6267
quote-style = "preserve"

setuptools/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from typing import TYPE_CHECKING
88

99
sys.path.extend(((vendor_path := os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setuptools', '_vendor')) not in sys.path) * [vendor_path]) # fmt: skip
10+
# workaround for #4476
11+
sys.modules.pop('backports', None)
1012

1113
import _distutils_hack.override # noqa: F401
1214
import distutils.core

setuptools/command/egg_info.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,17 +250,6 @@ def finalize_options(self):
250250
#
251251
self.distribution.metadata.version = self.egg_version
252252

253-
# If we bootstrapped around the lack of a PKG-INFO, as might be the
254-
# case in a fresh checkout, make sure that any special tags get added
255-
# to the version info
256-
#
257-
pd = self.distribution._patched_dist
258-
key = getattr(pd, "key", None) or getattr(pd, "name", None)
259-
if pd is not None and key == self.egg_name.lower():
260-
pd._version = self.egg_version
261-
pd._parsed_version = packaging.version.Version(self.egg_version)
262-
self.distribution._patched_dist = None
263-
264253
def _get_egg_basename(self, py_version=PY_MAJOR, platform=None):
265254
"""Compute filename of the output egg. Private API."""
266255
return _egg_basename(self.egg_name, self.egg_version, py_version, platform)

setuptools/dist.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import os
77
import re
88
import sys
9-
from contextlib import suppress
109
from glob import iglob
1110
from pathlib import Path
1211
from typing import TYPE_CHECKING, MutableMapping
@@ -28,7 +27,6 @@
2827
from packaging.version import Version
2928

3029
from . import _entry_points
31-
from . import _normalization
3230
from . import _reqs
3331
from . import command as _ # noqa -- imported for side-effects
3432
from ._importlib import metadata
@@ -269,24 +267,9 @@ class Distribution(_Distribution):
269267
'extras_require': dict,
270268
}
271269

272-
_patched_dist = None
273270
# Used by build_py, editable_wheel and install_lib commands for legacy namespaces
274271
namespace_packages: list[str] #: :meta private: DEPRECATED
275272

276-
def patch_missing_pkg_info(self, attrs):
277-
# Fake up a replacement for the data that would normally come from
278-
# PKG-INFO, but which might not yet be built if this is a fresh
279-
# checkout.
280-
#
281-
if not attrs or 'name' not in attrs or 'version' not in attrs:
282-
return
283-
name = _normalization.safe_name(str(attrs['name'])).lower()
284-
with suppress(metadata.PackageNotFoundError):
285-
dist = metadata.distribution(name)
286-
if dist is not None and not dist.read_text('PKG-INFO'):
287-
dist._version = _normalization.safe_version(str(attrs['version']))
288-
self._patched_dist = dist
289-
290273
def __init__(self, attrs: MutableMapping | None = None) -> None:
291274
have_package_data = hasattr(self, "package_data")
292275
if not have_package_data:
@@ -295,7 +278,6 @@ def __init__(self, attrs: MutableMapping | None = None) -> None:
295278
self.dist_files: list[tuple[str, str, str]] = []
296279
# Filter-out setuptools' specific options.
297280
self.src_root = attrs.pop("src_root", None)
298-
self.patch_missing_pkg_info(attrs)
299281
self.dependency_links = attrs.pop('dependency_links', [])
300282
self.setup_requires = attrs.pop('setup_requires', [])
301283
for ep in metadata.entry_points(group='distutils.setup_keywords'):

setuptools/tests/config/test_apply_pyprojecttoml.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from inspect import cleandoc
1313
from pathlib import Path
1414
from unittest.mock import Mock
15-
from zipfile import ZipFile
1615

1716
import pytest
1817
from ini2toml.api import LiteTranslator
@@ -422,11 +421,6 @@ def test_example_file_in_sdist(self, setuptools_sdist):
422421
with tarfile.open(setuptools_sdist) as tar:
423422
assert any(name.endswith(EXAMPLES_FILE) for name in tar.getnames())
424423

425-
def test_example_file_not_in_wheel(self, setuptools_wheel):
426-
"""Meta test to ensure auxiliary test files are not in wheel"""
427-
with ZipFile(setuptools_wheel) as zipfile:
428-
assert not any(name.endswith(EXAMPLES_FILE) for name in zipfile.namelist())
429-
430424

431425
class TestInteropCommandLineParsing:
432426
def test_version(self, tmp_path, monkeypatch, capsys):

setuptools/tests/test_setuptools.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tests for the 'setuptools' package"""
22

3+
import re
34
import sys
45
import os
56
import distutils.core
@@ -301,9 +302,26 @@ def test_findall_missing_symlink(tmpdir, can_symlink):
301302
assert found == []
302303

303304

305+
@pytest.mark.xfail(reason="unable to exclude tests; #4475 #3260")
304306
def test_its_own_wheel_does_not_contain_tests(setuptools_wheel):
305307
with ZipFile(setuptools_wheel) as zipfile:
306308
contents = [f.replace(os.sep, '/') for f in zipfile.namelist()]
307309

308310
for member in contents:
309311
assert '/tests/' not in member
312+
313+
314+
def test_wheel_includes_cli_scripts(setuptools_wheel):
315+
with ZipFile(setuptools_wheel) as zipfile:
316+
contents = [f.replace(os.sep, '/') for f in zipfile.namelist()]
317+
318+
assert any('cli-64.exe' in member for member in contents)
319+
320+
321+
def test_wheel_includes_vendored_metadata(setuptools_wheel):
322+
with ZipFile(setuptools_wheel) as zipfile:
323+
contents = [f.replace(os.sep, '/') for f in zipfile.namelist()]
324+
325+
assert any(
326+
re.search(r'_vendor/.*\.dist-info/METADATA', member) for member in contents
327+
)

0 commit comments

Comments
 (0)