f994ff1cc7
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1793456 The main() wrapper moved the import path again, this time with compatibility shim: - we still need pip-allow-different-versions.patch to support older pips installed by users - we dropped callable-main.patch - the shim is provided by pip for all previous paths - no need to patch older pips to support user installed pip 20+ - no need to patch Pythons (or virtualenv) to support pip 20+ wheel in ensurepip
52 lines
1.8 KiB
Diff
52 lines
1.8 KiB
Diff
From aab24967a03bda3b0999d80562a6064c27d1e0e0 Mon Sep 17 00:00:00 2001
|
|
From: Tomas Orsava <torsava@redhat.com>
|
|
Date: Tue, 12 Nov 2019 17:15:08 +0100
|
|
Subject: [PATCH] Downstream only patch
|
|
|
|
Emit a warning to the user if pip install is run with root privileges
|
|
Issue upstream: https://github.com/pypa/pip/issues/4288
|
|
---
|
|
src/pip/_internal/commands/install.py | 19 +++++++++++++++++++
|
|
1 file changed, 19 insertions(+)
|
|
|
|
diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py
|
|
index 02a187c..8037ffb 100644
|
|
--- a/src/pip/_internal/commands/install.py
|
|
+++ b/src/pip/_internal/commands/install.py
|
|
@@ -13,6 +13,8 @@ import operator
|
|
import os
|
|
import shutil
|
|
import site
|
|
+import sys
|
|
+from os import path
|
|
from optparse import SUPPRESS_HELP
|
|
|
|
from pip._vendor import pkg_resources
|
|
@@ -242,6 +244,23 @@ class InstallCommand(RequirementCommand):
|
|
def run(self, options, args):
|
|
# type: (Values, List[Any]) -> int
|
|
cmdoptions.check_install_build_global(options)
|
|
+
|
|
+ def is_venv():
|
|
+ return (hasattr(sys, 'real_prefix') or
|
|
+ (hasattr(sys, 'base_prefix') and
|
|
+ sys.base_prefix != sys.prefix))
|
|
+
|
|
+ # Check whether we have root privileges and aren't in venv/virtualenv
|
|
+ if os.getuid() == 0 and not is_venv():
|
|
+ command = path.basename(sys.argv[0])
|
|
+ if command == "__main__.py":
|
|
+ command = path.basename(sys.executable) + " -m pip"
|
|
+ logger.warning(
|
|
+ "Running pip install with root privileges is "
|
|
+ "generally not a good idea. Try `%s install --user` instead."
|
|
+ % command
|
|
+ )
|
|
+
|
|
upgrade_strategy = "to-satisfy-only"
|
|
if options.upgrade:
|
|
upgrade_strategy = options.upgrade_strategy
|
|
--
|
|
2.20.1
|
|
|