1+ GRPCIO_VIRTUALENV=$(shell pwd)/grpc_python_venv
12GENERATED_DIR=$(shell pwd)/generated_python
2- BIGTABLE_DIR =$(shell pwd) /gcloud/bigtable/_generated
3- DATASTORE_DIR =$(shell pwd) /gcloud/datastore/_generated
4- GRPC_PLUGIN =grpc_python_plugin
5- PROTOC_CMD =protoc
6- BIGTABLE_PROTOS_DIR =$(shell pwd) /cloud-bigtable-client/bigtable-protos/src/main/proto
3+ GENERATED_SUBDIR=_generated
4+ BIGTABLE_DIR=$(shell pwd)/gcloud/bigtable/$(GENERATED_SUBDIR)
5+ PROTOC_CMD=$(GRPCIO_VIRTUALENV)/bin/python -m grpc.tools.protoc
76GOOGLEAPIS_PROTOS_DIR=$(shell pwd)/googleapis-pb
7+ BIGTABLE_CHECKOUT_DIR=$(shell pwd)/cloud-bigtable-client
8+ BIGTABLE_PROTOS_DIR=$(BIGTABLE_CHECKOUT_DIR)/bigtable-client-core-parent/bigtable-protos/src/main/proto
89
910help:
1011 @echo 'Makefile for gcloud-python Bigtable protos '
@@ -14,19 +15,22 @@ help:
1415 @echo ' make clean Clean generated files '
1516
1617generate:
18+ # Ensure we have a virtualenv w/ up-to-date grpcio/grpcio-tools
19+ [ -d $(GRPCIO_VIRTUALENV) ] || python2.7 -m virtualenv $(GRPCIO_VIRTUALENV)
20+ $(GRPCIO_VIRTUALENV)/bin/pip install --upgrade grpcio grpcio-tools
1721 # Retrieve git repos that have our *.proto files.
18- [ -d cloud-bigtable-client ] || git clone https://github.com/GoogleCloudPlatform/cloud-bigtable-client --depth=1
19- cd cloud-bigtable-client && git pull origin master
20- [ -d googleapis-pb ] || git clone https://github.com/google/googleapis googleapis-pb --depth=1
21- cd googleapis-pb && git pull origin master
22+ [ -d $(BIGTABLE_CHECKOUT_DIR) ] || git clone https://github.com/GoogleCloudPlatform/cloud-bigtable-client --depth=1
23+ cd $(BIGTABLE_CHECKOUT_DIR) && git pull origin master
24+ [ -d $(GOOGLEAPIS_PROTOS_DIR) ] || git clone https://github.com/google/googleapis googleapis-pb --depth=1
25+ cd $(GOOGLEAPIS_PROTOS_DIR) && git pull origin master
2226 # Make the directory where our *_pb2.py files will go.
2327 mkdir -p $(GENERATED_DIR)
2428 # Generate all *_pb2.py files that require gRPC.
2529 $(PROTOC_CMD) \
2630 --proto_path=$(BIGTABLE_PROTOS_DIR) \
31+ --proto_path=$(GOOGLEAPIS_PROTOS_DIR) \
2732 --python_out=$(GENERATED_DIR) \
28- --plugin=protoc-gen-grpc=$(GRPC_PLUGIN ) \
29- --grpc_out=$(GENERATED_DIR ) \
33+ --grpc_python_out=$(GENERATED_DIR) \
3034 $(BIGTABLE_PROTOS_DIR)/google/bigtable/v1/bigtable_service.proto \
3135 $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/cluster/v1/bigtable_cluster_service.proto \
3236 $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/table/v1/bigtable_table_service.proto
@@ -41,49 +45,37 @@ generate:
4145 $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/cluster/v1/bigtable_cluster_service_messages.proto \
4246 $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/table/v1/bigtable_table_data.proto \
4347 $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/table/v1/bigtable_table_service_messages.proto \
44- $(GOOGLEAPIS_PROTOS_DIR ) /google/datastore/v1beta3/datastore.proto \
45- $(GOOGLEAPIS_PROTOS_DIR ) /google/datastore/v1beta3/entity.proto \
46- $(GOOGLEAPIS_PROTOS_DIR ) /google/datastore/v1beta3/query.proto
4748 # Move the newly generated *_pb2.py files into our library.
48- mv $(GENERATED_DIR ) /google/bigtable/v1/* $(BIGTABLE_DIR )
49- mv $(GENERATED_DIR ) /google/bigtable/admin/cluster/v1/* $(BIGTABLE_DIR )
50- mv $(GENERATED_DIR ) /google/bigtable/admin/table/v1/* $(BIGTABLE_DIR )
51- mv $(GENERATED_DIR ) /google/datastore/v1beta3/* $(DATASTORE_DIR )
49+ cp $(GENERATED_DIR)/google/bigtable/v1/* $(BIGTABLE_DIR)
50+ cp $(GENERATED_DIR)/google/bigtable/admin/cluster/v1/* $(BIGTABLE_DIR)
51+ cp $(GENERATED_DIR)/google/bigtable/admin/table/v1/* $(BIGTABLE_DIR)
5252 # Remove all existing *.proto files before we replace
5353 rm -f $(BIGTABLE_DIR)/*.proto
54- rm -f $(DATASTORE_DIR ) /* .proto
5554 # Copy over the *.proto files into our library.
5655 cp $(BIGTABLE_PROTOS_DIR)/google/bigtable/v1/*.proto $(BIGTABLE_DIR)
5756 cp $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/cluster/v1/*.proto $(BIGTABLE_DIR)
5857 cp $(BIGTABLE_PROTOS_DIR)/google/bigtable/admin/table/v1/*.proto $(BIGTABLE_DIR)
59- cp $(BIGTABLE_PROTOS_DIR ) /google/longrunning/operations.proto $(BIGTABLE_DIR )
60- cp $(GOOGLEAPIS_PROTOS_DIR ) /google/datastore/v1beta3/* .proto $(DATASTORE_DIR )
58+ cp $(GOOGLEAPIS_PROTOS_DIR)/google/longrunning/operations.proto $(BIGTABLE_DIR)
6159 # Rename all *.proto files in our library with an
6260 # underscore and remove executable bit.
6361 cd $(BIGTABLE_DIR) && \
6462 for filename in *.proto; do \
6563 chmod -x $$filename ; \
6664 mv $$filename _$$filename ; \
6765 done
68- cd $(DATASTORE_DIR ) && \
69- for filename in * .proto; do \
70- chmod -x $$ filename ; \
71- mv $$ filename _$$ filename ; \
72- done
7366 # Separate the gRPC parts of the operations service from the
7467 # non-gRPC parts so that the protos from `googleapis-common-protos`
7568 # can be used without gRPC.
76- python scripts/make_operations_grpc.py
77- # Separate the gRPC parts of the datastore service from the
78- # non-gRPC parts so that the protos can be used without gRPC.
79- python scripts/make_datastore_grpc.py
69+ GRPCIO_VIRTUALENV="$(GRPCIO_VIRTUALENV)" \
70+ GENERATED_SUBDIR=$(GENERATED_SUBDIR) \
71+ python scripts/make_operations_grpc.py
8072 # Rewrite the imports in the generated *_pb2.py files.
81- python scripts/rewrite_imports.py
73+ python scripts/rewrite_imports.py $(BIGTABLE_DIR)/*pb2.py
8274
8375check_generate:
8476 python scripts/check_generate.py
8577
8678clean:
87- rm -fr cloud-bigtable-client $(GENERATED_DIR )
79+ rm -fr $(GRPCIO_VIRTUALENV) $(GOOGLEAPIS_PROTOS_DIR) $(GENERATED_DIR)
8880
8981.PHONY: generate check_generate clean
0 commit comments