|
| 1 | +#!/bin/bash |
| 2 | +# This script builds a docker container, and pip wheels for all supported |
| 3 | +# Python versions. Run from the root tensorflow-text directory: |
| 4 | +# |
| 5 | +# ./oss_scripts/docker_builds.sh |
| 6 | + |
| 7 | +set -e -x |
| 8 | + |
| 9 | +# If a specific PYTHON_VERSION is specified, only build that one. |
| 10 | +# Otherwisebuild all supported versions. |
| 11 | +python_versions=("3.9" "3.10" "3.11" "3.12") |
| 12 | +if [[ ! -z ${PYTHON_VERSION+x} ]]; then |
| 13 | + python_versions=("$PYTHON_VERSION") |
| 14 | +fi |
| 15 | + |
| 16 | +# Clean previous images. |
| 17 | +for python_version in ${python_versions[@]} |
| 18 | +do |
| 19 | + docker rmi -f tensorflow_text:${python_version} || true |
| 20 | +done |
| 21 | + |
| 22 | +arch=$(uname -m) |
| 23 | +build_args=() |
| 24 | +if [ "$arch" == "x86_64" ]; then |
| 25 | + build_args+=("--config=release_cpu_linux") |
| 26 | + build_args+=("--platforms=@sigbuild-r2.17-clang_config_platform//:platform") |
| 27 | + auditwheel_platform="manylinux2014_x86_64" |
| 28 | +elif [ "$arch" == "aarch64" ]; then |
| 29 | + build_args+=("--crosstool_top=@ml2014_aarch64_config_aarch64//crosstool:toolchain") |
| 30 | + auditwheel_platform="manylinux2014_aarch64" |
| 31 | +fi |
| 32 | + |
| 33 | +# Build wheel for each Python version. |
| 34 | +for python_version in ${python_versions[@]} |
| 35 | +do |
| 36 | + DOCKER_BUILDKIT=1 docker build --progress=plain --no-cache \ |
| 37 | + --build-arg HERMETIC_PYTHON_VERSION=${python_version} --build-arg PYTHON_VERSION=${python_version} \ |
| 38 | + -t tensorflow_text:${python_version} - < "oss_scripts/build.Dockerfile.${arch}" |
| 39 | + |
| 40 | + docker run --rm -a stdin -a stdout -a stderr \ |
| 41 | + --env PYTHON_VERSION=${python_version} \ |
| 42 | + --env HERMETIC_PYTHON_VERSION=${python_version} \ |
| 43 | + --env BUILD_ARGS=${build_args} \ |
| 44 | + --env AUDITWHEEL_PLATFORM=${auditwheel_platform} \ |
| 45 | + --env IS_NIGHTLY=${IS_NIGHTLY} \ |
| 46 | + -v $PWD:/tmp/tensorflow_text \ |
| 47 | + --name tensorflow_text tensorflow_text:${python_version} \ |
| 48 | + bash oss_scripts/run_build.sh |
| 49 | +done |
0 commit comments