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

a80022
From 7c36cb21910b415e0eb171d0f6c4dbf72382fdaf Mon Sep 17 00:00:00 2001
a80022
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
a80022
Date: Tue, 10 Mar 2020 11:03:22 +0100
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.
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
a80022
index 3aa8a46..0ec017b 100755
a80022
--- a/src/pip/_internal/__init__.py
a80022
+++ b/src/pip/_internal/__init__.py
a80022
@@ -15,4 +15,4 @@ def main(args=None):
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
a80022
index befd01c..d6f3632 100644
a80022
--- a/src/pip/_internal/utils/entrypoints.py
a80022
+++ b/src/pip/_internal/utils/entrypoints.py
a80022
@@ -7,7 +7,7 @@ if MYPY_CHECK_RUNNING:
a80022
     from typing import List, Optional
a80022
 
a80022
 
a80022
-def _wrapper(args=None):
a80022
+def _wrapper(args=None, _nowarn=False):
a80022
     # type: (Optional[List[str]]) -> int
a80022
     """Central wrapper for all old entrypoints.
a80022
 
a80022
@@ -20,12 +20,13 @@ def _wrapper(args=None):
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
-- 
a80022
2.24.1
a80022