diff --git a/setuptools/command/build.py b/setuptools/command/build.py index afda7e3be9..16c077b7cc 100644 --- a/setuptools/command/build.py +++ b/setuptools/command/build.py @@ -1,8 +1,6 @@ from typing import Dict, List, Protocol from distutils.command.build import build as _build -from ..warnings import SetuptoolsDeprecationWarning - _ORIGINAL_SUBCOMMANDS = {"build_py", "build_clib", "build_ext", "build_scripts"} @@ -10,22 +8,6 @@ class build(_build): # copy to avoid sharing the object with parent class sub_commands = _build.sub_commands[:] - def get_sub_commands(self): - subcommands = {cmd[0] for cmd in _build.sub_commands} - if subcommands - _ORIGINAL_SUBCOMMANDS: - SetuptoolsDeprecationWarning.emit( - "Direct usage of `distutils` commands", - """ - It seems that you are using `distutils.command.build` to add - new subcommands. Using `distutils` directly is considered deprecated, - please use `setuptools.command.build`. - """, - due_date=(2023, 12, 13), # Warning introduced in 13 Jun 2022. - see_url="https://peps.python.org/pep-0632/", - ) - self.sub_commands = _build.sub_commands - return super().get_sub_commands() - class SubCommand(Protocol): """In order to support editable installations (see :pep:`660`) all diff --git a/setuptools/tests/test_build.py b/setuptools/tests/test_build.py index 4a3b11de18..141522efd4 100644 --- a/setuptools/tests/test_build.py +++ b/setuptools/tests/test_build.py @@ -1,10 +1,6 @@ -from contextlib import contextmanager -from setuptools import Command, SetuptoolsDeprecationWarning +from setuptools import Command from setuptools.dist import Distribution from setuptools.command.build import build -from distutils.command.build import build as distutils_build - -import pytest def test_distribution_gives_setuptools_build_obj(tmpdir_cwd): @@ -24,15 +20,6 @@ def test_distribution_gives_setuptools_build_obj(tmpdir_cwd): assert isinstance(dist.get_command_obj("build"), build) -@contextmanager -def _restore_sub_commands(): - orig = distutils_build.sub_commands[:] - try: - yield - finally: - distutils_build.sub_commands = orig - - class Subcommand(Command): """Dummy command to be used in tests""" @@ -44,24 +31,3 @@ def finalize_options(self): def run(self): raise NotImplementedError("just to check if the command runs") - - -@_restore_sub_commands() -def test_subcommand_in_distutils(tmpdir_cwd): - """ - Ensure that sub commands registered in ``distutils`` run, - after instructing the users to migrate to ``setuptools``. - """ - dist = Distribution( - dict( - packages=[], - cmdclass={'subcommand': Subcommand}, - ) - ) - distutils_build.sub_commands.append(('subcommand', None)) - - warning_msg = "please use .setuptools.command.build." - with pytest.warns(SetuptoolsDeprecationWarning, match=warning_msg): - # For backward compatibility, the subcommand should run anyway: - with pytest.raises(NotImplementedError, match="the command runs"): - dist.run_command("build")