orion / rpms / python3x-pip

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