Skip to content

Commit 5eb60cd

Browse files
authored
Merge branch 'main' into owl-bot-update-lock-023a21377a2a00008057f99f0118edadc30a19d1636a3fee47189ebec2f3921c
2 parents c8fe6a8 + a8f806e commit 5eb60cd

File tree

5 files changed

+78
-37
lines changed

5 files changed

+78
-37
lines changed

google/auth/transport/urllib3.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,21 @@
3434
try:
3535
import urllib3 # type: ignore
3636
import urllib3.exceptions # type: ignore
37+
from packaging import version # type: ignore
3738
except ImportError as caught_exc: # pragma: NO COVER
3839
raise ImportError(
39-
"The urllib3 library is not installed from please install the "
40-
"urllib3 package to use the urllib3 transport."
40+
""
41+
f"Error: {caught_exc}."
42+
" The 'google-auth' library requires the extras installed "
43+
"for urllib3 network transport."
44+
"\n"
45+
"Please install the necessary dependencies using pip:\n"
46+
" pip install google-auth[urllib3]\n"
47+
"\n"
48+
"(Note: Using '[urllib3]' ensures the specific dependencies needed for this feature are installed. "
49+
"We recommend running this command in your virtual environment.)"
4150
) from caught_exc
4251

43-
from packaging import version # type: ignore
4452

4553
from google.auth import environment_vars
4654
from google.auth import exceptions
@@ -414,7 +422,7 @@ def urlopen(self, method, url, body=None, headers=None, **kwargs):
414422
body=body,
415423
headers=headers,
416424
_credential_refresh_attempt=_credential_refresh_attempt + 1,
417-
**kwargs
425+
**kwargs,
418426
)
419427

420428
return response

noxfile.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ def unit(session):
8989
constraints_path = str(
9090
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
9191
)
92-
session.install("-r", "testing/requirements.txt", "-c", constraints_path)
93-
session.install("-e", ".", "-c", constraints_path)
92+
session.install("-e", ".[testing]", "-c", constraints_path)
9493
session.run(
9594
"pytest",
9695
f"--junitxml=unit_{session.python}_sponge_log.xml",
@@ -105,8 +104,7 @@ def unit(session):
105104

106105
@nox.session(python="3.8")
107106
def cover(session):
108-
session.install("-r", "testing/requirements.txt")
109-
session.install("-e", ".")
107+
session.install("-e", ".[testing]")
110108
session.run(
111109
"pytest",
112110
"--cov=google.auth",
@@ -144,8 +142,7 @@ def docs(session):
144142

145143
@nox.session(python="pypy")
146144
def pypy(session):
147-
session.install("-r", "testing/requirements.txt")
148-
session.install("-e", ".")
145+
session.install("-e", ".[testing]")
149146
session.run(
150147
"pytest",
151148
f"--junitxml=unit_{session.python}_sponge_log.xml",

setup.py

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,70 @@
2727
"rsa>=3.1.4,<5",
2828
)
2929

30+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1737): Unit test fails with
31+
# `No module named 'cryptography.hazmat.backends.openssl.x509' for Python 3.7``.
32+
cryptography_base_require = [
33+
"cryptography >= 38.0.3",
34+
"cryptography < 39.0.0; python_version < '3.8'",
35+
]
36+
37+
requests_extra_require = ["requests >= 2.20.0, < 3.0.0"]
38+
39+
aiohttp_extra_require = ["aiohttp >= 3.6.2, < 4.0.0", *requests_extra_require]
40+
41+
pyjwt_extra_require = ["pyjwt>=2.0", *cryptography_base_require]
42+
43+
reauth_extra_require = ["pyu2f>=0.1.5"]
44+
45+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1738): Add bounds for cryptography and pyopenssl dependencies.
46+
enterprise_cert_extra_require = ["cryptography", "pyopenssl"]
47+
48+
pyopenssl_extra_require = ["pyopenssl>=20.0.0", cryptography_base_require]
49+
50+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1739): Add bounds for urllib3 and packaging dependencies.
51+
urllib3_extra_require = ["urllib3", "packaging"]
52+
53+
# Unit test requirements.
54+
testing_extra_require = [
55+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1735): Remove `grpcio` from testing requirements once an extra is added for `grpcio` dependency.
56+
"grpcio",
57+
"flask",
58+
"freezegun",
59+
"mock",
60+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1736): Remove `oauth2client` from testing requirements once an extra is added for `oauth2client` dependency.
61+
"oauth2client",
62+
*pyjwt_extra_require,
63+
"pytest",
64+
"pytest-cov",
65+
"pytest-localserver",
66+
*pyopenssl_extra_require,
67+
*reauth_extra_require,
68+
"responses",
69+
*urllib3_extra_require,
70+
# Async Dependencies
71+
*aiohttp_extra_require,
72+
"aioresponses",
73+
"pytest-asyncio",
74+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1665): Remove the pinned version of pyopenssl
75+
# once `TestDecryptPrivateKey::test_success` is updated to remove the deprecated `OpenSSL.crypto.sign` and
76+
# `OpenSSL.crypto.verify` methods. See: https://www.pyopenssl.org/en/latest/changelog.html#id3.
77+
"pyopenssl < 24.3.0",
78+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1722): `test_aiohttp_requests` depend on
79+
# aiohttp < 3.10.0 which is a bug. Investigate and remove the pinned aiohttp version.
80+
"aiohttp < 3.10.0",
81+
]
82+
3083
extras = {
31-
"aiohttp": ["aiohttp >= 3.6.2, < 4.0.0.dev0", "requests >= 2.20.0, < 3.0.0.dev0"],
32-
"pyopenssl": ["pyopenssl>=20.0.0", "cryptography>=38.0.3"],
33-
"requests": "requests >= 2.20.0, < 3.0.0.dev0",
34-
"reauth": "pyu2f>=0.1.5",
35-
"enterprise_cert": ["cryptography", "pyopenssl"],
36-
"pyjwt": ["pyjwt>=2.0", "cryptography>=38.0.3"],
84+
"aiohttp": aiohttp_extra_require,
85+
"enterprise_cert": enterprise_cert_extra_require,
86+
"pyopenssl": pyopenssl_extra_require,
87+
"pyjwt": pyjwt_extra_require,
88+
"reauth": reauth_extra_require,
89+
"requests": requests_extra_require,
90+
"testing": testing_extra_require,
91+
"urllib3": urllib3_extra_require,
92+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1735): Add an extra for `grpcio` dependency.
93+
# TODO(https://github.com/googleapis/google-auth-library-python/issues/1736): Add an extra for `oauth2client` dependency.
3794
}
3895

3996
with io.open("README.rst", "r") as fh:

system_tests/secrets.tar.enc

0 Bytes
Binary file not shown.

testing/requirements.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)