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