Skip to content

Commit 880b30e

Browse files
committed
Remove deprecated fallback for 'distutils.commands.build.build.sub_commands +='
1 parent 118c5e4 commit 880b30e

File tree

2 files changed

+1
-53
lines changed

2 files changed

+1
-53
lines changed

setuptools/command/build.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,13 @@
11
from typing import Dict, List, Protocol
22
from distutils.command.build import build as _build
33

4-
from ..warnings import SetuptoolsDeprecationWarning
5-
64
_ORIGINAL_SUBCOMMANDS = {"build_py", "build_clib", "build_ext", "build_scripts"}
75

86

97
class build(_build):
108
# copy to avoid sharing the object with parent class
119
sub_commands = _build.sub_commands[:]
1210

13-
def get_sub_commands(self):
14-
subcommands = {cmd[0] for cmd in _build.sub_commands}
15-
if subcommands - _ORIGINAL_SUBCOMMANDS:
16-
SetuptoolsDeprecationWarning.emit(
17-
"Direct usage of `distutils` commands",
18-
"""
19-
It seems that you are using `distutils.command.build` to add
20-
new subcommands. Using `distutils` directly is considered deprecated,
21-
please use `setuptools.command.build`.
22-
""",
23-
due_date=(2023, 12, 13), # Warning introduced in 13 Jun 2022.
24-
see_url="https://peps.python.org/pep-0632/",
25-
)
26-
self.sub_commands = _build.sub_commands
27-
return super().get_sub_commands()
28-
2911

3012
class SubCommand(Protocol):
3113
"""In order to support editable installations (see :pep:`660`) all

setuptools/tests/test_build.py

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
from contextlib import contextmanager
2-
from setuptools import Command, SetuptoolsDeprecationWarning
1+
from setuptools import Command
32
from setuptools.dist import Distribution
43
from setuptools.command.build import build
5-
from distutils.command.build import build as distutils_build
6-
7-
import pytest
84

95

106
def test_distribution_gives_setuptools_build_obj(tmpdir_cwd):
@@ -24,15 +20,6 @@ def test_distribution_gives_setuptools_build_obj(tmpdir_cwd):
2420
assert isinstance(dist.get_command_obj("build"), build)
2521

2622

27-
@contextmanager
28-
def _restore_sub_commands():
29-
orig = distutils_build.sub_commands[:]
30-
try:
31-
yield
32-
finally:
33-
distutils_build.sub_commands = orig
34-
35-
3623
class Subcommand(Command):
3724
"""Dummy command to be used in tests"""
3825

@@ -44,24 +31,3 @@ def finalize_options(self):
4431

4532
def run(self):
4633
raise NotImplementedError("just to check if the command runs")
47-
48-
49-
@_restore_sub_commands()
50-
def test_subcommand_in_distutils(tmpdir_cwd):
51-
"""
52-
Ensure that sub commands registered in ``distutils`` run,
53-
after instructing the users to migrate to ``setuptools``.
54-
"""
55-
dist = Distribution(
56-
dict(
57-
packages=[],
58-
cmdclass={'subcommand': Subcommand},
59-
)
60-
)
61-
distutils_build.sub_commands.append(('subcommand', None))
62-
63-
warning_msg = "please use .setuptools.command.build."
64-
with pytest.warns(SetuptoolsDeprecationWarning, match=warning_msg):
65-
# For backward compatibility, the subcommand should run anyway:
66-
with pytest.raises(NotImplementedError, match="the command runs"):
67-
dist.run_command("build")

0 commit comments

Comments
 (0)