From de5ce176742606bc9e622fa589a61a95662d995d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 10 Jun 2019 13:09:38 +0200 Subject: [PATCH] Fix root warning when pip is invoked via python -m pip Fixes https://github.com/pypa/pip/issues/6576 --- emit-a-warning-when-running-with-root-privileges.patch | 7 +++++-- python-pip.spec | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/emit-a-warning-when-running-with-root-privileges.patch b/emit-a-warning-when-running-with-root-privileges.patch index 5aa0b09..9692abc 100644 --- a/emit-a-warning-when-running-with-root-privileges.patch +++ b/emit-a-warning-when-running-with-root-privileges.patch @@ -11,7 +11,7 @@ index 1279d4a..aeb9d26 100644 from optparse import SUPPRESS_HELP from pip._vendor import pkg_resources -@@ -217,6 +219,20 @@ class InstallCommand(RequirementCommand): +@@ -217,6 +219,23 @@ class InstallCommand(RequirementCommand): def run(self, options, args): cmdoptions.check_install_build_global(options) @@ -23,10 +23,13 @@ index 1279d4a..aeb9d26 100644 + + # 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( + "WARNING: Running pip install with root privileges is " + "generally not a good idea. Try `%s install --user` instead." -+ % path.basename(sys.argv[0]) ++ % command + ) + upgrade_strategy = "to-satisfy-only" diff --git a/python-pip.spec b/python-pip.spec index 7b884f7..f9b44c1 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -23,7 +23,7 @@ Name: python-%{srcname} # When updating, update the bundled libraries versions bellow! # You can use vendor_meta.sh in the dist git repo Version: 19.1.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A tool for installing and managing Python packages # We bundle a lot of libraries with pip, which itself is under MIT license. @@ -493,6 +493,9 @@ ln -sf %{buildroot}%{_bindir}/pip3 _bin/pip %endif %changelog +* Mon Jun 10 2019 Miro Hrončok - 19.1.1-2 +- Fix root warning when pip is invoked via python -m pip + * Wed May 15 2019 Miro Hrončok - 19.1.1-1 - Update to 19.1.1 (#1706995)