No sudo pip warning in venv or virtualenv
This commit is contained in:
parent
33d96860e5
commit
5a8e99c9e5
@ -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 <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 | 10 ++++++++++
|
pip/commands/install.py | 14 ++++++++++++++
|
||||||
1 file changed, 10 insertions(+)
|
1 file changed, 14 insertions(+)
|
||||||
|
|
||||||
diff --git a/commands/install.py b/commands/install.py
|
diff --git a/pip/commands/install.py b/pip/commands/install.py
|
||||||
index 227c526..88c7c58 100644
|
index 227c526..277a3d1 100644
|
||||||
--- a/pip/commands/install.py
|
--- a/pip/commands/install.py
|
||||||
+++ b/pip/commands/install.py
|
+++ b/pip/commands/install.py
|
||||||
@@ -6,6 +6,8 @@ import os
|
@@ -6,6 +6,8 @@ import os
|
||||||
@ -20,12 +20,16 @@ index 227c526..88c7c58 100644
|
|||||||
try:
|
try:
|
||||||
import wheel
|
import wheel
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -193,6 +195,14 @@ class InstallCommand(RequirementCommand):
|
@@ -193,6 +195,18 @@ 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)
|
||||||
|
|
||||||
+ # Check whether we have root privileges
|
+ def is_venv():
|
||||||
+ if os.getuid() == 0:
|
+ 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(
|
+ logger.warning(
|
||||||
+ "WARNING: Running pip install with root privileges is"
|
+ "WARNING: Running pip install with root privileges is"
|
||||||
+ "generally not a good idea. Try `%s install --user` instead."
|
+ "generally not a good idea. Try `%s install --user` instead."
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
Name: python-%{srcname}
|
Name: python-%{srcname}
|
||||||
Version: 9.0.1
|
Version: 9.0.1
|
||||||
Release: 7%{?dist}
|
Release: 8%{?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,9 @@ py.test-%{python3_version} -m 'not network'
|
|||||||
%endif # with_python3
|
%endif # with_python3
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Mar 03 2017 Tomas Orsava <torsava@redhat.com> - 9.0.1-8
|
||||||
|
- Patch 1 update: No sudo pip warning in venv or virtualenv
|
||||||
|
|
||||||
* Thu Feb 23 2017 Tomas Orsava <torsava@redhat.com> - 9.0.1-7
|
* 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
|
- Patch 1 update: Customize the warning with the proper version of the pip
|
||||||
command
|
command
|
||||||
|
Loading…
Reference in New Issue
Block a user