From 66c8ed932b9dfa59bd9396ce01e4d604fdc57fba Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 20 Sep 2024 18:50:51 +0000 Subject: [PATCH] fix: add extra for aiohttp --- google/api_core/rest_streaming_async.py | 2 +- noxfile.py | 24 ++++++++++++++-------- setup.py | 3 +++ tests/asyncio/test_rest_streaming_async.py | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/google/api_core/rest_streaming_async.py b/google/api_core/rest_streaming_async.py index d1f996f61..77e779c01 100644 --- a/google/api_core/rest_streaming_async.py +++ b/google/api_core/rest_streaming_async.py @@ -22,7 +22,7 @@ import google.auth.aio.transport except ImportError as e: # pragma: NO COVER raise ImportError( - "google-auth>=2.35.0 is required to use asynchronous rest streaming." + "google-api-core[aiohttp] is required to use asynchronous rest streaming." ) from e import google.protobuf.message diff --git a/noxfile.py b/noxfile.py index 3fc4a722c..d5e23977a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -136,20 +136,28 @@ def default(session, install_grpc=True, prerelease=False, install_auth_aio=False session, f"{constraints_dir}/constraints-{PYTHON_VERSIONS[0]}.txt" ) # This *must* be the last install command to get the package from source. - session.install("-e", ".", "--no-deps") + session.install( + "-e", "." + "[aiohttp]" if install_auth_aio else "", "--no-deps" + ) else: session.install( "-e", - ".[grpc]" if install_grpc else ".", + "." + + ( + "[grpc,aiohttp]" + if install_grpc and install_auth_aio + else ( + "[grpc]" + if install_grpc + else "[aiohttp]" + if install_auth_aio + else "" + ) + ), "-c", f"{constraints_dir}/constraints-{session.python}.txt", ) - if install_auth_aio: - session.install( - "google-auth @ git+https://git@github.com/googleapis/google-auth-library-python@8833ad6f92c3300d6645355994c7db2356bd30ad" - ) - # Print out package versions of dependencies session.run( "python", "-c", "import google.protobuf; print(google.protobuf.__version__)" @@ -261,7 +269,7 @@ def mypy(session): """Run type-checking.""" # TODO(https://github.com/googleapis/python-api-core/issues/682): # Use the latest version of mypy instead of mypy<1.11.0 - session.install(".[grpc]", "mypy<1.11.0") + session.install(".[grpc,aiohttp]", "mypy<1.11.0") session.install( "types-setuptools", "types-requests", diff --git a/setup.py b/setup.py index a9e01f49c..eb243fb29 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,9 @@ "requests >= 2.18.0, < 3.0.0.dev0", ] extras = { + "aiohttp": [ + "google-auth[aiohttp] >= 2.35.0, < 3.0.dev0", + ], "grpc": [ "grpcio >= 1.33.2, < 2.0dev", "grpcio >= 1.49.1, < 2.0dev; python_version>='3.11'", diff --git a/tests/asyncio/test_rest_streaming_async.py b/tests/asyncio/test_rest_streaming_async.py index 35820de66..e5692ab5e 100644 --- a/tests/asyncio/test_rest_streaming_async.py +++ b/tests/asyncio/test_rest_streaming_async.py @@ -35,7 +35,7 @@ if not AUTH_AIO_INSTALLED: # pragma: NO COVER pytest.skip( - "google-auth>=2.35.0 is required to use asynchronous rest streaming.", + "google-api-core[aiohttp] is required to use asynchronous rest streaming.", allow_module_level=True, )