瀏覽代碼

Add a modified patch from craigcitro@ to handle namespace sharing.

Silviu Calinoiu 9 年之前
父節點
當前提交
786f80fe66
共有 4 個文件被更改,包括 14 次插入2 次删除
  1. 4 1
      python/google/__init__.py
  2. 6 0
      python/google/protobuf/__init__.py
  3. 4 0
      python/google/protobuf/pyext/__init__.py
  4. 0 1
      python/setup.py

+ 4 - 1
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__)

+ 6 - 0
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__)

+ 4 - 0
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__)

+ 0 - 1
python/setup.py

@@ -210,7 +210,6 @@ if __name__ == '__main__':
         "Programming Language :: Python :: 3.3",
         "Programming Language :: Python :: 3.4",
         ],
-      namespace_packages=['google'],
       packages=find_packages(
           exclude=[
               'import_test_package',