From 50a1ddab5c6126f8f91c16e78e9595c3388f7f13 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Wed, 6 Mar 2019 07:57:21 -0800 Subject: [PATCH 1/2] Revert "Revert "Strip Python wheel binary"" This reverts commit 04609b1ea5aa743182f0d910d86d054a113f60e6. --- test/distrib/python/test_packages.sh | 2 +- .../artifacts/build_package_python.sh | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/test/distrib/python/test_packages.sh b/test/distrib/python/test_packages.sh index 755daa10211..433148e6bd7 100755 --- a/test/distrib/python/test_packages.sh +++ b/test/distrib/python/test_packages.sh @@ -41,7 +41,7 @@ PYTHON=$VIRTUAL_ENV/bin/python function at_least_one_installs() { for file in "$@"; do - if "$PYTHON" -m pip install "$file"; then + if "$PYTHON" -m pip install --require-hashes "$file"; then return 0 fi done diff --git a/tools/run_tests/artifacts/build_package_python.sh b/tools/run_tests/artifacts/build_package_python.sh index 29801a5b867..193d75db62a 100755 --- a/tools/run_tests/artifacts/build_package_python.sh +++ b/tools/run_tests/artifacts/build_package_python.sh @@ -23,6 +23,24 @@ mkdir -p artifacts/ # and we only collect them here to deliver them to the distribtest phase. cp -r "${EXTERNAL_GIT_ROOT}"/input_artifacts/python_*/* artifacts/ || true +strip_binary_wheel() { + WHEEL_PATH="$1" + TEMP_WHEEL_DIR=$(mktemp -d) + wheel unpack "$WHEEL_PATH" -d "$TEMP_WHEEL_DIR" + find "$TEMP_WHEEL_DIR" -name "_protoc_compiler*.so" -exec strip --strip-debug {} ";" + find "$TEMP_WHEEL_DIR" -name "cygrpc*.so" -exec strip --strip-debug {} ";" + + WHEEL_FILE=$(basename "$WHEEL_PATH") + DISTRIBUTION_NAME=$(basename "$WHEEL_PATH" | cut -d '-' -f 1) + VERSION=$(basename "$WHEEL_PATH" | cut -d '-' -f 2) + wheel pack "$TEMP_WHEEL_DIR/$DISTRIBUTION_NAME-$VERSION" -d "$TEMP_WHEEL_DIR" + mv "$TEMP_WHEEL_DIR/$WHEEL_FILE" "$WHEEL_PATH" +} + +for wheel in artifacts/*.whl; do + strip_binary_wheel "$wheel" +done + # TODO: all the artifact builder configurations generate a grpcio-VERSION.tar.gz # source distribution package, and only one of them will end up # in the artifacts/ directory. They should be all equivalent though. From 4814972080ea8490085e6fb60e31c6e96cb50771 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Wed, 6 Mar 2019 15:00:02 -0800 Subject: [PATCH 2/2] Install `wheel` right before use it --- tools/run_tests/artifacts/build_package_python.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/run_tests/artifacts/build_package_python.sh b/tools/run_tests/artifacts/build_package_python.sh index 193d75db62a..29a26bc081c 100755 --- a/tools/run_tests/artifacts/build_package_python.sh +++ b/tools/run_tests/artifacts/build_package_python.sh @@ -23,17 +23,20 @@ mkdir -p artifacts/ # and we only collect them here to deliver them to the distribtest phase. cp -r "${EXTERNAL_GIT_ROOT}"/input_artifacts/python_*/* artifacts/ || true +apt-get install -y python-pip +python -m pip install wheel --user + strip_binary_wheel() { WHEEL_PATH="$1" TEMP_WHEEL_DIR=$(mktemp -d) - wheel unpack "$WHEEL_PATH" -d "$TEMP_WHEEL_DIR" + python -m wheel unpack "$WHEEL_PATH" -d "$TEMP_WHEEL_DIR" find "$TEMP_WHEEL_DIR" -name "_protoc_compiler*.so" -exec strip --strip-debug {} ";" find "$TEMP_WHEEL_DIR" -name "cygrpc*.so" -exec strip --strip-debug {} ";" WHEEL_FILE=$(basename "$WHEEL_PATH") DISTRIBUTION_NAME=$(basename "$WHEEL_PATH" | cut -d '-' -f 1) VERSION=$(basename "$WHEEL_PATH" | cut -d '-' -f 2) - wheel pack "$TEMP_WHEEL_DIR/$DISTRIBUTION_NAME-$VERSION" -d "$TEMP_WHEEL_DIR" + python -m wheel pack "$TEMP_WHEEL_DIR/$DISTRIBUTION_NAME-$VERSION" -d "$TEMP_WHEEL_DIR" mv "$TEMP_WHEEL_DIR/$WHEEL_FILE" "$WHEEL_PATH" }