From 6e462c7a18c32089bfd4e8c6cb0f3382b7f25c7a Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 25 Mar 2022 14:34:03 +0000 Subject: [PATCH 1/2] Add back convert_path as deprecated function --- setuptools/__init__.py | 15 +++++++++++++++ setuptools/tests/test_setuptools.py | 5 +++++ 2 files changed, 20 insertions(+) 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') From 26145049f9b4d9aeac926c17679bd01e9b7c41f4 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 25 Mar 2022 14:40:05 +0000 Subject: [PATCH 2/2] Add news fragment --- changelog.d/3206.deprecation.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog.d/3206.deprecation.rst 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.