aboutsummaryrefslogtreecommitdiffhomepage
path: root/python
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2015-05-26 00:11:09 -0700
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2015-05-26 00:11:09 -0700
commit8e1426800e8332bcdfa9f29eb0db41d3a565b598 (patch)
tree598b07ae34540fbf32d0419d18ea806ca86bfef2 /python
parent0ac523bfeeacfebb7f46c61417b303274956c98c (diff)
Replace the check of "../.git"
Checking the existence of ".git" is not the right way to check whether we are in develop environment because we distribute source tar-balls where such a ".git" directory does not exist. Replaced it with checking .proto files.
Diffstat (limited to 'python')
-rwxr-xr-xpython/setup.py49
1 files changed, 24 insertions, 25 deletions
diff --git a/python/setup.py b/python/setup.py
index 5c321f50..f53ad5ff 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -58,11 +58,14 @@ def GetVersion():
return __version__
-def generate_proto(source):
+def generate_proto(source, require = True):
"""Invokes the Protocol Compiler to generate a _pb2.py from the given
.proto file. Does nothing if the output already exists and is newer than
the input."""
+ if not require and not os.path.exists(source):
+ return
+
output = source.replace(".proto", "_pb2.py").replace("../src/", "")
if (not os.path.exists(output) or
@@ -87,30 +90,26 @@ def generate_proto(source):
def GenerateUnittestProtos():
- # Unittest protos are only needed for development.
- if not os.path.exists("../.git"):
- return
-
- generate_proto("../src/google/protobuf/map_unittest.proto")
- generate_proto("../src/google/protobuf/unittest.proto")
- generate_proto("../src/google/protobuf/unittest_custom_options.proto")
- generate_proto("../src/google/protobuf/unittest_import.proto")
- generate_proto("../src/google/protobuf/unittest_import_public.proto")
- generate_proto("../src/google/protobuf/unittest_mset.proto")
- generate_proto("../src/google/protobuf/unittest_no_generic_services.proto")
- generate_proto("../src/google/protobuf/unittest_proto3_arena.proto")
- generate_proto("google/protobuf/internal/descriptor_pool_test1.proto")
- generate_proto("google/protobuf/internal/descriptor_pool_test2.proto")
- generate_proto("google/protobuf/internal/factory_test1.proto")
- generate_proto("google/protobuf/internal/factory_test2.proto")
- generate_proto("google/protobuf/internal/import_test_package/inner.proto")
- generate_proto("google/protobuf/internal/import_test_package/outer.proto")
- generate_proto("google/protobuf/internal/missing_enum_values.proto")
- generate_proto("google/protobuf/internal/more_extensions.proto")
- generate_proto("google/protobuf/internal/more_extensions_dynamic.proto")
- generate_proto("google/protobuf/internal/more_messages.proto")
- generate_proto("google/protobuf/internal/test_bad_identifiers.proto")
- generate_proto("google/protobuf/pyext/python.proto")
+ generate_proto("../src/google/protobuf/map_unittest.proto", False)
+ generate_proto("../src/google/protobuf/unittest.proto", False)
+ generate_proto("../src/google/protobuf/unittest_custom_options.proto", False)
+ generate_proto("../src/google/protobuf/unittest_import.proto", False)
+ generate_proto("../src/google/protobuf/unittest_import_public.proto", False)
+ generate_proto("../src/google/protobuf/unittest_mset.proto", False)
+ generate_proto("../src/google/protobuf/unittest_no_generic_services.proto", False)
+ generate_proto("../src/google/protobuf/unittest_proto3_arena.proto", False)
+ generate_proto("google/protobuf/internal/descriptor_pool_test1.proto", False)
+ generate_proto("google/protobuf/internal/descriptor_pool_test2.proto", False)
+ generate_proto("google/protobuf/internal/factory_test1.proto", False)
+ generate_proto("google/protobuf/internal/factory_test2.proto", False)
+ generate_proto("google/protobuf/internal/import_test_package/inner.proto", False)
+ generate_proto("google/protobuf/internal/import_test_package/outer.proto", False)
+ generate_proto("google/protobuf/internal/missing_enum_values.proto", False)
+ generate_proto("google/protobuf/internal/more_extensions.proto", False)
+ generate_proto("google/protobuf/internal/more_extensions_dynamic.proto", False)
+ generate_proto("google/protobuf/internal/more_messages.proto", False)
+ generate_proto("google/protobuf/internal/test_bad_identifiers.proto", False)
+ generate_proto("google/protobuf/pyext/python.proto", False)
class clean(_clean):