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