2017-02-23 11:16:46 +00:00
|
|
|
From e29dfc3855813dbab25513ca82703fc5d7b989cf Mon Sep 17 00:00:00 2001
|
2017-02-16 10:48:01 +00:00
|
|
|
From: Tomas Orsava <torsava@redhat.com>
|
|
|
|
Date: Tue, 14 Feb 2017 17:10:09 +0100
|
|
|
|
Subject: [PATCH] Emit a warning when running with root privileges
|
|
|
|
|
|
|
|
---
|
2017-02-23 11:16:46 +00:00
|
|
|
pip/commands/install.py | 10 ++++++++++
|
|
|
|
1 file changed, 10 insertions(+)
|
2017-02-16 10:48:01 +00:00
|
|
|
|
2017-02-23 11:16:46 +00:00
|
|
|
diff --git a/commands/install.py b/commands/install.py
|
|
|
|
index 227c526..88c7c58 100644
|
2017-02-16 10:48:01 +00:00
|
|
|
--- a/pip/commands/install.py
|
|
|
|
+++ b/pip/commands/install.py
|
2017-02-23 11:16:46 +00:00
|
|
|
@@ -6,6 +6,8 @@ import os
|
|
|
|
import tempfile
|
|
|
|
import shutil
|
|
|
|
import warnings
|
|
|
|
+import sys
|
|
|
|
+from os import path
|
|
|
|
try:
|
|
|
|
import wheel
|
|
|
|
except ImportError:
|
|
|
|
@@ -193,6 +195,14 @@ class InstallCommand(RequirementCommand):
|
2017-02-16 10:48:01 +00:00
|
|
|
cmdoptions.resolve_wheel_no_use_binary(options)
|
|
|
|
cmdoptions.check_install_build_global(options)
|
|
|
|
|
|
|
|
+ # Check whether we have root privileges
|
|
|
|
+ if os.getuid() == 0:
|
|
|
|
+ logger.warning(
|
2017-02-23 11:16:46 +00:00
|
|
|
+ "WARNING: Running pip install with root privileges is"
|
|
|
|
+ "generally not a good idea. Try `%s install --user` instead."
|
|
|
|
+ % path.basename(sys.argv[0])
|
2017-02-16 10:48:01 +00:00
|
|
|
+ )
|
|
|
|
+
|
|
|
|
if options.as_egg:
|
|
|
|
warnings.warn(
|
|
|
|
"--egg has been deprecated and will be removed in the future. "
|
|
|
|
--
|
|
|
|
2.11.0
|
|
|
|
|