Customize the sudo pip warning with the proper version of the pip

This commit is contained in:
Tomas Orsava 2017-02-23 12:16:46 +01:00
parent 3d0a78651f
commit 33d96860e5
2 changed files with 23 additions and 9 deletions

View File

@ -1,17 +1,26 @@
From 5023ea0feceb5a9cc4931f6be9404d4582cb8502 Mon Sep 17 00:00:00 2001 From e29dfc3855813dbab25513ca82703fc5d7b989cf Mon Sep 17 00:00:00 2001
From: Tomas Orsava <torsava@redhat.com> From: Tomas Orsava <torsava@redhat.com>
Date: Tue, 14 Feb 2017 17:10:09 +0100 Date: Tue, 14 Feb 2017 17:10:09 +0100
Subject: [PATCH] Emit a warning when running with root privileges Subject: [PATCH] Emit a warning when running with root privileges
--- ---
pip/commands/install.py | 7 +++++++ pip/commands/install.py | 10 ++++++++++
1 file changed, 7 insertions(+) 1 file changed, 10 insertions(+)
diff --git a/pip/commands/install.py b/pip/commands/install.py diff --git a/commands/install.py b/commands/install.py
index b7e662bd..c1bcf3b5 100644 index 227c526..88c7c58 100644
--- a/pip/commands/install.py --- a/pip/commands/install.py
+++ b/pip/commands/install.py +++ b/pip/commands/install.py
@@ -192,6 +192,13 @@ class InstallCommand(RequirementCommand): @@ -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):
cmdoptions.resolve_wheel_no_use_binary(options) cmdoptions.resolve_wheel_no_use_binary(options)
cmdoptions.check_install_build_global(options) cmdoptions.check_install_build_global(options)
@ -19,7 +28,8 @@ index b7e662bd..c1bcf3b5 100644
+ if os.getuid() == 0: + if os.getuid() == 0:
+ logger.warning( + logger.warning(
+ "WARNING: Running pip install with root privileges is" + "WARNING: Running pip install with root privileges is"
+ "generally not advised. Try `pip install --user` instead." + "generally not a good idea. Try `%s install --user` instead."
+ % path.basename(sys.argv[0])
+ ) + )
+ +
if options.as_egg: if options.as_egg:

View File

@ -17,7 +17,7 @@
Name: python-%{srcname} Name: python-%{srcname}
Version: 9.0.1 Version: 9.0.1
Release: 6%{?dist} Release: 7%{?dist}
Summary: A tool for installing and managing Python packages Summary: A tool for installing and managing Python packages
Group: Development/Libraries Group: Development/Libraries
@ -244,6 +244,10 @@ py.test-%{python3_version} -m 'not network'
%endif # with_python3 %endif # with_python3
%changelog %changelog
* Thu Feb 23 2017 Tomas Orsava <torsava@redhat.com> - 9.0.1-7
- Patch 1 update: Customize the warning with the proper version of the pip
command
* Tue Feb 14 2017 Tomas Orsava <torsava@redhat.com> - 9.0.1-6 * Tue Feb 14 2017 Tomas Orsava <torsava@redhat.com> - 9.0.1-6
- Added patch 1: Emit a warning when running with root privileges - Added patch 1: Emit a warning when running with root privileges