From 53f6d098a7d79325005be594b17096ee0a82ae26 Mon Sep 17 00:00:00 2001 From: Masood Malekghassemi Date: Mon, 12 Dec 2016 15:34:34 -0800 Subject: [PATCH] Recover 'namespace'd Python distribution packages Uses dynamic loading to paper-over the negative effects of losing namespace packages in the previous commit. --- src/python/grpcio/grpc/__init__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index cfad7de42f4..3713c1fd44d 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -31,6 +31,7 @@ import abc import enum +import sys import six @@ -1342,3 +1343,24 @@ __all__ = ( 'secure_channel', 'server', ) + + +############################### Extension Shims ################################ + + +# Here to maintain backwards compatibility; avoid using these in new code! +try: + import grpc_tools + sys.modules.update({'grpc.tools': grpc_tools}) +except ImportError: + pass +try: + import grpc_health + sys.modules.update({'grpc.health': grpc_health}) +except ImportError: + pass +try: + import grpc_reflection + sys.modules.update({'grpc.reflection': grpc_reflection}) +except ImportError: + pass