From 5a8e99c9e5769de15e43efe2cd339f45a034d1d7 Mon Sep 17 00:00:00 2001 From: Tomas Orsava Date: Fri, 3 Mar 2017 15:15:18 +0100 Subject: [PATCH] No sudo pip warning in venv or virtualenv --- ...ng-when-running-with-root-privileges.patch | 22 +++++++++++-------- python-pip.spec | 5 ++++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/emit-a-warning-when-running-with-root-privileges.patch b/emit-a-warning-when-running-with-root-privileges.patch index 5ad98e4..6cfe250 100644 --- a/emit-a-warning-when-running-with-root-privileges.patch +++ b/emit-a-warning-when-running-with-root-privileges.patch @@ -1,14 +1,14 @@ -From e29dfc3855813dbab25513ca82703fc5d7b989cf Mon Sep 17 00:00:00 2001 +From 18a617e9e0f64b727938422d4f941dfddfbf5d00 Mon Sep 17 00:00:00 2001 From: Tomas Orsava 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 | 10 ++++++++++ - 1 file changed, 10 insertions(+) + pip/commands/install.py | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) -diff --git a/commands/install.py b/commands/install.py -index 227c526..88c7c58 100644 +diff --git a/pip/commands/install.py b/pip/commands/install.py +index 227c526..277a3d1 100644 --- a/pip/commands/install.py +++ b/pip/commands/install.py @@ -6,6 +6,8 @@ import os @@ -20,12 +20,16 @@ index 227c526..88c7c58 100644 try: import wheel except ImportError: -@@ -193,6 +195,14 @@ class InstallCommand(RequirementCommand): +@@ -193,6 +195,18 @@ class InstallCommand(RequirementCommand): cmdoptions.resolve_wheel_no_use_binary(options) cmdoptions.check_install_build_global(options) -+ # Check whether we have root privileges -+ if os.getuid() == 0: ++ 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(): + logger.warning( + "WARNING: Running pip install with root privileges is" + "generally not a good idea. Try `%s install --user` instead." diff --git a/python-pip.spec b/python-pip.spec index c5b0bac..379b005 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -17,7 +17,7 @@ Name: python-%{srcname} Version: 9.0.1 -Release: 7%{?dist} +Release: 8%{?dist} Summary: A tool for installing and managing Python packages Group: Development/Libraries @@ -244,6 +244,9 @@ py.test-%{python3_version} -m 'not network' %endif # with_python3 %changelog +* Fri Mar 03 2017 Tomas Orsava - 9.0.1-8 +- Patch 1 update: No sudo pip warning in venv or virtualenv + * Thu Feb 23 2017 Tomas Orsava - 9.0.1-7 - Patch 1 update: Customize the warning with the proper version of the pip command