xref: /aosp_15_r20/external/grpc-grpc/tools/distrib/install_all_python_modules.sh (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
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<3.0.0rc1";
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/grpcio_observability;
41    ./make_grpcio_observability.py
42    GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .
43  popd;
44  pushd tools/distrib/python/xds_protos;
45    GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .
46  popd;
47  pushd src/python;
48    for PACKAGE in ${PACKAGES}; do
49      pushd "${PACKAGE}";
50        python setup.py clean;
51        maybe_run_command preprocess
52        maybe_run_command build_package_protos
53        python -m pip install .;
54      popd;
55    done
56  popd;
57)
58