diff --git a/changelog.d/3206.deprecation.rst b/changelog.d/3206.deprecation.rst new file mode 100644 index 0000000000..2ad90f37c1 --- /dev/null +++ b/changelog.d/3206.deprecation.rst @@ -0,0 +1,3 @@ +Changed ``setuptools.convert_path`` to an internal function that is not exposed +as part of setuptools API. +Future releases of ``setuptools`` are likely to remove this function. diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 187e7329f2..502d2a2e12 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -3,11 +3,13 @@ import functools import os import re +import warnings import _distutils_hack.override # noqa: F401 import distutils.core from distutils.errors import DistutilsOptionError +from distutils.util import convert_path as _convert_path from ._deprecation_warning import SetuptoolsDeprecationWarning @@ -158,6 +160,19 @@ def findall(dir=os.curdir): return list(files) +@functools.wraps(_convert_path) +def convert_path(pathname): + from inspect import cleandoc + + msg = """ + The function `convert_path` is considered internal and not part of the public API. + Its direct usage by 3rd-party packages is considered deprecated and the function + may be removed in the future. + """ + warnings.warn(cleandoc(msg), SetuptoolsDeprecationWarning) + return _convert_path(pathname) + + class sic(str): """Treat this string as-is (https://en.wikipedia.org/wiki/Sic)""" diff --git a/setuptools/tests/test_setuptools.py b/setuptools/tests/test_setuptools.py index b97faf17bc..0640f49da1 100644 --- a/setuptools/tests/test_setuptools.py +++ b/setuptools/tests/test_setuptools.py @@ -303,3 +303,8 @@ def test_its_own_wheel_does_not_contain_tests(setuptools_wheel): for member in contents: assert '/tests/' not in member + + +def test_convert_path_deprecated(): + with pytest.warns(setuptools.SetuptoolsDeprecationWarning): + setuptools.convert_path('setuptools/tests')