Skip to content

Commit

Permalink
Handle the sed and grep difference between Linux and Darwin (milv…
Browse files Browse the repository at this point in the history
…us-io#1106)

Signed-off-by: SimFG <[email protected]>

Signed-off-by: SimFG <[email protected]>
  • Loading branch information
SimFG authored Aug 15, 2022
1 parent 0270918 commit 7078ae9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions check_proto_product.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ SCRIPTS_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
cd ${SCRIPTS_DIR}

GO_SRC_DIR="${SCRIPTS_DIR}/$1"

if [[ $(uname -s) == "Darwin" ]]; then
if ! brew --prefix --installed grep >/dev/null 2>&1; then
brew install grep
fi
export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
fi

if test -z "$(git status | grep -E "*pb2.py|*pb2_grpc.py")"; then
echo "Success to check the proto files"
exit 0
else
echo "The milvus-proto commit doesn't match with files generated by proto!"
Expand Down
9 changes: 9 additions & 0 deletions pymilvus/grpc_gen/python_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ python -m grpc_tools.protoc -I ${PROTO_DIR} --python_out=${OUTDIR}
python -m grpc_tools.protoc -I ${PROTO_DIR} --python_out=${OUTDIR} ${PROTO_DIR}/schema.proto
python -m grpc_tools.protoc -I ${PROTO_DIR} --python_out=${OUTDIR} --grpc_python_out=${OUTDIR} ${PROTO_DIR}/milvus.proto

if [[ $(uname -s) == "Darwin" ]]; then
if ! brew --prefix --installed gnu-sed >/dev/null 2>&1; then
brew install gnu-sed
fi
export PATH="/usr/local/opt/gsed/libexec/gnubin:$PATH"
fi

sed -i 's/import common_pb2 as common__pb2/from . import common_pb2 as common__pb2/' $OUTDIR/*py
sed -i 's/import schema_pb2 as schema__pb2/from . import schema_pb2 as schema__pb2/' $OUTDIR/*py
sed -i 's/import milvus_pb2 as milvus__pb2/from . import milvus_pb2 as milvus__pb2/' $OUTDIR/*py

echo "Success to generate the python proto files."

0 comments on commit 7078ae9

Please sign in to comment.