Skip to content

Commit bf0e5f2

Browse files
authored
Remove deprecation warning from vendored pkg_resources (#12660)
1 parent 6b35bee commit bf0e5f2

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

news/12660.trivial.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove (suppressed) deprecation warning from vendored ``pkg_resources``
2+
to ensure builds succeed with ``PYTHONWARNINGS=error``.

src/pip/_vendor/pkg_resources/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,10 @@
9999
_namespace_packages = None
100100

101101

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

109107

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

tools/vendoring/patches/pkg_resources.patch

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,22 @@ index 3f2476a0c..8d5727d35 100644
1111
yield_lines,
1212
drop_comment,
1313
join_continuation,
14+
--- a/src/pip/_vendor/pkg_resources/__init__.py
15+
+++ b/src/pip/_vendor/pkg_resources/__init__.py
16+
@@ -101,12 +101,10 @@ _namespace_handlers = None
17+
_namespace_packages = None
18+
19+
20+
-warnings.warn(
21+
- "pkg_resources is deprecated as an API. "
22+
- "See https://setuptools.pypa.io/en/latest/pkg_resources.html",
23+
- DeprecationWarning,
24+
- stacklevel=2,
25+
-)
26+
+# Patch: Remove deprecation warning from vendored pkg_resources.
27+
+# Setting PYTHONWARNINGS=error to verify builds produce no warnings
28+
+# causes immediate exceptions.
29+
+# See https://github.com/pypa/pip/issues/12243
30+
31+
32+
_PEP440_FALLBACK = re.compile(r"^v?(?P<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I)

0 commit comments

Comments
 (0)