From e7a739456f6596ddf4e0599a50d26f433aa6b7f9 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 28 Jul 2022 18:04:01 +0000 Subject: [PATCH 01/11] fix: restore support for grpcio-gcp --- .github/sync-repo-settings.yaml | 4 ++ .github/workflows/unittest.yml | 2 +- google/api_core/grpc_helpers.py | 31 +++++++++++- noxfile.py | 15 ++++++ setup.py | 2 + testing/constraints-3.7.txt | 1 + tests/unit/test_grpc_helpers.py | 87 ++++++++++++++++++++++++++++----- 7 files changed, 126 insertions(+), 16 deletions(-) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index b06a42ac..e4ec2b78 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -11,6 +11,10 @@ branchProtectionRules: # No Kokoro: the following are Github actions - 'lint' - 'mypy' + - 'unit_grpc_gcp-3.7' + - 'unit_grpc_gcp-3.8' + - 'unit_grpc_gcp-3.9' + - 'unit_grpc_gcp-3.10' - 'unit-3.6' - 'unit-3.7' - 'unit-3.8' diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 0c2e37f6..77bfc2cc 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - option: ["", "_wo_grpc"] + option: ["", "_grpc_gcp", "_wo_grpc"] python: - "3.6" - "3.7" diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index 47d27726..86333ab2 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -16,6 +16,7 @@ import collections import functools +import warnings import grpc @@ -24,6 +25,16 @@ import google.auth.credentials import google.auth.transport.grpc import google.auth.transport.requests +import google.protobuf + +PROTOBUF_VERSION = google.protobuf.__version__ + +try: + import grpc_gcp + + HAS_GRPC_GCP = True +except ImportError: + HAS_GRPC_GCP = False # The list of gRPC Callable interfaces that return iterators. @@ -275,7 +286,9 @@ def create_channel( default_scopes (Sequence[str]): Default scopes passed by a Google client library. Use 'scopes' for user-defined scopes. default_host (str): The default endpoint. e.g., "pubsub.googleapis.com". - kwargs: Additional key-word args passed to :func:`grpc.secure_channel`. + kwargs: Additional key-word args passed to + :func:`grpc_gcp.secure_channel` or :func:`grpc.secure_channel`. + Note: `grpc_gcp` is only supported in environments with protobuf < 4.0.0. Returns: grpc.Channel: The created channel. @@ -294,7 +307,21 @@ def create_channel( default_host=default_host, ) - return grpc.secure_channel(target, composite_credentials, **kwargs) + if HAS_GRPC_GCP: + # The grpcio-gcp package does not support protobuf 4.x.x. + # If grpc_gcp module is available and the environment has protobuf<4.x.x + # use grpc_gcp.secure_channel, otherwise, use grpc.secure_channel + # to create grpc channel. + if int(PROTOBUF_VERSION.split('.')[0]) < 4: + warnings.warn("""Support for grpcio-gcp is deprecated. This feature will be + removed from `google-api-core` after August 1, 2023. If you need to + continue to use this feature, please pin to a specific version of + `google-api-core`.""", + DeprecationWarning + ) + return grpc_gcp.secure_channel(target, composite_credentials, **kwargs) + else: + return grpc.secure_channel(target, composite_credentials, **kwargs) _MethodCall = collections.namedtuple( diff --git a/noxfile.py b/noxfile.py index 9b71610c..51ca5302 100644 --- a/noxfile.py +++ b/noxfile.py @@ -32,6 +32,7 @@ # 'docfx' is excluded since it only needs to run in 'docs-presubmit' nox.options.sessions = [ "unit", + "unit_grpc_gcp", "unit_wo_grpc", "cover", "pytype", @@ -142,6 +143,20 @@ def unit(session): default(session) +@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10"]) +def unit_grpc_gcp(session): + """Run the unit test suite with grpcio-gcp installed.""" + constraints_path = str( + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" + ) + # Install protobuf < 4.0.0 + session.install("protobuf<4.0.0") + # Install grpcio-gcp + session.install("-e", ".[grpcgcp]", "-c", constraints_path) + + default(session) + + @nox.session(python=["3.6", "3.10"]) def unit_wo_grpc(session): """Run the unit test suite w/o grpcio installed""" diff --git a/setup.py b/setup.py index 3c40548d..0a975276 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,8 @@ ] extras = { "grpc": ["grpcio >= 1.33.2, < 2.0dev", "grpcio-status >= 1.33.2, < 2.0dev"], + "grpcgcp": "grpcio-gcp >= 0.2.2, < 1.0dev", + "grpcio-gcp": "grpcio-gcp >= 0.2.2, < 1.0dev", } diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index c3e6ad74..5802a35b 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -12,3 +12,4 @@ requests==2.18.0 packaging==14.3 grpcio==1.33.2 grpcio-status==1.33.2 +grpcio-gcp==0.2.2 diff --git a/tests/unit/test_grpc_helpers.py b/tests/unit/test_grpc_helpers.py index 649072f0..1fa6b3cf 100644 --- a/tests/unit/test_grpc_helpers.py +++ b/tests/unit/test_grpc_helpers.py @@ -365,7 +365,10 @@ def test_create_channel_implicit(grpc_secure_channel, default, composite_creds_c default.assert_called_once_with(scopes=None, default_scopes=None) - grpc_secure_channel.assert_called_once_with(target, composite_creds) + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) @mock.patch("google.auth.transport.grpc.AuthMetadataPlugin", autospec=True) @@ -397,7 +400,10 @@ def test_create_channel_implicit_with_default_host( mock.sentinel.credentials, mock.sentinel.Request, default_host=default_host ) - grpc_secure_channel.assert_called_once_with(target, composite_creds) + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) @mock.patch("grpc.composite_channel_credentials") @@ -420,7 +426,11 @@ def test_create_channel_implicit_with_ssl_creds( composite_creds_call.assert_called_once_with(ssl_creds, mock.ANY) composite_creds = composite_creds_call.return_value - grpc_secure_channel.assert_called_once_with(target, composite_creds) + + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) @mock.patch("grpc.composite_channel_credentials") @@ -442,7 +452,10 @@ def test_create_channel_implicit_with_scopes( default.assert_called_once_with(scopes=["one", "two"], default_scopes=None) - grpc_secure_channel.assert_called_once_with(target, composite_creds) + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) @mock.patch("grpc.composite_channel_credentials") @@ -464,7 +477,10 @@ def test_create_channel_implicit_with_default_scopes( default.assert_called_once_with(scopes=None, default_scopes=["three", "four"]) - grpc_secure_channel.assert_called_once_with(target, composite_creds) + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) def test_create_channel_explicit_with_duplicate_credentials(): @@ -492,7 +508,11 @@ def test_create_channel_explicit(grpc_secure_channel, auth_creds, composite_cred ) assert channel is grpc_secure_channel.return_value - grpc_secure_channel.assert_called_once_with(target, composite_creds) + + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) @mock.patch("grpc.composite_channel_credentials") @@ -512,7 +532,11 @@ def test_create_channel_explicit_scoped(grpc_secure_channel, composite_creds_cal credentials.with_scopes.assert_called_once_with(scopes, default_scopes=None) assert channel is grpc_secure_channel.return_value - grpc_secure_channel.assert_called_once_with(target, composite_creds) + + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) @mock.patch("grpc.composite_channel_credentials") @@ -536,7 +560,11 @@ def test_create_channel_explicit_default_scopes( ) assert channel is grpc_secure_channel.return_value - grpc_secure_channel.assert_called_once_with(target, composite_creds) + + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) @mock.patch("grpc.composite_channel_credentials") @@ -558,7 +586,11 @@ def test_create_channel_explicit_with_quota_project( credentials.with_quota_project.assert_called_once_with("project-foo") assert channel is grpc_secure_channel.return_value - grpc_secure_channel.assert_called_once_with(target, composite_creds) + + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) @mock.patch("grpc.composite_channel_credentials") @@ -583,7 +615,11 @@ def test_create_channel_with_credentials_file( ) assert channel is grpc_secure_channel.return_value - grpc_secure_channel.assert_called_once_with(target, composite_creds) + + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) @mock.patch("grpc.composite_channel_credentials") @@ -611,7 +647,11 @@ def test_create_channel_with_credentials_file_and_scopes( ) assert channel is grpc_secure_channel.return_value - grpc_secure_channel.assert_called_once_with(target, composite_creds) + + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) @mock.patch("grpc.composite_channel_credentials") @@ -639,11 +679,32 @@ def test_create_channel_with_credentials_file_and_default_scopes( ) assert channel is grpc_secure_channel.return_value - grpc_secure_channel.assert_called_once_with(target, composite_creds) + + if grpc_helpers.HAS_GRPC_GCP: + grpc_secure_channel.assert_called_once_with(target, composite_creds, None) + else: + grpc_secure_channel.assert_called_once_with(target, composite_creds) + +@pytest.mark.skipif( + not grpc_helpers.HAS_GRPC_GCP, reason="grpc_gcp module not available" +) +@mock.patch("grpc_gcp.secure_channel") +def test_create_channel_with_grpc_gcp(grpc_gcp_secure_channel): + target = "example.com:443" + scopes = ["test_scope"] + + credentials = mock.create_autospec(google.auth.credentials.Scoped, instance=True) + credentials.requires_scopes = True + + grpc_helpers.create_channel(target, credentials=credentials, scopes=scopes) + grpc_gcp_secure_channel.assert_called() + + credentials.with_scopes.assert_called_once_with(scopes, default_scopes=None) +@pytest.mark.skipif(grpc_helpers.HAS_GRPC_GCP, reason="grpc_gcp module not available") @mock.patch("grpc.secure_channel") -def test_create_channel(grpc_secure_channel): +def test_create_channel_without_grpc_gcp(grpc_secure_channel): target = "example.com:443" scopes = ["test_scope"] From bf2f2badb175116ffe7c86e8761f4e10a25d7ad9 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 28 Jul 2022 18:53:32 +0000 Subject: [PATCH 02/11] update support date --- google/api_core/grpc_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index 86333ab2..32b276f4 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -314,7 +314,7 @@ def create_channel( # to create grpc channel. if int(PROTOBUF_VERSION.split('.')[0]) < 4: warnings.warn("""Support for grpcio-gcp is deprecated. This feature will be - removed from `google-api-core` after August 1, 2023. If you need to + removed from `google-api-core` after January 1, 2024. If you need to continue to use this feature, please pin to a specific version of `google-api-core`.""", DeprecationWarning From 6ab58f1ede322f9799a93071801cd8da612c0ae5 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 10 Aug 2022 01:56:29 +0000 Subject: [PATCH 03/11] lint --- google/api_core/grpc_helpers.py | 9 +++++---- tests/unit/test_grpc_helpers.py | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index 32b276f4..d1d7a038 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -310,14 +310,15 @@ def create_channel( if HAS_GRPC_GCP: # The grpcio-gcp package does not support protobuf 4.x.x. # If grpc_gcp module is available and the environment has protobuf<4.x.x - # use grpc_gcp.secure_channel, otherwise, use grpc.secure_channel + # use grpc_gcp.secure_channel, otherwise, use grpc.secure_channel # to create grpc channel. - if int(PROTOBUF_VERSION.split('.')[0]) < 4: - warnings.warn("""Support for grpcio-gcp is deprecated. This feature will be + if int(PROTOBUF_VERSION.split(".")[0]) < 4: + warnings.warn( + """Support for grpcio-gcp is deprecated. This feature will be removed from `google-api-core` after January 1, 2024. If you need to continue to use this feature, please pin to a specific version of `google-api-core`.""", - DeprecationWarning + DeprecationWarning, ) return grpc_gcp.secure_channel(target, composite_credentials, **kwargs) else: diff --git a/tests/unit/test_grpc_helpers.py b/tests/unit/test_grpc_helpers.py index 1fa6b3cf..8b9fd9f1 100644 --- a/tests/unit/test_grpc_helpers.py +++ b/tests/unit/test_grpc_helpers.py @@ -685,6 +685,7 @@ def test_create_channel_with_credentials_file_and_default_scopes( else: grpc_secure_channel.assert_called_once_with(target, composite_creds) + @pytest.mark.skipif( not grpc_helpers.HAS_GRPC_GCP, reason="grpc_gcp module not available" ) From 74d4d47ee31a734375bf45af74ea55c9a598d5c2 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 30 Aug 2022 18:06:05 +0000 Subject: [PATCH 04/11] fix(deps): require protobuf 3.19.0 --- setup.py | 2 +- testing/constraints-3.7.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f9ace2e6..ad94032f 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ release_status = "Development Status :: 5 - Production/Stable" dependencies = [ "googleapis-common-protos >= 1.56.2, < 2.0dev", - "protobuf >= 3.15.0, <5.0.0dev", + "protobuf >= 3.19.0, <5.0.0dev", "google-auth >= 1.25.0, < 3.0dev", "requests >= 2.18.0, < 3.0.0dev", ] diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index 5802a35b..da562ac3 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -6,7 +6,7 @@ # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 googleapis-common-protos==1.56.2 -protobuf==3.15.0 +protobuf==3.19.0 google-auth==1.25.0 requests==2.18.0 packaging==14.3 From f7dec2505a2078c35437840605374f82d2d74c02 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 30 Aug 2022 18:11:21 +0000 Subject: [PATCH 05/11] ensure protobuf < 4 for python 3.7 unit test --- noxfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index 2e513452..2d8f1e02 100644 --- a/noxfile.py +++ b/noxfile.py @@ -149,10 +149,10 @@ def unit_grpc_gcp(session): constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - # Install protobuf < 4.0.0 - session.install("protobuf<4.0.0") # Install grpcio-gcp session.install("-e", ".[grpcgcp]", "-c", constraints_path) + # Install protobuf < 4.0.0 + session.install("protobuf<4.0.0") default(session) From 996a5cf327dcac98c966a7a20789bed1493e9e87 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 30 Aug 2022 18:30:45 +0000 Subject: [PATCH 06/11] only import grpc_gcp if protobuf < 4 --- google/api_core/grpc_helpers.py | 37 +++++++++++++++------------------ testing/constraints-3.8.txt | 2 ++ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index d1d7a038..218e8214 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -29,11 +29,21 @@ PROTOBUF_VERSION = google.protobuf.__version__ -try: - import grpc_gcp - - HAS_GRPC_GCP = True -except ImportError: +# The grpcio-gcp package only has support for protobuf < 4 +if int(PROTOBUF_VERSION.split(".")[0]) < 4: + try: + import grpc_gcp + warnings.warn( + """Support for grpcio-gcp is deprecated. This feature will be + removed from `google-api-core` after January 1, 2024. If you need to + continue to use this feature, please pin to a specific version of + `google-api-core`.""", + DeprecationWarning, + ) + HAS_GRPC_GCP = True + except ImportError: + HAS_GRPC_GCP = False +else: HAS_GRPC_GCP = False @@ -308,21 +318,8 @@ def create_channel( ) if HAS_GRPC_GCP: - # The grpcio-gcp package does not support protobuf 4.x.x. - # If grpc_gcp module is available and the environment has protobuf<4.x.x - # use grpc_gcp.secure_channel, otherwise, use grpc.secure_channel - # to create grpc channel. - if int(PROTOBUF_VERSION.split(".")[0]) < 4: - warnings.warn( - """Support for grpcio-gcp is deprecated. This feature will be - removed from `google-api-core` after January 1, 2024. If you need to - continue to use this feature, please pin to a specific version of - `google-api-core`.""", - DeprecationWarning, - ) - return grpc_gcp.secure_channel(target, composite_credentials, **kwargs) - else: - return grpc.secure_channel(target, composite_credentials, **kwargs) + return grpc_gcp.secure_channel(target, composite_credentials, **kwargs) + return grpc.secure_channel(target, composite_credentials, **kwargs) _MethodCall = collections.namedtuple( diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt index e69de29b..8d760bbd 100644 --- a/testing/constraints-3.8.txt +++ b/testing/constraints-3.8.txt @@ -0,0 +1,2 @@ +googleapis-common-protos==1.56.3 +protobuf==4.21.5 \ No newline at end of file From 7bd69053c050eb17a9d1585e56c33b02ec75348a Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 30 Aug 2022 18:45:38 +0000 Subject: [PATCH 07/11] lint --- google/api_core/grpc_helpers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index 218e8214..6023f8cb 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -33,6 +33,7 @@ if int(PROTOBUF_VERSION.split(".")[0]) < 4: try: import grpc_gcp + warnings.warn( """Support for grpcio-gcp is deprecated. This feature will be removed from `google-api-core` after January 1, 2024. If you need to From 6225d4fad49792d88b00584f8c7596c2d02c076c Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 1 Sep 2022 19:45:10 +0000 Subject: [PATCH 08/11] address review feedback --- google/api_core/grpc_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index 6023f8cb..85feba40 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -30,7 +30,7 @@ PROTOBUF_VERSION = google.protobuf.__version__ # The grpcio-gcp package only has support for protobuf < 4 -if int(PROTOBUF_VERSION.split(".")[0]) < 4: +if PROTOBUF_VERSION == "4.": try: import grpc_gcp From 5b74ea91349964365eafb0bbe08a462f5340a151 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 1 Sep 2022 19:49:29 +0000 Subject: [PATCH 09/11] fix(deps): require protobuf >= 3.20.1 --- setup.py | 2 +- testing/constraints-3.7.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ad94032f..2dd2a0cd 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ release_status = "Development Status :: 5 - Production/Stable" dependencies = [ "googleapis-common-protos >= 1.56.2, < 2.0dev", - "protobuf >= 3.19.0, <5.0.0dev", + "protobuf >= 3.20.1, <5.0.0dev", "google-auth >= 1.25.0, < 3.0dev", "requests >= 2.18.0, < 3.0.0dev", ] diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index da562ac3..fe671145 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -6,7 +6,7 @@ # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 googleapis-common-protos==1.56.2 -protobuf==3.19.0 +protobuf==3.20.1 google-auth==1.25.0 requests==2.18.0 packaging==14.3 From dcbeaa41a8e3f9a1743b363e09b67700c1cbcdc6 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 1 Sep 2022 20:08:07 +0000 Subject: [PATCH 10/11] fix typo --- google/api_core/grpc_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index 85feba40..6c1e4057 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -30,7 +30,7 @@ PROTOBUF_VERSION = google.protobuf.__version__ # The grpcio-gcp package only has support for protobuf < 4 -if PROTOBUF_VERSION == "4.": +if PROTOBUF_VERSION == "3.": try: import grpc_gcp From 08ff43a32b4242d71999fbbe0fc76debfdcb3d97 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 1 Sep 2022 20:19:40 +0000 Subject: [PATCH 11/11] properly slice version --- google/api_core/grpc_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index 6c1e4057..bf04ae4c 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -30,7 +30,7 @@ PROTOBUF_VERSION = google.protobuf.__version__ # The grpcio-gcp package only has support for protobuf < 4 -if PROTOBUF_VERSION == "3.": +if PROTOBUF_VERSION[0:2] == "3.": try: import grpc_gcp