Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add convert_path back (but with deprecated status) #3207

Merged
merged 2 commits into from Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions 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.
15 changes: 15 additions & 0 deletions setuptools/__init__.py
Expand Up @@ -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

Expand Down Expand Up @@ -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)"""

Expand Down
5 changes: 5 additions & 0 deletions setuptools/tests/test_setuptools.py
Expand Up @@ -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')