Merge pull request #23949 from gnossen/grpcio_tools_import

Tolerate old versions of grpcio-tools
pull/23959/head
Richard Belleville 5 years ago committed by GitHub
commit 4a2d4a0b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      src/python/grpcio/grpc/_runtime_protos.py

@ -14,20 +14,24 @@
import sys
_REQUIRED_SYMBOLS = ("_protos", "_services", "_protos_and_services")
def _uninstalled_protos(*args, **kwargs):
raise NotImplementedError(
"Install the grpcio-tools package to use the protos function.")
"Install the grpcio-tools package (1.32.0+) to use the protos function."
)
def _uninstalled_services(*args, **kwargs):
raise NotImplementedError(
"Install the grpcio-tools package to use the services function.")
"Install the grpcio-tools package (1.32.0+) to use the services function."
)
def _uninstalled_protos_and_services(*args, **kwargs):
raise NotImplementedError(
"Install the grpcio-tools package to use the protos_and_services function."
"Install the grpcio-tools package (1.32.0+) to use the protos_and_services function."
)
@ -156,6 +160,12 @@ else:
services = _uninstalled_services
protos_and_services = _uninstalled_protos_and_services
else:
from grpc_tools.protoc import _protos as protos # pylint: disable=unused-import
from grpc_tools.protoc import _services as services # pylint: disable=unused-import
from grpc_tools.protoc import _protos_and_services as protos_and_services # pylint: disable=unused-import
import grpc_tools.protoc # pylint: disable=unused-import
if all(hasattr(grpc_tools.protoc, sym) for sym in _REQUIRED_SYMBOLS):
from grpc_tools.protoc import _protos as protos # pylint: disable=unused-import
from grpc_tools.protoc import _services as services # pylint: disable=unused-import
from grpc_tools.protoc import _protos_and_services as protos_and_services # pylint: disable=unused-import
else:
protos = _uninstalled_protos
services = _uninstalled_services
protos_and_services = _uninstalled_protos_and_services

Loading…
Cancel
Save