diff --git a/python/google/__init__.py b/python/google/__init__.py index de40ea7ca058e..5585614122997 100755 --- a/python/google/__init__.py +++ b/python/google/__init__.py @@ -1 +1,4 @@ -__import__('pkg_resources').declare_namespace(__name__) +try: + __import__('pkg_resources').declare_namespace(__name__) +except ImportError: + __path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/python/google/protobuf/__init__.py b/python/google/protobuf/__init__.py index 533821c16a3a4..5d2441919c4fc 100755 --- a/python/google/protobuf/__init__.py +++ b/python/google/protobuf/__init__.py @@ -31,3 +31,9 @@ # Copyright 2007 Google Inc. All Rights Reserved. __version__ = '3.0.0b2' + +if __name__ != '__main__': + try: + __import__('pkg_resources').declare_namespace(__name__) + except ImportError: + __path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/python/google/protobuf/pyext/__init__.py b/python/google/protobuf/pyext/__init__.py index e69de29bb2d1d..5585614122997 100644 --- a/python/google/protobuf/pyext/__init__.py +++ b/python/google/protobuf/pyext/__init__.py @@ -0,0 +1,4 @@ +try: + __import__('pkg_resources').declare_namespace(__name__) +except ImportError: + __path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/python/setup.py b/python/setup.py index 6ea3bad736565..24ac53dbda98b 100755 --- a/python/setup.py +++ b/python/setup.py @@ -210,7 +210,6 @@ def run(self): "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", ], - namespace_packages=['google'], packages=find_packages( exclude=[ 'import_test_package',