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