__init__.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. """For backward compatibility, expose main functions from
  2. ``setuptools.config.setupcfg``
  3. """
  4. import warnings
  5. from functools import wraps
  6. from textwrap import dedent
  7. from typing import Callable, TypeVar, cast
  8. from .._deprecation_warning import SetuptoolsDeprecationWarning
  9. from . import setupcfg
  10. Fn = TypeVar("Fn", bound=Callable)
  11. __all__ = ('parse_configuration', 'read_configuration')
  12. def _deprecation_notice(fn: Fn) -> Fn:
  13. @wraps(fn)
  14. def _wrapper(*args, **kwargs):
  15. msg = f"""\
  16. As setuptools moves its configuration towards `pyproject.toml`,
  17. `{__name__}.{fn.__name__}` became deprecated.
  18. For the time being, you can use the `{setupcfg.__name__}` module
  19. to access a backward compatible API, but this module is provisional
  20. and might be removed in the future.
  21. """
  22. warnings.warn(dedent(msg), SetuptoolsDeprecationWarning, stacklevel=2)
  23. return fn(*args, **kwargs)
  24. return cast(Fn, _wrapper)
  25. read_configuration = _deprecation_notice(setupcfg.read_configuration)
  26. parse_configuration = _deprecation_notice(setupcfg.parse_configuration)