1#!/bin/bash
2# Copyright 2022 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
16set -ex
17
18# avoid slow finalization after the script has exited.
19source $(dirname $0)/../../../tools/internal_ci/helper_scripts/move_src_tree_and_respawn_itself_rc
20
21# change to grpc repo root
22cd $(dirname $0)/../../..
23
24export PREPARE_BUILD_INSTALL_DEPS_PYTHON=true
25source tools/internal_ci/helper_scripts/prepare_build_macos_rc
26
27# TODO(jtattermusch): cleanup this prepare build step (needed for python artifact build)
28# install cython for all python versions
29python3.7 -m pip install -U cython setuptools==65.4.1 wheel --user
30python3.8 -m pip install -U cython setuptools==65.4.1 wheel --user
31python3.9 -m pip install -U cython setuptools==65.4.1 wheel --user
32python3.10 -m pip install -U cython setuptools==65.4.1 wheel --user
33python3.11 -m pip install -U cython setuptools==65.4.1 wheel --user
34
35# Build all python macos artifacts (this step actually builds all the binary wheels and source archives)
36tools/run_tests/task_runner.py -f artifact macos python ${TASK_RUNNER_EXTRA_FILTERS} -j 4 -x build_artifacts/sponge_log.xml || FAILED="true"
37
38# the next step expects to find the artifacts from the previous step in the "input_artifacts" folder.
39rm -rf input_artifacts
40mkdir -p input_artifacts
41cp -r artifacts/* input_artifacts/ || true
42
43# Collect the python artifact from subdirectories of input_artifacts/ to artifacts/
44# TODO(jtattermusch): when collecting the artifacts that will later be uploaded as kokoro job artifacts,
45# potentially skip some file names that would clash with linux-created artifacts.
46cp -r input_artifacts/python_*/* artifacts/ || true
47
48# TODO(jtattermusch): Here we would normally run python macos distribtests, but currently no such tests are defined
49# in distribtest_targets.py
50
51tools/internal_ci/helper_scripts/store_artifacts_from_moved_src_tree.sh
52
53if [ "$FAILED" != "" ]
54then
55  exit 1
56fi
57