dfbae6
From 7c36cb21910b415e0eb171d0f6c4dbf72382fdaf Mon Sep 17 00:00:00 2001
dfbae6
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
dfbae6
Date: Tue, 10 Mar 2020 11:03:22 +0100
dfbae6
Subject: [PATCH] Don't warn the user about pip._internal.main() entrypoint
dfbae6
dfbae6
In Fedora, we use that in ensurepip and users cannot do anything about it,
dfbae6
this warning is juts moot. Also, the warning breaks CPython test suite.
dfbae6
---
dfbae6
 src/pip/_internal/__init__.py          |  2 +-
dfbae6
 src/pip/_internal/utils/entrypoints.py | 19 ++++++++++---------
dfbae6
 tests/functional/test_cli.py           |  3 ++-
dfbae6
 3 files changed, 13 insertions(+), 11 deletions(-)
dfbae6
dfbae6
diff --git a/src/pip/_internal/__init__.py b/src/pip/_internal/__init__.py
dfbae6
index 3aa8a46..0ec017b 100755
dfbae6
--- a/src/pip/_internal/__init__.py
dfbae6
+++ b/src/pip/_internal/__init__.py
dfbae6
@@ -15,4 +15,4 @@ def main(args=None):
dfbae6
     """
dfbae6
     from pip._internal.utils.entrypoints import _wrapper
dfbae6
 
dfbae6
-    return _wrapper(args)
dfbae6
+    return _wrapper(args, _nowarn=True)
dfbae6
diff --git a/src/pip/_internal/utils/entrypoints.py b/src/pip/_internal/utils/entrypoints.py
dfbae6
index befd01c..d6f3632 100644
dfbae6
--- a/src/pip/_internal/utils/entrypoints.py
dfbae6
+++ b/src/pip/_internal/utils/entrypoints.py
dfbae6
@@ -7,7 +7,7 @@ if MYPY_CHECK_RUNNING:
dfbae6
     from typing import Optional, List
dfbae6
 
dfbae6
 
dfbae6
-def _wrapper(args=None):
dfbae6
+def _wrapper(args=None, _nowarn=False):
dfbae6
     # type: (Optional[List[str]]) -> int
dfbae6
     """Central wrapper for all old entrypoints.
dfbae6
 
dfbae6
@@ -20,12 +20,13 @@ def _wrapper(args=None):
dfbae6
     directing them to an appropriate place for help, we now define all of
dfbae6
     our old entrypoints as wrappers for the current one.
dfbae6
     """
dfbae6
-    sys.stderr.write(
dfbae6
-        "WARNING: pip is being invoked by an old script wrapper. This will "
dfbae6
-        "fail in a future version of pip.\n"
dfbae6
-        "Please see https://github.com/pypa/pip/issues/5599 for advice on "
dfbae6
-        "fixing the underlying issue.\n"
dfbae6
-        "To avoid this problem you can invoke Python with '-m pip' instead of "
dfbae6
-        "running pip directly.\n"
dfbae6
-    )
dfbae6
+    if not _nowarn:
dfbae6
+        sys.stderr.write(
dfbae6
+            "WARNING: pip is being invoked by an old script wrapper. This will "
dfbae6
+            "fail in a future version of pip.\n"
dfbae6
+            "Please see https://github.com/pypa/pip/issues/5599 for advice on "
dfbae6
+            "fixing the underlying issue.\n"
dfbae6
+            "To avoid this problem you can invoke Python with '-m pip' instead of "
dfbae6
+            "running pip directly.\n"
dfbae6
+        )
dfbae6
     return main(args)
dfbae6
diff --git a/tests/functional/test_cli.py b/tests/functional/test_cli.py
dfbae6
index e416315..7f57f67 100644
dfbae6
--- a/tests/functional/test_cli.py
dfbae6
+++ b/tests/functional/test_cli.py
dfbae6
@@ -31,4 +31,5 @@ def test_entrypoints_work(entrypoint, script):
dfbae6
     result = script.pip("-V")
dfbae6
     result2 = script.run("fake_pip", "-V", allow_stderr_warning=True)
dfbae6
     assert result.stdout == result2.stdout
dfbae6
-    assert "old script wrapper" in result2.stderr
dfbae6
+    if entrypoint[0] != "fake_pip = pip._internal:main":
dfbae6
+        assert "old script wrapper" in result2.stderr
dfbae6
-- 
dfbae6
2.24.1
dfbae6