__init__.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. """For backward compatibility, expose main functions from
  2. ``setuptools.config.setupcfg``
  3. """
  4. from functools import wraps
  5. from typing import Callable, TypeVar, cast
  6. from ..warnings import SetuptoolsDeprecationWarning
  7. from . import setupcfg
  8. Fn = TypeVar("Fn", bound=Callable)
  9. __all__ = ('parse_configuration', 'read_configuration')
  10. def _deprecation_notice(fn: Fn) -> Fn:
  11. @wraps(fn)
  12. def _wrapper(*args, **kwargs):
  13. SetuptoolsDeprecationWarning.emit(
  14. "Deprecated API usage.",
  15. 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. To read project metadata, consider using
  22. ``build.util.project_wheel_metadata`` (https://pypi.org/project/build/).
  23. For simple scenarios, you can also try parsing the file directly
  24. with the help of ``configparser``.
  25. """,
  26. # due_date not defined yet, because the community still heavily relies on it
  27. # Warning introduced in 24 Mar 2022
  28. )
  29. return fn(*args, **kwargs)
  30. return cast(Fn, _wrapper)
  31. read_configuration = _deprecation_notice(setupcfg.read_configuration)
  32. parse_configuration = _deprecation_notice(setupcfg.parse_configuration)