Skip to content

Commit 34328fa

Browse files
authored
Remove deprecated code after warnings have been issued for a long period (pypa#4322)
2 parents 6dc694e + a32e2aa commit 34328fa

File tree

7 files changed

+8
-77
lines changed

7 files changed

+8
-77
lines changed

newsfragments/4322.removal.1.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove ``setuptools.convert_path`` after long deprecation period.
2+
This function was never defined by ``setuptools`` itself, but rather a
3+
side-effect of an import for internal usage.

newsfragments/4322.removal.2.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove fallback for customisations of ``distutils``' ``build.sub_command`` after long
2+
deprecated period.
3+
Users are advised to import ``build`` directly from ``setuptools.command.build``.

setuptools/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import _distutils_hack.override # noqa: F401
99
import distutils.core
1010
from distutils.errors import DistutilsOptionError
11-
from distutils.util import convert_path as _convert_path
1211

1312
from . import logging, monkey
1413
from . import version as _version_module
@@ -247,22 +246,6 @@ def findall(dir=os.curdir):
247246
return list(files)
248247

249248

250-
@functools.wraps(_convert_path)
251-
def convert_path(pathname):
252-
SetuptoolsDeprecationWarning.emit(
253-
"Access to implementation detail",
254-
"""
255-
The function `convert_path` is not provided by setuptools itself,
256-
and therefore not part of the public API.
257-
258-
Its direct usage by 3rd-party packages is considered improper and the function
259-
may be removed in the future.
260-
""",
261-
due_date=(2023, 12, 13), # initial deprecation 2022-03-25, see #3201
262-
)
263-
return _convert_path(pathname)
264-
265-
266249
class sic(str):
267250
"""Treat this string as-is (https://en.wikipedia.org/wiki/Sic)"""
268251

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")

setuptools/tests/test_setuptools.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,3 @@ def test_its_own_wheel_does_not_contain_tests(setuptools_wheel):
307307

308308
for member in contents:
309309
assert '/tests/' not in member
310-
311-
312-
def test_convert_path_deprecated():
313-
with pytest.warns(setuptools.SetuptoolsDeprecationWarning):
314-
setuptools.convert_path('setuptools/tests')

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ deps =
44
# Ideally all the dependencies should be set as "extras"
55
setenv =
66
PYTHONWARNDEFAULTENCODING = 1
7-
SETUPTOOLS_ENFORCE_DEPRECATION = {env:SETUPTOOLS_ENFORCE_DEPRECATION:0}
8-
# ^-- Temporarily disable enforcement so CI don't fail on due dates
7+
SETUPTOOLS_ENFORCE_DEPRECATION = {env:SETUPTOOLS_ENFORCE_DEPRECATION:1}
98
commands =
109
pytest {posargs}
1110
usedevelop = True

0 commit comments

Comments
 (0)