Skip to content

Commit be06d67

Browse files
authored
Merge branch 'main' into FURB
2 parents bea8c1c + d126744 commit be06d67

33 files changed

+250
-140
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 = 80.8.0
2+
current_version = 80.9.0
33
commit = True
44
tag = True
55

.github/workflows/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ jobs:
157157
if: always()
158158

159159
needs:
160+
- check-changed-folders
160161
- integration-test
161162
- test
162163
- collateral
@@ -228,6 +229,38 @@ jobs:
228229
VM-${{ matrix.platform }},
229230
Py-${{ steps.python-install.outputs.python-version }}
230231
token: ${{ secrets.CODECOV_TOKEN }}
232+
233+
check-changed-folders:
234+
name: Fail the job if files changed under _disutils/_vendor folders
235+
if: github.event_name == 'pull_request'
236+
runs-on: ubuntu-latest
237+
steps:
238+
- name: Checkout code
239+
uses: actions/checkout@v3
240+
with:
241+
fetch-depth: 0
242+
- name: Check if files changed in the _distutils folder
243+
id: changed-files-specific-distutils
244+
uses: tj-actions/changed-files@v34
245+
with:
246+
files: |
247+
setuptools/_distutils/**
248+
- name: Check if files changed in the _vendor folder
249+
id: changed-files-specific-vendor
250+
uses: tj-actions/changed-files@v34
251+
with:
252+
files: |
253+
setuptools/_vendor/**
254+
- name: Fail the job if any file(s) in the _distutils folder change
255+
if: steps.changed-files-specific-distutils.outputs.any_changed == 'true'
256+
run: |
257+
echo "One or more files in the setuptools/_distutils folder has changed." | tee "${GITHUB_STEP_SUMMARY}"
258+
exit 1
259+
- name: Fail the job if any file(s) in the _vendor folder change
260+
if: steps.changed-files-specific-vendor.outputs.any_changed == 'true'
261+
run: |
262+
echo "One or more files in the setuptools/_vendor folder has changed." | tee "${GITHUB_STEP_SUMMARY}"
263+
exit 1
231264
232265
integration-test:
233266
needs: test

NEWS.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
v80.9.0
2+
=======
3+
4+
Features
5+
--------
6+
7+
- Set a deadline for the removal of pkg_resources later this year (December). (#3085)
8+
- Removed reliance on pkg_resources in test_wheel. (#3085)
9+
10+
111
v80.8.0
212
=======
313

newsfragments/3085.feature.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

pkg_resources/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,11 @@
9797

9898
warnings.warn(
9999
"pkg_resources is deprecated as an API. "
100-
"See https://setuptools.pypa.io/en/latest/pkg_resources.html",
101-
DeprecationWarning,
100+
"See https://setuptools.pypa.io/en/latest/pkg_resources.html. "
101+
"The pkg_resources package is slated for removal as early as "
102+
"2025-11-30. Refrain from using this package or pin to "
103+
"Setuptools<81.",
104+
UserWarning,
102105
stacklevel=2,
103106
)
104107

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ backend-path = ["."]
1010

1111
[project]
1212
name = "setuptools"
13-
version = "80.8.0"
13+
version = "80.9.0"
1414
authors = [
1515
{ name = "Python Packaging Authority", email = "[email protected]" },
1616
]

pytest.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ filterwarnings=
8484
# Avoid errors when testing pkg_resources.declare_namespace
8585
ignore:.*pkg_resources\.declare_namespace.*:DeprecationWarning
8686

87-
# suppress known deprecation
88-
ignore:pkg_resources is deprecated:DeprecationWarning
87+
# suppress known deprecation pypa/setuptools#3085
88+
ignore:pkg_resources is deprecated:UserWarning
8989

9090
# Dependencies might not have been updated yet
9191
default:onerror argument is deprecated, use onexc instead

ruff.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extend-select = [
2626

2727
# local
2828
"ANN2", # missing-return-type-*
29+
"ISC", # flake8-implicit-str-concat
2930
"FURB", # refurb
3031
"PERF", # Perflint
3132
"PGH", # pygrep-hooks (blanket-* rules)
@@ -66,13 +67,12 @@ ignore = [
6667
"UP038", # Using `X | Y` in `isinstance` call is slower and more verbose https://github.com/astral-sh/ruff/issues/7871
6768
# Only enforcing return type annotations for public functions
6869
"ANN202", # missing-return-type-private-function
69-
"ANN204", # missing-return-type-special-method
7070
]
7171

7272
[lint.per-file-ignores]
7373
# Suppress nuisance warnings about module-import-not-at-top-of-file (E402) due to workaround for #4476
7474
"setuptools/__init__.py" = ["E402"]
75-
"pkg_resources/__init__.py" = ["E402"]
75+
"pkg_resources/__init__.py" = ["E402", "ANN204"]
7676

7777
[lint.isort]
7878
combine-as-imports = true

setuptools/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ def _fetch_build_eggs(dist: Distribution):
108108
raise
109109

110110

111-
def setup(**attrs):
111+
def setup(**attrs) -> Distribution:
112112
logging.configure()
113113
# Make sure we have any requirements needed to interpret 'attrs'.
114114
_install_setup_requires(attrs)
115-
return distutils.core.setup(**attrs)
115+
# Override return type of distutils.core.Distribution with setuptools.dist.Distribution
116+
# (implicitly implemented via `setuptools.monkey.patch_all`).
117+
return distutils.core.setup(**attrs) # type: ignore[return-value]
116118

117119

118120
setup.__doc__ = distutils.core.setup.__doc__
@@ -176,14 +178,14 @@ def __init__(self, dist: Distribution, **kw) -> None:
176178
@overload
177179
def reinitialize_command(
178180
self, command: str, reinit_subcommands: bool = False, **kw
179-
) -> _Command: ...
181+
) -> Command: ... # override distutils.cmd.Command with setuptools.Command
180182
@overload
181183
def reinitialize_command(
182184
self, command: _CommandT, reinit_subcommands: bool = False, **kw
183185
) -> _CommandT: ...
184186
def reinitialize_command(
185187
self, command: str | _Command, reinit_subcommands: bool = False, **kw
186-
) -> _Command:
188+
) -> Command | _Command:
187189
cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
188190
vars(cmd).update(kw)
189191
return cmd # pyright: ignore[reportReturnType] # pypa/distutils#307

setuptools/build_meta.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import warnings
4040
from collections.abc import Iterable, Iterator, Mapping
4141
from pathlib import Path
42-
from typing import TYPE_CHECKING, Union
42+
from typing import TYPE_CHECKING, NoReturn, Union
4343

4444
import setuptools
4545

@@ -74,14 +74,14 @@ def __init__(self, specifiers) -> None:
7474

7575

7676
class Distribution(setuptools.dist.Distribution):
77-
def fetch_build_eggs(self, specifiers):
77+
def fetch_build_eggs(self, specifiers) -> NoReturn:
7878
specifier_list = list(parse_strings(specifiers))
7979

8080
raise SetupRequirementsError(specifier_list)
8181

8282
@classmethod
8383
@contextlib.contextmanager
84-
def patch(cls):
84+
def patch(cls) -> Iterator[None]:
8585
"""
8686
Replace
8787
distutils.dist.Distribution with this class
@@ -304,7 +304,7 @@ def _get_build_requires(
304304

305305
return requirements
306306

307-
def run_setup(self, setup_script: str = 'setup.py'):
307+
def run_setup(self, setup_script: str = 'setup.py') -> None:
308308
# Note that we can reuse our build directory between calls
309309
# Correctness comes first, then optimization later
310310
__file__ = os.path.abspath(setup_script)
@@ -327,10 +327,14 @@ def run_setup(self, setup_script: str = 'setup.py'):
327327
"setup-py-deprecated.html",
328328
)
329329

330-
def get_requires_for_build_wheel(self, config_settings: _ConfigSettings = None):
330+
def get_requires_for_build_wheel(
331+
self, config_settings: _ConfigSettings = None
332+
) -> list[str]:
331333
return self._get_build_requires(config_settings, requirements=[])
332334

333-
def get_requires_for_build_sdist(self, config_settings: _ConfigSettings = None):
335+
def get_requires_for_build_sdist(
336+
self, config_settings: _ConfigSettings = None
337+
) -> list[str]:
334338
return self._get_build_requires(config_settings, requirements=[])
335339

336340
def _bubble_up_info_directory(
@@ -361,7 +365,7 @@ def _find_info_directory(self, metadata_directory: StrPath, suffix: str) -> Path
361365

362366
def prepare_metadata_for_build_wheel(
363367
self, metadata_directory: StrPath, config_settings: _ConfigSettings = None
364-
):
368+
) -> str:
365369
sys.argv = [
366370
*sys.argv[:1],
367371
*self._global_args(config_settings),
@@ -417,7 +421,7 @@ def build_wheel(
417421
wheel_directory: StrPath,
418422
config_settings: _ConfigSettings = None,
419423
metadata_directory: StrPath | None = None,
420-
):
424+
) -> str:
421425
def _build(cmd: list[str]):
422426
with suppress_known_deprecation():
423427
return self._build_with_temp_dir(
@@ -442,7 +446,7 @@ def _build(cmd: list[str]):
442446

443447
def build_sdist(
444448
self, sdist_directory: StrPath, config_settings: _ConfigSettings = None
445-
):
449+
) -> str:
446450
return self._build_with_temp_dir(
447451
['sdist', '--formats', 'gztar'], '.tar.gz', sdist_directory, config_settings
448452
)
@@ -459,7 +463,7 @@ def build_editable(
459463
wheel_directory: StrPath,
460464
config_settings: _ConfigSettings = None,
461465
metadata_directory: StrPath | None = None,
462-
):
466+
) -> str:
463467
# XXX can or should we hide our editable_wheel command normally?
464468
info_dir = self._get_dist_info_dir(metadata_directory)
465469
opts = ["--dist-info-dir", info_dir] if info_dir else []
@@ -469,12 +473,14 @@ def build_editable(
469473
cmd, ".whl", wheel_directory, config_settings
470474
)
471475

472-
def get_requires_for_build_editable(self, config_settings: _ConfigSettings = None):
476+
def get_requires_for_build_editable(
477+
self, config_settings: _ConfigSettings = None
478+
) -> list[str]:
473479
return self.get_requires_for_build_wheel(config_settings)
474480

475481
def prepare_metadata_for_build_editable(
476482
self, metadata_directory: StrPath, config_settings: _ConfigSettings = None
477-
):
483+
) -> str:
478484
return self.prepare_metadata_for_build_wheel(
479485
metadata_directory, config_settings
480486
)
@@ -492,7 +498,7 @@ class _BuildMetaLegacyBackend(_BuildMetaBackend):
492498
and will eventually be removed.
493499
"""
494500

495-
def run_setup(self, setup_script: str = 'setup.py'):
501+
def run_setup(self, setup_script: str = 'setup.py') -> None:
496502
# In order to maintain compatibility with scripts assuming that
497503
# the setup.py script is in a directory on the PYTHONPATH, inject
498504
# '' into sys.path. (pypa/setuptools#1642)

0 commit comments

Comments
 (0)