• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2016 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
18cd "$(dirname "$0")/../../.."
19
20mkdir -p artifacts/
21
22# All the python packages have been built in the artifact phase already
23# and we only collect them here to deliver them to the distribtest phase.
24cp -r "${EXTERNAL_GIT_ROOT}"/input_artifacts/python_*/* artifacts/ || true
25
26apt-get install -y python-pip
27python -m pip install -U pip
28python -m pip install -U wheel
29
30strip_binary_wheel() {
31    WHEEL_PATH="$1"
32    TEMP_WHEEL_DIR=$(mktemp -d)
33    python -m wheel unpack "$WHEEL_PATH" -d "$TEMP_WHEEL_DIR"
34    find "$TEMP_WHEEL_DIR" -name "_protoc_compiler*.so" -exec strip --strip-debug {} ";"
35    find "$TEMP_WHEEL_DIR" -name "cygrpc*.so" -exec strip --strip-debug {} ";"
36
37    WHEEL_FILE=$(basename "$WHEEL_PATH")
38    DISTRIBUTION_NAME=$(basename "$WHEEL_PATH" | cut -d '-' -f 1)
39    VERSION=$(basename "$WHEEL_PATH" | cut -d '-' -f 2)
40    python -m wheel pack "$TEMP_WHEEL_DIR/$DISTRIBUTION_NAME-$VERSION" -d "$TEMP_WHEEL_DIR"
41    mv "$TEMP_WHEEL_DIR/$WHEEL_FILE" "$WHEEL_PATH"
42}
43
44for wheel in artifacts/*.whl; do
45    strip_binary_wheel "$wheel"
46done
47
48# TODO: all the artifact builder configurations generate a grpcio-VERSION.tar.gz
49# source distribution package, and only one of them will end up
50# in the artifacts/ directory. They should be all equivalent though.
51