aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio_reflection
diff options
context:
space:
mode:
authorGravatar Mehrdad Afshari <mmx@google.com>2017-11-16 15:21:02 -0800
committerGravatar Mehrdad Afshari <mmx@google.com>2017-11-20 18:37:34 -0800
commit90dbd2b6701acacace74df6bbdd8bcfe2248b431 (patch)
tree1758dcd8607f09131d652d3164f02bfbd4793491 /src/python/grpcio_reflection
parent018153cd1aafcbc07cc358a1a014f404ed930266 (diff)
Alter health/reflection packages' build criterion
Using the presence of the `*_pb2_grpc` module, as opposed to the absence of the build script (`*_commands` module) is a problematic choice, because even if a generated file is present, the test infrastructure may want to regenerate it under a different environment (e.g. different Python/proto package version). This will ensure the protos always get recompiled if we have a `*_commands` module present, signaling we are in a build environment, thereby making the process hermetic.
Diffstat (limited to 'src/python/grpcio_reflection')
-rw-r--r--src/python/grpcio_reflection/setup.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/python/grpcio_reflection/setup.py b/src/python/grpcio_reflection/setup.py
index ad9e86990f..25312c7c0a 100644
--- a/src/python/grpcio_reflection/setup.py
+++ b/src/python/grpcio_reflection/setup.py
@@ -61,17 +61,8 @@ INSTALL_REQUIRES = ('protobuf>=3.3.0',
'grpcio>={version}'.format(version=grpc_version.VERSION),)
try:
- # ensure we can load the _pb2_grpc module:
- from grpc_reflection.v1alpha import reflection_pb2_grpc as _pb2_grpc
- # if we can find the _pb2_grpc module, the package has already been built.
- SETUP_REQUIRES = ()
- COMMAND_CLASS = {
- # wire up commands to no-op not to break the external dependencies
- 'preprocess': _NoOpCommand,
- 'build_package_protos': _NoOpCommand,
- }
-except ImportError: # we are in the build environment
import reflection_commands as _reflection_commands
+ # we are in the build environment, otherwise the above import fails
SETUP_REQUIRES = (
'grpcio-tools=={version}'.format(version=grpc_version.VERSION),)
COMMAND_CLASS = {
@@ -79,6 +70,13 @@ except ImportError: # we are in the build environment
'preprocess': _reflection_commands.CopyProtoModules,
'build_package_protos': _reflection_commands.BuildPackageProtos,
}
+except ImportError:
+ SETUP_REQUIRES = ()
+ COMMAND_CLASS = {
+ # wire up commands to no-op not to break the external dependencies
+ 'preprocess': _NoOpCommand,
+ 'build_package_protos': _NoOpCommand,
+ }
setuptools.setup(
name='grpcio-reflection',