commit:     a50bfe9db8555b380955a2f4ad80ebfc336335da
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 14 06:40:04 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 14 06:43:22 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a50bfe9d

dev-python/google-auth: Apply patch for urllib3-2 compatibility

Bug: https://github.com/googleapis/google-auth-library-python/pull/1290
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../files/google-auth-2.20.0-urllib3-2.patch       | 68 ++++++++++++++++++++++
 dev-python/google-auth/google-auth-2.20.0.ebuild   |  7 ++-
 2 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/dev-python/google-auth/files/google-auth-2.20.0-urllib3-2.patch 
b/dev-python/google-auth/files/google-auth-2.20.0-urllib3-2.patch
new file mode 100644
index 000000000000..791edeed09cf
--- /dev/null
+++ b/dev-python/google-auth/files/google-auth-2.20.0-urllib3-2.patch
@@ -0,0 +1,68 @@
+From 9ed006d02d7c9de3e6898ee819648c2fd3367c1d Mon Sep 17 00:00:00 2001
+From: Daniel Garcia Moreno <[email protected]>
+Date: Wed, 10 May 2023 09:18:57 +0200
+Subject: [PATCH] Support urllib3 >= 2.0.0
+
+The urllib3.request.RequestMethods has been moved to
+urllib3._request_methods.RequestMethods.
+
+This patch changes the usage to continue working with the latest
+release, but now it's a "private" class in a "private" module, so maybe
+it's worth to start to think about updating this code to use the public
+API.
+
+https://urllib3.readthedocs.io/en/stable/changelog.html#removed
+---
+ google/auth/transport/urllib3.py | 11 ++++++-----
+ setup.py                         |  2 +-
+ 2 files changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/google/auth/transport/urllib3.py 
b/google/auth/transport/urllib3.py
+index 4abc26b52..f1dd35320 100644
+--- a/google/auth/transport/urllib3.py
++++ b/google/auth/transport/urllib3.py
+@@ -95,8 +95,8 @@ class Request(transport.Request):
+         credentials.refresh(request)
+ 
+     Args:
+-        http (urllib3.request.RequestMethods): An instance of any urllib3
+-            class that implements :class:`~urllib3.request.RequestMethods`,
++        http (urllib3._request_methods.RequestMethods): An instance of any 
urllib3
++            class that implements 
:class:`~urllib3._request_methods.RequestMethods`,
+             usually :class:`urllib3.PoolManager`.
+ 
+     .. automethod:: __call__
+@@ -184,7 +184,7 @@ def _make_mutual_tls_http(cert, key):
+     return http
+ 
+ 
+-class AuthorizedHttp(urllib3.request.RequestMethods):
++class AuthorizedHttp(urllib3._request_methods.RequestMethods):
+     """A urllib3 HTTP class with credentials.
+ 
+     This class is used to perform requests to API endpoints that require
+@@ -197,8 +197,9 @@ class AuthorizedHttp(urllib3.request.RequestMethods):
+         response = authed_http.request(
+             'GET', 'https://www.googleapis.com/storage/v1/b')
+ 
+-    This class implements :class:`urllib3.request.RequestMethods` and can be
+-    used just like any other :class:`urllib3.PoolManager`.
++    This class implements
++    :class:`urllib3._request_methods.RequestMethods` and can be used
++    just like any other :class:`urllib3.PoolManager`.
+ 
+     The underlying :meth:`urlopen` implementation handles adding the
+     credentials' headers to the request and refreshing credentials as needed.
+diff --git a/setup.py b/setup.py
+index e45512a02..cfb3b504f 100644
+--- a/setup.py
++++ b/setup.py
+@@ -29,7 +29,7 @@
+     # install enum34 to support 2.7. enum34 only works up to python version 
3.3.
+     'enum34>=1.1.10; python_version < "3.4"',
+     "six>=1.9.0",
+-    "urllib3<2.0",
++    "urllib3>=2.0",
+ )
+ 
+ extras = {

diff --git a/dev-python/google-auth/google-auth-2.20.0.ebuild 
b/dev-python/google-auth/google-auth-2.20.0.ebuild
index c7a6aff8ed05..fae7f6b53c35 100644
--- a/dev-python/google-auth/google-auth-2.20.0.ebuild
+++ b/dev-python/google-auth/google-auth-2.20.0.ebuild
@@ -40,12 +40,17 @@ BDEPEND="
                dev-python/pyu2f[${PYTHON_USEDEP}]
                dev-python/requests[${PYTHON_USEDEP}]
                dev-python/responses[${PYTHON_USEDEP}]
-               <dev-python/urllib3-2[${PYTHON_USEDEP}]
+               >=dev-python/urllib3-2[${PYTHON_USEDEP}]
        )
 "
 
 distutils_enable_tests pytest
 
+PATCHES=(
+       # https://github.com/googleapis/google-auth-library-python/pull/1290
+       "${FILESDIR}"/google-auth-2.20.0-urllib3-2.patch
+)
+
 EPYTEST_IGNORE=(
        # these are compatibility tests with oauth2client
        # disable them to unblock removal of that package

Reply via email to