orion / rpms / python3x-pip

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