diff --git a/.bazelrc b/.bazelrc index 5c70e99..671c2df 100644 --- a/.bazelrc +++ b/.bazelrc @@ -28,6 +28,11 @@ 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 +build:linux --remote_upload_local_results=false + # 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.sh b/release/kokoro/release_linux.sh index 5292ef6..64a1d44 100755 --- a/release/kokoro/release_linux.sh +++ b/release/kokoro/release_linux.sh @@ -19,8 +19,14 @@ set -e 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 +209,30 @@ 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 +# Register QEMU for arm64 emulation if not on arm64 host +if [ "$(uname -m)" != "aarch64" ]; then + echo "Registering QEMU binfmt handlers..." + docker run --privileged --rm mirror.gcr.io/tonistiigi/binfmt --install arm64 +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"]