1#!/bin/bash 2# Copyright 2020 gRPC authors. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16trap 'date' DEBUG 17set -ex 18 19# change to grpc repo root 20pushd "${KOKORO_ARTIFACTS_DIR}/github/grpc" 21 22# Note: we don't use venv here because then per-language build files would need 23# to source this script to have venv python be on the PATH. This would require 24# backport this change to ~30 branches. Instead, we just install pip packages 25# globally here. If this ever breaks, uncomment the following lines, remove 26# sudo from pip install, and do the backports. 27# 28# sudo DEBIAN_FRONTEND=noninteractive apt-get -qq update 29# sudo DEBIAN_FRONTEND=noninteractive apt-get -qq install --auto-remove "python3.10-venv" 30# VIRTUAL_ENV=$(mktemp -d) 31# python3 -m venv "${VIRTUAL_ENV}" 32# source "${VIRTUAL_ENV}/bin/activate" 33 34sudo python3 -m pip install --upgrade pip==19.3.1 35# TODO(sergiitk): Unpin grpcio-tools when a version of xds-protos 36# compatible with protobuf 4.X is uploaded to PyPi. 37sudo python3 -m pip install --upgrade grpcio grpcio-tools==1.48.1 google-api-python-client google-auth-httplib2 oauth2client xds-protos 38 39# Prepare generated Python code. 40TOOLS_DIR=tools/run_tests 41PROTO_SOURCE_DIR=src/proto/grpc/testing 42PROTO_DEST_DIR=${TOOLS_DIR}/${PROTO_SOURCE_DIR} 43mkdir -p ${PROTO_DEST_DIR} 44 45python3 -m grpc_tools.protoc \ 46 --proto_path=. \ 47 --python_out=${TOOLS_DIR} \ 48 --grpc_python_out=${TOOLS_DIR} \ 49 ${PROTO_SOURCE_DIR}/test.proto \ 50 ${PROTO_SOURCE_DIR}/messages.proto \ 51 ${PROTO_SOURCE_DIR}/empty.proto 52 53HEALTH_PROTO_SOURCE_DIR=src/proto/grpc/health/v1 54HEALTH_PROTO_DEST_DIR=${TOOLS_DIR}/${HEALTH_PROTO_SOURCE_DIR} 55mkdir -p ${HEALTH_PROTO_DEST_DIR} 56 57python3 -m grpc_tools.protoc \ 58 --proto_path=. \ 59 --python_out=${TOOLS_DIR} \ 60 --grpc_python_out=${TOOLS_DIR} \ 61 ${HEALTH_PROTO_SOURCE_DIR}/health.proto 62 63popd 64