From 2e843c0986f155b922e0b2bbe916bb27d4fd22a5 Mon Sep 17 00:00:00 2001 From: Dmitri Plotnikov Date: Mon, 22 Jun 2026 12:13:36 -0700 Subject: [PATCH] Update release scripts and pyproject.toml for ARM support PiperOrigin-RevId: 936185160 --- .bazelrc | 4 +++ release/kokoro/release_linux.cfg | 2 +- release/kokoro/release_linux.sh | 45 ++++++++++++++++++++++++++++++-- release/pyproject.toml | 6 ++++- 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index 5c70e99..6d57007 100644 --- a/.bazelrc +++ b/.bazelrc @@ -28,6 +28,10 @@ common:windows --experimental_repository_downloader_retries=10 build --verbose_failures test --test_output=errors +# GCS remote caching config (Linux-only, active by default on Linux) +build:linux --remote_cache=https://storage.googleapis.com/linux-cel-python-remote-cache +build:linux --google_default_credentials=true + # GCS remote caching config (Windows-only, active by default on Windows!) build:windows --remote_cache=https://storage.googleapis.com/windows-cel-python-remote-cache build:windows --google_default_credentials=true diff --git a/release/kokoro/release_linux.cfg b/release/kokoro/release_linux.cfg index a42e2e3..392547d 100644 --- a/release/kokoro/release_linux.cfg +++ b/release/kokoro/release_linux.cfg @@ -5,6 +5,6 @@ build_file: "cel-python/release/kokoro/release_linux.sh" timeout_mins: 120 container_properties { - docker_image: "us-central1-docker.pkg.dev/kokoro-container-bakery/kokoro/ubuntu/ubuntu2204/ktcb:current" + docker_image: "mirror.gcr.io/library/ubuntu:22.04" docker_sibling_containers: true } diff --git a/release/kokoro/release_linux.sh b/release/kokoro/release_linux.sh index 5292ef6..e03d5f8 100755 --- a/release/kokoro/release_linux.sh +++ b/release/kokoro/release_linux.sh @@ -15,12 +15,40 @@ set -e +if ! command -v pip3 &> /dev/null || ! command -v curl &> /dev/null || ! command -v docker &> /dev/null; then + echo "Installing basic dependencies..." + apt-get update && apt-get install -y python3-pip curl + + if ! command -v docker &> /dev/null; then + echo "Installing docker CLI..." + ARCH=$(uname -m) + if [ "$ARCH" = "x86_64" ]; then + DOCKER_ARCH="x86_64" + elif [ "$ARCH" = "aarch64" ]; then + DOCKER_ARCH="aarch64" + else + echo "Unsupported arch: $ARCH" + exit 1 + fi + curl -fsSL "https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-24.0.7.tgz" -o docker.tgz + tar xzvf docker.tgz --strip-components=1 docker/docker + mv docker /usr/local/bin/ + rm -f docker.tgz + fi +fi + # Avoid virtualenv/pip trying to download/upgrade tools from PyPI on host export VIRTUALENV_NO_DOWNLOAD=1 export PIP_DISABLE_PIP_VERSION_CHECK=1 +if [ "$(uname -m)" = "aarch64" ]; then + export CIBW_ARCHS="aarch64" +else + export CIBW_ARCHS="x86_64" +fi + # Pass these environment variables to the cibuildwheel Docker container -export CIBW_ENVIRONMENT="VIRTUALENV_NO_DOWNLOAD=1 PIP_DISABLE_PIP_VERSION_CHECK=1" +export CIBW_ENVIRONMENT="VIRTUALENV_NO_DOWNLOAD=1 PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_DEFAULT_TIMEOUT=120" export CIBW_DEPENDENCY_VERSIONS="latest" export CIBW_CONTAINER_ENGINE_EXTRA_ARGS="--network=host" @@ -203,13 +231,26 @@ rm -rf cel_expr_python/*_test.py echo "Downloading bazelisk on host..." curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64 -chmod +x bazelisk-linux-amd64 +curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-arm64 +chmod +x bazelisk-linux-amd64 bazelisk-linux-arm64 + +echo "Downloading build dependencies on host..." +mkdir -p build_deps +pip download --only-binary=:all: --dest build_deps "setuptools>=40.8.0" "wheel" +if [ "$(uname -m)" = "aarch64" ]; then + PLATFORM_SUFFIX="aarch64" +else + PLATFORM_SUFFIX="x86_64" +fi +pip download --only-binary=:all: --dest build_deps --python-version 3.9 --platform "manylinux2014_${PLATFORM_SUFFIX}" "virtualenv" # Check if pyproject.toml exists before running sed if [ -f pyproject.toml ]; then sed -i "" "s/\$VERSION/${VERSION}/g" pyproject.toml || sed -i "s/\$VERSION/${VERSION}/g" pyproject.toml fi + + echo "Running cibuildwheel..." # Default CIBWHEEL_BIN if not set if [ -z "${CIBWHEEL_BIN}" ]; then diff --git a/release/pyproject.toml b/release/pyproject.toml index c6b322a..d7aa211 100644 --- a/release/pyproject.toml +++ b/release/pyproject.toml @@ -44,14 +44,18 @@ test-command = "python {project}/cel_basic_test.py" build-verbosity = 1 [tool.cibuildwheel.linux] +build-frontend = { name = "pip", args = ["--no-build-isolation"] } +before-build = "pip install --no-index --find-links={project}/build_deps setuptools wheel virtualenv" +archs = ["x86_64", "aarch64"] manylinux-x86_64-image = "manylinux_2_28" +manylinux-aarch64-image = "manylinux_2_28" container-engine = "docker; disable_host_mount: True" # Google's internal Kokoro/RBE network uses a secure MITM proxy that resigns HTTPS # traffic with an internal Google CA. Since the public manylinux container does not # trust this CA, git fetches for external dependencies (like @cel-cpp) will fail # with SSL certificate errors. We disable http.sslVerify inside the container to # bypass this and allow Bazel to fetch SCM dependencies through the proxy. -before-all = "git config --global http.sslVerify false && echo 'Installing bazelisk' && cp {project}/bazelisk-linux-amd64 /usr/local/bin/bazel" +before-all = "git config --global http.sslVerify false && echo 'Installing bazelisk' && if [ $(uname -m) = 'aarch64' ]; then cp {project}/bazelisk-linux-arm64 /usr/local/bin/bazel; else cp {project}/bazelisk-linux-amd64 /usr/local/bin/bazel; fi && python3 -m pip install --no-index --find-links={project}/build_deps virtualenv" [tool.cibuildwheel.macos] archs = ["x86_64", "arm64"]