2
2
3
3
RED=" \033[0;31m"
4
4
NC=' \033[0m'
5
- PROTOC=${PROTOC:= protoc}
6
5
7
6
PY_VER_MYPY_PROTOBUF=${PY_VER_MYPY_PROTOBUF:= 3.10.1}
8
7
PY_VER_MYPY_PROTOBUF_SHORT=$( echo $PY_VER_MYPY_PROTOBUF | cut -d. -f1-2)
@@ -16,6 +15,31 @@ if [ -e $CUSTOM_TYPESHED_DIR ]; then
16
15
export MYPYPATH=$CUSTOM_TYPESHED_DIR /stubs/protobuf
17
16
fi
18
17
18
+ # Install protoc
19
+ PROTOBUF_VERSION=$( grep " ^protobuf>=" test_requirements.txt | cut -f2 -d=)
20
+ PROTOC_DIR=" protoc_$PROTOBUF_VERSION "
21
+ if [[ -z $SKIP_CLEAN ]] || [[ ! -e $PROTOC_DIR ]]; then
22
+ if uname -a | grep Darwin; then
23
+ # brew install coreutils wget
24
+ PLAT=osx
25
+ else
26
+ PLAT=linux
27
+ fi
28
+
29
+ PROTOC_FILENAME=" protoc-${PROTOBUF_VERSION} -${PLAT} -x86_64.zip"
30
+ PROTOC_URL=" https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION} /$PROTOC_FILENAME "
31
+
32
+ rm -rf " $PROTOC_DIR "
33
+ wget " $PROTOC_URL " -P " $PROTOC_DIR "
34
+ mkdir -p " $PROTOC_DIR /protoc_install"
35
+ unzip " $PROTOC_DIR /$PROTOC_FILENAME " -d " $PROTOC_DIR /protoc_install"
36
+ fi
37
+ PROTOC=" $PROTOC_DIR /protoc_install/bin/protoc"
38
+ if [[ $( $PROTOC --version) != " libprotoc $PROTOBUF_VERSION " ]]; then
39
+ echo -e " ${RED} Wrong protoc installed?"
40
+ exit 1
41
+ fi
42
+
19
43
# Create mypy venv
20
44
MYPY_VENV=venv_$PY_VER_MYPY
21
45
(
@@ -82,11 +106,6 @@ MYPY_PROTOBUF_VENV=venv_$PY_VER_MYPY_PROTOBUF
82
106
# Generate protos
83
107
python --version
84
108
$PROTOC --version
85
- expected=" libprotoc 3.19.4"
86
- if [[ $( $PROTOC --version) != $expected ]]; then
87
- echo -e " ${RED} For tests - must install protoc version ${expected} ${NC} "
88
- exit 1
89
- fi
90
109
91
110
# CI Check to make sure generated files are committed
92
111
SHA_BEFORE=$( find test/generated -name " *.pyi" | xargs sha1sum)
0 commit comments