Skip to content

Commit

Permalink
Remove deprecation warning from vendored pkg_resources (#12660)
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies authored Jul 9, 2024
1 parent 6b35bee commit bf0e5f2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
2 changes: 2 additions & 0 deletions news/12660.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove (suppressed) deprecation warning from vendored ``pkg_resources``
to ensure builds succeed with ``PYTHONWARNINGS=error``.
10 changes: 4 additions & 6 deletions src/pip/_vendor/pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,10 @@
_namespace_packages = None


warnings.warn(
"pkg_resources is deprecated as an API. "
"See https://setuptools.pypa.io/en/latest/pkg_resources.html",
DeprecationWarning,
stacklevel=2,
)
# Patch: Remove deprecation warning from vendored pkg_resources.
# Setting PYTHONWARNINGS=error to verify builds produce no warnings
# causes immediate exceptions.
# See https://github.com/pypa/pip/issues/12243


_PEP440_FALLBACK = re.compile(r"^v?(?P<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I)
Expand Down
19 changes: 19 additions & 0 deletions tools/vendoring/patches/pkg_resources.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,22 @@ index 3f2476a0c..8d5727d35 100644
yield_lines,
drop_comment,
join_continuation,
--- a/src/pip/_vendor/pkg_resources/__init__.py
+++ b/src/pip/_vendor/pkg_resources/__init__.py
@@ -101,12 +101,10 @@ _namespace_handlers = None
_namespace_packages = None


-warnings.warn(
- "pkg_resources is deprecated as an API. "
- "See https://setuptools.pypa.io/en/latest/pkg_resources.html",
- DeprecationWarning,
- stacklevel=2,
-)
+# Patch: Remove deprecation warning from vendored pkg_resources.
+# Setting PYTHONWARNINGS=error to verify builds produce no warnings
+# causes immediate exceptions.
+# See https://github.com/pypa/pip/issues/12243


_PEP440_FALLBACK = re.compile(r"^v?(?P<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I)

0 comments on commit bf0e5f2

Please sign in to comment.