Blame SOURCES/nowarn-pip._internal.main.patch

f96a86
From 619782ad2d181fe2933ddf4edc7127fdc13dd0df Mon Sep 17 00:00:00 2001
f96a86
From: Karolina Surma <ksurma@redhat.com>
f96a86
Date: Mon, 10 May 2021 16:48:49 +0200
a80022
Subject: [PATCH] Don't warn the user about pip._internal.main() entrypoint
a80022
a80022
In Fedora, we use that in ensurepip and users cannot do anything about it,
a80022
this warning is juts moot. Also, the warning breaks CPython test suite.
f96a86
f96a86
Co-Authored-By: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
a80022
---
a80022
 src/pip/_internal/__init__.py          |  2 +-
a80022
 src/pip/_internal/utils/entrypoints.py | 19 ++++++++++---------
a80022
 tests/functional/test_cli.py           |  3 ++-
a80022
 3 files changed, 13 insertions(+), 11 deletions(-)
a80022
a80022
diff --git a/src/pip/_internal/__init__.py b/src/pip/_internal/__init__.py
f96a86
index 6afb5c6..faf25af 100755
a80022
--- a/src/pip/_internal/__init__.py
a80022
+++ b/src/pip/_internal/__init__.py
f96a86
@@ -16,4 +16,4 @@ def main(args: (Optional[List[str]]) = None) -> int:
a80022
     """
a80022
     from pip._internal.utils.entrypoints import _wrapper
a80022
 
a80022
-    return _wrapper(args)
a80022
+    return _wrapper(args, _nowarn=True)
a80022
diff --git a/src/pip/_internal/utils/entrypoints.py b/src/pip/_internal/utils/entrypoints.py
f96a86
index 1504a12..07d941b 100644
a80022
--- a/src/pip/_internal/utils/entrypoints.py
a80022
+++ b/src/pip/_internal/utils/entrypoints.py
f96a86
@@ -4,7 +4,7 @@ from typing import List, Optional
f96a86
 from pip._internal.cli.main import main
a80022
 
a80022
 
f96a86
-def _wrapper(args: Optional[List[str]] = None) -> int:
f96a86
+def _wrapper(args: Optional[List[str]] = None, _nowarn: bool = False) -> int:
a80022
     """Central wrapper for all old entrypoints.
a80022
 
f96a86
     Historically pip has had several entrypoints defined. Because of issues
f96a86
@@ -16,12 +16,13 @@ def _wrapper(args: Optional[List[str]] = None) -> int:
a80022
     directing them to an appropriate place for help, we now define all of
a80022
     our old entrypoints as wrappers for the current one.
a80022
     """
a80022
-    sys.stderr.write(
a80022
-        "WARNING: pip is being invoked by an old script wrapper. This will "
a80022
-        "fail in a future version of pip.\n"
a80022
-        "Please see https://github.com/pypa/pip/issues/5599 for advice on "
a80022
-        "fixing the underlying issue.\n"
a80022
-        "To avoid this problem you can invoke Python with '-m pip' instead of "
a80022
-        "running pip directly.\n"
a80022
-    )
a80022
+    if not _nowarn:
a80022
+        sys.stderr.write(
a80022
+            "WARNING: pip is being invoked by an old script wrapper. This will "
a80022
+            "fail in a future version of pip.\n"
a80022
+            "Please see https://github.com/pypa/pip/issues/5599 for advice on "
a80022
+            "fixing the underlying issue.\n"
a80022
+            "To avoid this problem you can invoke Python with '-m pip' instead of "
a80022
+            "running pip directly.\n"
a80022
+        )
a80022
     return main(args)
a80022
diff --git a/tests/functional/test_cli.py b/tests/functional/test_cli.py
a80022
index e416315..7f57f67 100644
a80022
--- a/tests/functional/test_cli.py
a80022
+++ b/tests/functional/test_cli.py
a80022
@@ -31,4 +31,5 @@ def test_entrypoints_work(entrypoint, script):
a80022
     result = script.pip("-V")
a80022
     result2 = script.run("fake_pip", "-V", allow_stderr_warning=True)
a80022
     assert result.stdout == result2.stdout
a80022
-    assert "old script wrapper" in result2.stderr
a80022
+    if entrypoint[0] != "fake_pip = pip._internal:main":
a80022
+        assert "old script wrapper" in result2.stderr
a80022
-- 
f96a86
2.32.0
a80022