I have a directory named protos
which holds a single .proto
file, but will eventually hold many. This directory has a sibling named app
, where I would like to dump the built grpc
python files.
I'm trying to write a simple bash script that will invoke the protoc
command and build .proto
files in protos
, and output the built files to app
Below is a tree
of where I've placed each file.
├── build_protos.sh
└── trainingInstance (root module directory)
|
├── app
│ ├── app.py
| ├── (where I'd like my built files to go)
| |
| └──trainingInstance
| └──protos
| └──(where the built files actually go)
|
└── protos
└── TrainingService.proto (what I'd like to compile)
When I run build_protos.sh
, the file TrainingService.proto
is detected fine and built, but instead of placing the built file into ...trainingInstance/app/<file>
, it instead places it in ...trainingInstance/app/trainingInstance/protos/<file>
(see above).
I thought I had solved this problem by explicitly setting the proto_path
to protos
, but it doesn't seem to care either way. Below is my build_protos.sh
file:
#!/bin/bash
working_dir=$(pwd)
proto_dirs=($(pwd)/trainingInstance)
for dir in $proto_dirs
do
srcdir=$dir/protos #./trainingInstance/protos
destdir=$dir/app #./trainingInstance/app
echo Building $dir protos...
python3 -m grpc_tools.protoc\
-I $working_dir\
--proto_path=$srcdir\
--python_out=$destdir\
--grpc_python_out=$destdir\
$srcdir/*.proto #./trainingInstance/protos/*.proto
done
So does anyone know how to stop protoc from making these reflected directories in the output directory? Any help is appreciated.