codekingpro/portable-devtools
114k
1"""For backward compatibility, expose main functions from2``setuptools.config.setupcfg``3"""4 5from functools import wraps6from typing import Callable, TypeVar, cast7 8from ..warnings import SetuptoolsDeprecationWarning9from . import setupcfg10 11Fn = TypeVar("Fn", bound=Callable)12 13__all__ = ('parse_configuration', 'read_configuration')14 15 16def _deprecation_notice(fn: Fn) -> Fn:17 @wraps(fn)18 def _wrapper(*args, **kwargs):19 SetuptoolsDeprecationWarning.emit(20 "Deprecated API usage.",21 f"""22 As setuptools moves its configuration towards `pyproject.toml`,23 `{__name__}.{fn.__name__}` became deprecated.24 25 For the time being, you can use the `{setupcfg.__name__}` module26 to access a backward compatible API, but this module is provisional27 and might be removed in the future.28 29 To read project metadata, consider using30 ``build.util.project_wheel_metadata`` (https://pypi.org/project/build/).31 For simple scenarios, you can also try parsing the file directly32 with the help of ``configparser``.33 """,34 # due_date not defined yet, because the community still heavily relies on it35 # Warning introduced in 24 Mar 202236 )37 return fn(*args, **kwargs)38 39 return cast(Fn, _wrapper)40 41 42read_configuration = _deprecation_notice(setupcfg.read_configuration)43parse_configuration = _deprecation_notice(setupcfg.parse_configuration)44 