Registry / gcp / grpcio-gcp

grpcio-gcp

JSON →
library0.2.2pypypi✓ verified 21d ago

grpcio-gcp provides gRPC extensions specifically designed for Google Cloud Platform. It allows developers to leverage GCP-specific features with gRPC client libraries, including channel pooling and configuration management. The latest release, 0.2.2, was published on September 10, 2018. While the library itself hasn't seen recent releases, its functionality is referenced and integrated into other Google client libraries, suggesting an ongoing maintenance posture for compatibility.

pip install grpcio-gcp
INSTALL
IMPORT
SIG · GRPCIO-GCP
G
grpcio-gcp
gcppythonv0.2.2
Install
2.6s avg
Import
Disk
35MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 38.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.6s · import 0.000s · 36MB
35MB installed
● package 35MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ChannelPool
from grpc_gcp import ChannelPool
from grpc_gcp import ChannelPool

This quickstart demonstrates how to initialize a `ChannelPool` using `grpcio-gcp` and an `ApiConfig`. For actual usage, you would need compiled protobuf stubs for your specific Google Cloud service and a properly defined API configuration. Authentication typically relies on `GOOGLE_APPLICATION_CREDENTIALS`.

import os from grpc_gcp import ChannelPool from grpc_gcp.proto import api_config_pb2 import grpc # NOTE: This is a conceptual example. For a real GCP service, you would need # compiled protobufs for that service and proper API configuration. # This example assumes a 'spanner.grpc.config' file exists for demonstration. # In a real scenario, you'd replace 'spanner.grpc.config' with your actual # service configuration and define the correct stub/client. # Ensure GOOGLE_APPLICATION_CREDENTIALS is set for authentication # For local development, set this environment variable: # export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/key.json" # Or ensure gcloud is authenticated: gcloud auth application-default login # Example API configuration (replace with your service's actual config) # Content of 'spanner.grpc.config' (as mentioned in PyPI usage): # channel_pool: { # max_size: 10 # max_concurrent_streams_low_watermark: 1 # } # method: { # name: "/google.spanner.v1.Spanner/*" # per_rpc_timeout_millis: 10000 # max_retries: 3 # } if not os.environ.get('GOOGLE_APPLICATION_CREDENTIALS'): print("Warning: GOOGLE_APPLICATION_CREDENTIALS not set. Auth may fail.") try: # Load configuration from a file (example placeholder) # In a real application, you would create or load a meaningful ApiConfig api_config = api_config_pb2.ApiConfig() # Assume a config file exists for a service, e.g., 'spanner.grpc.config' # This part is illustrative; actual loading depends on your config source # For this example, we'll manually set some values for demonstration api_config.channel_pool.max_size = 5 # Create a ChannelPool instance # The target would be the address of your gRPC service, e.g., 'spanner.googleapis.com:443' target_service_address = 'localhost:50051' # Replace with actual service address with ChannelPool(target_service_address, api_config) as channel_pool: print(f"Created ChannelPool for {target_service_address}") # You can now get a channel from the pool and use it with a gRPC stub channel = channel_pool.get_channel() print(f"Obtained channel: {channel}") # Example of using the channel (requires a generated stub) # For a real service, you would import and use its generated stub: # import your_service_pb2_grpc # stub = your_service_pb2_grpc.YourServiceStub(channel) # response = stub.YourMethod(your_service_pb2.YourRequest(...)) # print(response) print("ChannelPool demonstration complete.") except Exception as e: print(f"An error occurred: {e}") print("Ensure you have a gRPC service running at the target address and correct authentication.")
Debug
Known issues
gotchaThe `grpcio-gcp` library itself has not had a new release since September 2018 (v0.2.2). While it is still functional and utilized by other Google client libraries, direct development on this specific package appears to be minimal. Users should be aware of its static nature when planning long-term dependencies.
fix
Be mindful of potential compatibility issues with very new Python, `grpcio`, or `protobuf` versions. Test thoroughly with your specific dependency stack. Consider if newer Google Cloud client libraries (which might internally use similar logic) are a more actively maintained alternative.
affects: <=0.2.2
breaking`google-api-core` (a common dependency for Google Cloud Python client libraries) temporarily dropped support for `grpc-gcp` in version 2.8.2 (June 2022) before restoring it later. This indicates potential volatility or specific version requirements for interoperation. Users might encounter issues if using incompatible `google-api-core` versions.
fix
Refer to the `google-api-core` changelog (or your specific Google Cloud client library's dependencies) to ensure compatibility. If encountering issues, try pinning `google-api-core` to a version known to work with `grpcio-gcp`.
affects: google-api-core==2.8.2
gotchaThe gRPC ecosystem, including `grpcio` and `protobuf`, frequently experiences compatibility issues between versions. Specifically, `grpcio-tools` often requires a narrow range of `protobuf` versions (e.g., `<=3.20.1` for older `grpcio-tools`). These incompatibilities can lead to installation failures or runtime errors.
fix
Carefully manage your `grpcio`, `grpcio-tools`, and `protobuf` versions. If you encounter installation or runtime errors related to protobuf, try explicitly pinning `protobuf` to an older version (e.g., `protobuf<4.0.0` or `protobuf<=3.20.1`) that is known to be compatible with your `grpcio` and `grpcio-tools` versions. Consult specific error messages and community forums for known working combinations.
affects: All versions, due to upstream dependencies
gotchaAuthentication with Google Cloud services typically requires `GOOGLE_APPLICATION_CREDENTIALS` to be set or `gcloud auth application-default login` to have been run. Failing to configure authentication will result in permission errors when attempting to connect to GCP services.
fix
Ensure that your environment is properly authenticated to Google Cloud. Set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path of a service account key file, or use `gcloud auth application-default login` for user-based authentication in development environments.
affects: All versions
Upgrade
Version history
0.2.2latest on PyPI · released Sep 10, 2018
Audit
Dependencies
grpciorequiredCore gRPC framework, on which grpcio-gcp builds.
google-authrequiredRequired for Google Cloud authentication.
grpcio-toolsoptionalUseful for generating gRPC client stubs from .proto files, often used in conjunction with grpcio.
Agent activity
35 hits · last 30 days
node
28
Amazon
1
OpenAI (training)
1
Resources
grpcio-gcp — pip install grpcio-gcp · libregistry