From 5e84450166c477deef4e851a8c24ee3a4f259c8f Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 12 Jun 2023 10:03:51 +0100 Subject: [PATCH] Mention 'packaging' on pkg_resources deprecation notes --- docs/pkg_resources.rst | 2 ++ pkg_resources/__init__.py | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/pkg_resources.rst b/docs/pkg_resources.rst index 7fd77f8d06..ba41d6200c 100644 --- a/docs/pkg_resources.rst +++ b/docs/pkg_resources.rst @@ -14,6 +14,8 @@ packages. Use of ``pkg_resources`` is deprecated in favor of :mod:`importlib.resources`, :mod:`importlib.metadata` and their backports (:pypi:`importlib_resources`, :pypi:`importlib_metadata`). + Some useful APIs are also provided by :pypi:`packaging` (e.g. requirements + and version parsing). Users should refrain from new usage of ``pkg_resources`` and should work to port to importlib-based solutions. diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 8159afd224..8aa51d02de 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -13,11 +13,8 @@ .zip files and with custom PEP 302 loaders that support the ``get_data()`` method. -This module is deprecated. Users are directed to -`importlib.resources `_ -and -`importlib.metadata `_ -instead. +This module is deprecated. Users are directed to :mod:`importlib.resources`, +:mod:`importlib.metadata` and :pypi:`packaging` instead. """ import sys @@ -118,7 +115,11 @@ _namespace_packages = None -warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning) +warnings.warn( + "pkg_resources is deprecated as an API. " + "See https://setuptools.pypa.io/en/latest/pkg_resources.html", + DeprecationWarning +) _PEP440_FALLBACK = re.compile(r"^v?(?P(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I)