Only ask for keyring password once
This makes https://bugzilla.redhat.com/show_bug.cgi?id=1859476 much less painful.
This commit is contained in:
parent
aef4d01da3
commit
152f6ef002
2 changed files with 87 additions and 1 deletions
79
8744.patch
Normal file
79
8744.patch
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
From 23a2fef3919d773041f0c06e5f1a85471132098c Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||
Date: Mon, 3 Aug 2020 10:41:03 +0200
|
||||
Subject: [PATCH] When one keyring attempt fails, don't bother with more
|
||||
|
||||
This makes https://github.com/pypa/pip/issues/8090 much less painful.
|
||||
---
|
||||
news/8090.bugfix | 3 +++
|
||||
src/pip/_internal/network/auth.py | 2 ++
|
||||
tests/unit/test_networking_auth.py | 26 ++++++++++++++++++++++++++
|
||||
3 files changed, 31 insertions(+)
|
||||
create mode 100644 news/8090.bugfix
|
||||
|
||||
diff --git a/news/8090.bugfix b/news/8090.bugfix
|
||||
new file mode 100644
|
||||
index 0000000..e9f2b7c
|
||||
--- /dev/null
|
||||
+++ b/news/8090.bugfix
|
||||
@@ -0,0 +1,3 @@
|
||||
+Only attempt to use the keyring once and if it fails, don't try again.
|
||||
+This prevents spamming users with several keyring unlock prompts when they
|
||||
+cannot unlock or don't want to do so.
|
||||
diff --git a/src/pip/_internal/network/auth.py b/src/pip/_internal/network/auth.py
|
||||
index 1e1da54..c101f93 100644
|
||||
--- a/src/pip/_internal/network/auth.py
|
||||
+++ b/src/pip/_internal/network/auth.py
|
||||
@@ -45,6 +45,7 @@ except Exception as exc:
|
||||
|
||||
def get_keyring_auth(url, username):
|
||||
"""Return the tuple auth for a given url from keyring."""
|
||||
+ global keyring
|
||||
if not url or not keyring:
|
||||
return None
|
||||
|
||||
@@ -70,6 +71,7 @@ def get_keyring_auth(url, username):
|
||||
logger.warning(
|
||||
"Keyring is skipped due to an exception: %s", str(exc),
|
||||
)
|
||||
+ keyring = None
|
||||
|
||||
|
||||
class MultiDomainBasicAuth(AuthBase):
|
||||
diff --git a/tests/unit/test_networking_auth.py b/tests/unit/test_networking_auth.py
|
||||
index 0f0b679..0fc5799 100644
|
||||
--- a/tests/unit/test_networking_auth.py
|
||||
+++ b/tests/unit/test_networking_auth.py
|
||||
@@ -222,3 +222,29 @@ def test_keyring_get_credential(monkeypatch, url, expect):
|
||||
assert auth._get_new_credentials(
|
||||
url, allow_netrc=False, allow_keyring=True
|
||||
) == expect
|
||||
+
|
||||
+
|
||||
+class KeyringModuleBroken(object):
|
||||
+ """Represents the current supported API of keyring, but broken"""
|
||||
+
|
||||
+ def __init__(self):
|
||||
+ self._call_count = 0
|
||||
+
|
||||
+ def get_credential(self, system, username):
|
||||
+ self._call_count += 1
|
||||
+ raise Exception("This keyring is broken!")
|
||||
+
|
||||
+
|
||||
+def test_broken_keyring_disables_keyring(monkeypatch):
|
||||
+ keyring_broken = KeyringModuleBroken()
|
||||
+ monkeypatch.setattr(pip._internal.network.auth, 'keyring', keyring_broken)
|
||||
+
|
||||
+ auth = MultiDomainBasicAuth(index_urls=["http://example.com/"])
|
||||
+
|
||||
+ assert keyring_broken._call_count == 0
|
||||
+ for i in range(5):
|
||||
+ url = "http://example.com/path" + str(i)
|
||||
+ assert auth._get_new_credentials(
|
||||
+ url, allow_netrc=False, allow_keyring=True
|
||||
+ ) == (None, None)
|
||||
+ assert keyring_broken._call_count == 1
|
||||
--
|
||||
2.26.2
|
||||
|
||||
|
|
@ -16,7 +16,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.3.1
|
||||
Release: 3%{?dist}
|
||||
Release: 4%{?dist}
|
||||
Summary: A tool for installing and managing Python packages
|
||||
|
||||
# We bundle a lot of libraries with pip, which itself is under MIT license.
|
||||
|
|
@ -104,6 +104,9 @@ Patch6: callable-main.patch
|
|||
# Backported from https://github.com/pypa/pip/pull/7873
|
||||
Patch7: 7873.patch
|
||||
|
||||
# Backported from https://github.com/pypa/pip/pull/8744
|
||||
Patch8: 8744.patch
|
||||
|
||||
# Downstream only patch
|
||||
# Users might have local installations of pip from using
|
||||
# `pip install --user --upgrade pip` on older/newer versions.
|
||||
|
|
@ -261,6 +264,7 @@ popd
|
|||
%endif
|
||||
%patch6 -p1
|
||||
%patch7 -p1
|
||||
%patch8 -p1
|
||||
|
||||
# this goes together with patch4
|
||||
rm src/pip/_vendor/certifi/*.pem
|
||||
|
|
@ -388,6 +392,9 @@ ln -sf %{buildroot}%{_bindir}/pip3 _bin/pip
|
|||
%{python_wheeldir}/%{python_wheelname}
|
||||
|
||||
%changelog
|
||||
* Tue Aug 11 2020 Miro Hrončok <mhroncok@redhat.com> - 19.3.1-4
|
||||
- Only ask for keyring password once (#1859476)
|
||||
|
||||
* Fri Apr 10 2020 Miro Hrončok <mhroncok@redhat.com> - 19.3.1-3
|
||||
- Allow setting $TMPDIR to $PWD/... during pip wheel (#1806625)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue