1#!/bin/bash
2# Copyright 2020 The 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
16# TODO: Integrate this into CI to avoid bitrot.
17
18echo "It's recommended that you run this script from a virtual environment."
19
20function maybe_run_command () {
21  if python setup.py --help-commands | grep "$1" &>/dev/null; then
22    python setup.py "$1";
23  fi
24}
25
26set -e
27
28BASEDIR=$(dirname "$0")
29BASEDIR=$(realpath "$BASEDIR")/../..
30
31PACKAGES="grpcio_channelz  grpcio_csds  grpcio_admin grpcio_health_checking  grpcio_reflection  grpcio_status  grpcio_testing  grpcio_tests"
32
33(cd "$BASEDIR";
34  pip install --upgrade cython;
35  python setup.py install;
36  pushd tools/distrib/python/grpcio_tools;
37    ../make_grpcio_tools.py
38    GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .
39  popd;
40  pushd src/python;
41    for PACKAGE in ${PACKAGES}; do
42      pushd "${PACKAGE}";
43        python setup.py clean;
44        maybe_run_command preprocess
45        maybe_run_command build_package_protos
46        python setup.py install;
47      popd;
48    done
49  popd;
50)
51