Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2016, Google Inc. |
| 3 | # All rights reserved. |
| 4 | # |
| 5 | # Redistribution and use in source and binary forms, with or without |
| 6 | # modification, are permitted provided that the following conditions are |
| 7 | # met: |
| 8 | # |
| 9 | # * Redistributions of source code must retain the above copyright |
| 10 | # notice, this list of conditions and the following disclaimer. |
| 11 | # * Redistributions in binary form must reproduce the above |
| 12 | # copyright notice, this list of conditions and the following disclaimer |
| 13 | # in the documentation and/or other materials provided with the |
| 14 | # distribution. |
| 15 | # * Neither the name of Google Inc. nor the names of its |
| 16 | # contributors may be used to endorse or promote products derived from |
| 17 | # this software without specific prior written permission. |
| 18 | # |
| 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | set -ex |
| 32 | |
| 33 | cd $(dirname $0)/../.. |
| 34 | |
Masood Malekghassemi | 6c06189 | 2016-03-21 17:56:32 -0700 | [diff] [blame] | 35 | export GRPC_PYTHON_USE_CUSTOM_BDIST=0 |
| 36 | export GRPC_PYTHON_BUILD_WITH_CYTHON=1 |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 37 | export PYTHON=${PYTHON:-python} |
| 38 | export PIP=${PIP:-pip} |
| 39 | export AUDITWHEEL=${AUDITWHEEL:-auditwheel} |
| 40 | |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 41 | # Because multiple builds run in parallel, some distutils file |
| 42 | # operations may collide. To avoid this, each build is run in |
| 43 | # a temp directory |
| 44 | mkdir -p artifacts |
| 45 | ARTIFACT_DIR="$PWD/artifacts" |
| 46 | BUILD_DIR=`mktemp -d "${TMPDIR:-/tmp}/pygrpc.XXXXXX"` |
| 47 | trap "rm -rf $BUILD_DIR" EXIT |
| 48 | cp -r * "$BUILD_DIR" |
| 49 | cd "$BUILD_DIR" |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 50 | |
Masood Malekghassemi | 7361734 | 2016-02-18 12:39:42 -0800 | [diff] [blame] | 51 | # Build the source distribution first because MANIFEST.in cannot override |
| 52 | # exclusion of built shared objects among package resources (for some |
| 53 | # inexplicable reason). |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 54 | ${SETARCH_CMD} ${PYTHON} setup.py sdist |
Masood Malekghassemi | 7361734 | 2016-02-18 12:39:42 -0800 | [diff] [blame] | 55 | |
Masood Malekghassemi | 7361734 | 2016-02-18 12:39:42 -0800 | [diff] [blame] | 56 | # Wheel has a bug where directories don't get excluded. |
| 57 | # https://bitbucket.org/pypa/wheel/issues/99/cannot-exclude-directory |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 58 | ${SETARCH_CMD} ${PYTHON} setup.py bdist_wheel |
Masood Malekghassemi | b6d3a82 | 2016-02-11 13:08:14 -0800 | [diff] [blame] | 59 | |
Masood Malekghassemi | f6d09f2 | 2016-06-07 22:19:46 -0700 | [diff] [blame] | 60 | # Build gRPC tools package distribution |
| 61 | ${PYTHON} tools/distrib/python/make_grpcio_tools.py |
| 62 | |
Masood Malekghassemi | 2b86729 | 2016-05-05 18:17:45 -0700 | [diff] [blame] | 63 | # Build gRPC tools package source distribution |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 64 | ${SETARCH_CMD} ${PYTHON} tools/distrib/python/grpcio_tools/setup.py sdist |
Masood Malekghassemi | 2b86729 | 2016-05-05 18:17:45 -0700 | [diff] [blame] | 65 | |
| 66 | # Build gRPC tools package binary distribution |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 67 | ${SETARCH_CMD} ${PYTHON} tools/distrib/python/grpcio_tools/setup.py bdist_wheel |
Jan Tattermusch | 8640f92 | 2016-02-01 18:58:46 -0800 | [diff] [blame] | 68 | |
Ken Payson | cc17af1 | 2016-07-21 11:08:46 -0700 | [diff] [blame] | 69 | if [ "$BUILD_MANYLINUX_WHEEL" != "" ] |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 70 | then |
| 71 | for wheel in dist/*.whl; do |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 72 | ${AUDITWHEEL} repair $wheel -w "$ARTIFACT_DIR" |
Ken Payson | cc17af1 | 2016-07-21 11:08:46 -0700 | [diff] [blame] | 73 | rm $wheel |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 74 | done |
| 75 | for wheel in tools/distrib/python/grpcio_tools/dist/*.whl; do |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 76 | ${AUDITWHEEL} repair $wheel -w "$ARTIFACT_DIR" |
Ken Payson | cc17af1 | 2016-07-21 11:08:46 -0700 | [diff] [blame] | 77 | rm $wheel |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 78 | done |
Masood Malekghassemi | 010eb48 | 2016-05-03 15:59:40 -0700 | [diff] [blame] | 79 | fi |
Masood Malekghassemi | 88baf86 | 2016-05-04 06:33:15 -0700 | [diff] [blame] | 80 | |
Ken Payson | dd24c1e | 2016-07-13 14:18:33 -0700 | [diff] [blame] | 81 | # We need to use the built grpcio-tools/grpcio to compile the health proto |
| 82 | # Wheels are not supported by setup_requires/dependency_links, so we |
| 83 | # manually install the dependency. Note we should only do this if we |
| 84 | # are in a docker image or in a virtualenv. |
| 85 | if [ "$BUILD_HEALTH_CHECKING" != "" ] |
| 86 | then |
| 87 | ${PIP} install -rrequirements.txt |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 88 | ${PIP} install grpcio --no-index --find-links "file://$ARTIFACT_DIR/" |
| 89 | ${PIP} install grpcio-tools --no-index --find-links "file://$ARTIFACT_DIR/" |
Ken Payson | dd24c1e | 2016-07-13 14:18:33 -0700 | [diff] [blame] | 90 | |
| 91 | # Build gRPC health check source distribution |
| 92 | ${SETARCH_CMD} ${PYTHON} src/python/grpcio_health_checking/setup.py \ |
| 93 | preprocess build_package_protos sdist |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 94 | cp -r src/python/grpcio_health_checking/dist/* "$ARTIFACT_DIR" |
Ken Payson | dd24c1e | 2016-07-13 14:18:33 -0700 | [diff] [blame] | 95 | fi |
| 96 | |
Ken Payson | 5998cd7 | 2016-08-10 15:39:43 -0700 | [diff] [blame] | 97 | cp -r dist/* "$ARTIFACT_DIR" |
| 98 | cp -r tools/distrib/python/grpcio_tools/dist/* "$ARTIFACT_DIR" |