Skip to content

Commit 3fbe2ec

Browse files
committed
Upgrading Makefile to generate datastore v1beta3.
Also - Removing `v1beta2` generated code and `.proto` file - Adding new `.proto` files and generated code - Adding `make_datastore_grpc.py` script to tear out the `protoc` inserted lines by the gRPC plugin - Updating `rewrite_imports.py` to rewrite the datastore imports
1 parent 323eff8 commit 3fbe2ec

File tree

13 files changed

+3459
-2646
lines changed

13 files changed

+3459
-2646
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ scripts/pylintrc_reduced
5353
# Directories used for creating generated PB2 files
5454
generated_python/
5555
cloud-bigtable-client/
56+
googleapis-pb/

Makefile

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
GENERATED_DIR=$(shell pwd)/generated_python
22
BT_DIR=$(shell pwd)/gcloud/bigtable/_generated
3+
DS_DIR=$(shell pwd)/gcloud/datastore/_generated
34
GRPC_PLUGIN=grpc_python_plugin
45
PROTOC_CMD=protoc
56
BT_PROTOS_DIR=$(shell pwd)/cloud-bigtable-client/bigtable-protos/src/main/proto
7+
DS_PROTOS_DIR=$(shell pwd)/googleapis-pb
68

79
help:
810
@echo 'Makefile for gcloud-python Bigtable protos '
@@ -12,8 +14,12 @@ help:
1214
@echo ' make clean Clean generated files '
1315

1416
generate:
15-
[ -d cloud-bigtable-client ] || git clone https://github.com/GoogleCloudPlatform/cloud-bigtable-client
17+
# Retrieve git repos that have our *.proto files.
18+
[ -d cloud-bigtable-client ] || git clone https://github.com/GoogleCloudPlatform/cloud-bigtable-client --depth=1
1619
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+
# Make the directory where our *_pb2.py files will go.
1723
mkdir -p $(GENERATED_DIR)
1824
# Generate all *_pb2.py files that require gRPC.
1925
$(PROTOC_CMD) \
@@ -27,35 +33,50 @@ generate:
2733
# Generate all *_pb2.py files that do not require gRPC.
2834
$(PROTOC_CMD) \
2935
--proto_path=$(BT_PROTOS_DIR) \
36+
--proto_path=$(DS_PROTOS_DIR) \
3037
--python_out=$(GENERATED_DIR) \
3138
$(BT_PROTOS_DIR)/google/bigtable/v1/bigtable_data.proto \
3239
$(BT_PROTOS_DIR)/google/bigtable/v1/bigtable_service_messages.proto \
3340
$(BT_PROTOS_DIR)/google/bigtable/admin/cluster/v1/bigtable_cluster_data.proto \
3441
$(BT_PROTOS_DIR)/google/bigtable/admin/cluster/v1/bigtable_cluster_service_messages.proto \
3542
$(BT_PROTOS_DIR)/google/bigtable/admin/table/v1/bigtable_table_data.proto \
36-
$(BT_PROTOS_DIR)/google/bigtable/admin/table/v1/bigtable_table_service_messages.proto
43+
$(BT_PROTOS_DIR)/google/bigtable/admin/table/v1/bigtable_table_service_messages.proto \
44+
$(DS_PROTOS_DIR)/google/datastore/v1beta3/datastore.proto \
45+
$(DS_PROTOS_DIR)/google/datastore/v1beta3/entity.proto \
46+
$(DS_PROTOS_DIR)/google/datastore/v1beta3/query.proto
3747
# Move the newly generated *_pb2.py files into our library.
3848
mv $(GENERATED_DIR)/google/bigtable/v1/* $(BT_DIR)
3949
mv $(GENERATED_DIR)/google/bigtable/admin/cluster/v1/* $(BT_DIR)
4050
mv $(GENERATED_DIR)/google/bigtable/admin/table/v1/* $(BT_DIR)
51+
mv $(GENERATED_DIR)/google/datastore/v1beta3/* $(DS_DIR)
4152
# Remove all existing *.proto files before we replace
4253
rm -f $(BT_DIR)/*.proto
54+
rm -f $(DS_DIR)/*.proto
4355
# Copy over the *.proto files into our library.
4456
cp $(BT_PROTOS_DIR)/google/bigtable/v1/*.proto $(BT_DIR)
4557
cp $(BT_PROTOS_DIR)/google/bigtable/admin/cluster/v1/*.proto $(BT_DIR)
4658
cp $(BT_PROTOS_DIR)/google/bigtable/admin/table/v1/*.proto $(BT_DIR)
4759
cp $(BT_PROTOS_DIR)/google/longrunning/operations.proto $(BT_DIR)
60+
cp $(DS_PROTOS_DIR)/google/datastore/v1beta3/*.proto $(DS_DIR)
4861
# Rename all *.proto files in our library with an
4962
# underscore and remove executable bit.
5063
cd $(BT_DIR) && \
5164
for filename in *.proto; do \
5265
chmod -x $$filename ; \
5366
mv $$filename _$$filename ; \
5467
done
68+
cd $(DS_DIR) && \
69+
for filename in *.proto; do \
70+
chmod -x $$filename ; \
71+
mv $$filename _$$filename ; \
72+
done
5573
# Separate the gRPC parts of the operations service from the
5674
# non-gRPC parts so that the protos from `googleapis-common-protos`
5775
# can be used without gRPC.
5876
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
5980
# Rewrite the imports in the generated *_pb2.py files.
6081
python scripts/rewrite_imports.py
6182

0 commit comments

Comments
 (0)