浏览代码

Add __init__.py files to compiler and util subpackages (#4117)

The compiler and util subpackages are created by the build_py class in
setup.py. This has caused an issue in the protobuf package in
conda-forge (https://github.com/conda-forge/protobuf-feedstock/issues/40),
which is fixed by this commit.
Thomas Hisch 7 年之前
父节点
当前提交
451e0446ab
共有 5 个文件被更改,包括 3 次插入11 次删除
  1. 0 2
      .gitignore
  2. 2 0
      Makefile.am
  3. 0 0
      python/google/protobuf/compiler/__init__.py
  4. 0 0
      python/google/protobuf/util/__init__.py
  5. 1 9
      python/setup.py

+ 0 - 2
.gitignore

@@ -58,8 +58,6 @@ python/*.egg
 python/.eggs/
 python/.eggs/
 python/.tox
 python/.tox
 python/build/
 python/build/
-python/google/protobuf/compiler/
-python/google/protobuf/util/
 
 
 src/js_embed
 src/js_embed
 src/protoc
 src/protoc

+ 2 - 0
Makefile.am

@@ -763,6 +763,7 @@ python_EXTRA_DIST=                                                           \
   python/MANIFEST.in                                                         \
   python/MANIFEST.in                                                         \
   python/google/__init__.py                                                  \
   python/google/__init__.py                                                  \
   python/google/protobuf/__init__.py                                         \
   python/google/protobuf/__init__.py                                         \
+  python/google/protobuf/compiler/__init__.py                                \
   python/google/protobuf/descriptor.py                                       \
   python/google/protobuf/descriptor.py                                       \
   python/google/protobuf/descriptor_database.py                              \
   python/google/protobuf/descriptor_database.py                              \
   python/google/protobuf/descriptor_pool.py                                  \
   python/google/protobuf/descriptor_pool.py                                  \
@@ -858,6 +859,7 @@ python_EXTRA_DIST=                                                           \
   python/google/protobuf/symbol_database.py                                  \
   python/google/protobuf/symbol_database.py                                  \
   python/google/protobuf/text_encoding.py                                    \
   python/google/protobuf/text_encoding.py                                    \
   python/google/protobuf/text_format.py                                      \
   python/google/protobuf/text_format.py                                      \
+  python/google/protobuf/util/__init__.py                                    \
   python/release.sh                                                          \
   python/release.sh                                                          \
   python/mox.py                                                              \
   python/mox.py                                                              \
   python/setup.cfg                                                           \
   python/setup.cfg                                                           \

+ 0 - 0
python/google/protobuf/compiler/__init__.py


+ 0 - 0
python/google/protobuf/util/__init__.py


+ 1 - 9
python/setup.py

@@ -120,9 +120,7 @@ class clean(_clean):
       for filename in filenames:
       for filename in filenames:
         filepath = os.path.join(dirpath, filename)
         filepath = os.path.join(dirpath, filename)
         if filepath.endswith("_pb2.py") or filepath.endswith(".pyc") or \
         if filepath.endswith("_pb2.py") or filepath.endswith(".pyc") or \
-          filepath.endswith(".so") or filepath.endswith(".o") or \
-          filepath.endswith('google/protobuf/compiler/__init__.py') or \
-          filepath.endswith('google/protobuf/util/__init__.py'):
+          filepath.endswith(".so") or filepath.endswith(".o"):
           os.remove(filepath)
           os.remove(filepath)
     # _clean is an old-style class, so super() doesn't work.
     # _clean is an old-style class, so super() doesn't work.
     _clean.run(self)
     _clean.run(self)
@@ -144,12 +142,6 @@ class build_py(_build_py):
     generate_proto("../src/google/protobuf/wrappers.proto")
     generate_proto("../src/google/protobuf/wrappers.proto")
     GenerateUnittestProtos()
     GenerateUnittestProtos()
 
 
-    # Make sure google.protobuf/** are valid packages.
-    for path in ['', 'internal/', 'compiler/', 'pyext/', 'util/']:
-      try:
-        open('google/protobuf/%s__init__.py' % path, 'a').close()
-      except EnvironmentError:
-        pass
     # _build_py is an old-style class, so super() doesn't work.
     # _build_py is an old-style class, so super() doesn't work.
     _build_py.run(self)
     _build_py.run(self)