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