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

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