Skip to content

Commit 2225602

Browse files
Add support for linux/arm64 wheels.
Update pyproject.toml to build for aarch64 on Linux, and update release_linux.sh to download the corresponding bazelisk binary. Also download setuptools and wheel on host, and virtualenv resolved for Python 3.9, and install them with --no-build-isolation to avoid PyPI timeout issues in container. Install virtualenv in before-build as well to avoid PyPI timeout during testing. Increase pip default timeout to 120s to handle slow network/proxy in Kokoro. Limit Bazel jobs to 8 in setup.py to avoid OOM failures in Kokoro/RBE. Register QEMU for arm64 emulation in release_linux.sh. Configure GCS remote cache for Bazel to speed up compilation. Temporarily restrict build to cp311-aarch64 only to verify cache and speed. PiperOrigin-RevId: 933297845
1 parent 78c8096 commit 2225602

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ common:windows --experimental_repository_downloader_retries=10
2828
build --verbose_failures
2929
test --test_output=errors
3030

31+
# GCS remote caching config (Linux-only, active by default on Linux)
32+
build:linux --remote_cache=https://storage.googleapis.com/linux-cel-python-remote-cache
33+
build:linux --google_default_credentials=true
34+
3135
# GCS remote caching config (Windows-only, active by default on Windows!)
3236
build:windows --remote_cache=https://storage.googleapis.com/windows-cel-python-remote-cache
3337
build:windows --google_default_credentials=true

release/kokoro/release_linux.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export VIRTUALENV_NO_DOWNLOAD=1
2020
export PIP_DISABLE_PIP_VERSION_CHECK=1
2121

2222
# Pass these environment variables to the cibuildwheel Docker container
23-
export CIBW_ENVIRONMENT="VIRTUALENV_NO_DOWNLOAD=1 PIP_DISABLE_PIP_VERSION_CHECK=1"
23+
export CIBW_ENVIRONMENT="VIRTUALENV_NO_DOWNLOAD=1 PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_DEFAULT_TIMEOUT=120"
2424
export CIBW_DEPENDENCY_VERSIONS="latest"
2525
export CIBW_CONTAINER_ENGINE_EXTRA_ARGS="--network=host"
2626

@@ -203,13 +203,23 @@ rm -rf cel_expr_python/*_test.py
203203

204204
echo "Downloading bazelisk on host..."
205205
curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64
206-
chmod +x bazelisk-linux-amd64
206+
curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-arm64
207+
chmod +x bazelisk-linux-amd64 bazelisk-linux-arm64
208+
209+
echo "Downloading build dependencies on host..."
210+
mkdir -p build_deps
211+
pip download --only-binary=:all: --dest build_deps "setuptools>=40.8.0" "wheel"
212+
pip download --only-binary=:all: --dest build_deps --python-version 3.9 --platform manylinux2014_x86_64 "virtualenv"
207213

208214
# Check if pyproject.toml exists before running sed
209215
if [ -f pyproject.toml ]; then
210216
sed -i "" "s/\$VERSION/${VERSION}/g" pyproject.toml || sed -i "s/\$VERSION/${VERSION}/g" pyproject.toml
211217
fi
212218

219+
# Register QEMU for arm64 emulation
220+
echo "Registering QEMU binfmt handlers..."
221+
docker run --privileged --rm mirror.gcr.io/tonistiigi/binfmt --install arm64
222+
213223
echo "Running cibuildwheel..."
214224
# Default CIBWHEEL_BIN if not set
215225
if [ -z "${CIBWHEEL_BIN}" ]; then

release/pyproject.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,26 @@ where = ["."]
3838
exclude = ["codelab*", "conformance*", "custom_ext*", "release*", "testing*", "wheelhouse*"]
3939

4040
[tool.cibuildwheel]
41-
build = "cp311-* cp312-* cp313-* cp314-*"
41+
#build = "cp311-* cp312-* cp313-* cp314-*"
42+
build = "cp311-*"
4243
skip = "*musllinux* *win32* *i686*"
4344
test-command = "python {project}/cel_basic_test.py"
4445
build-verbosity = 1
4546

4647
[tool.cibuildwheel.linux]
47-
manylinux-x86_64-image = "manylinux_2_28"
48+
build-frontend = { name = "pip", args = ["--no-build-isolation"] }
49+
before-build = "pip install --no-index --find-links={project}/build_deps setuptools wheel virtualenv"
50+
#archs = ["x86_64", "aarch64"]
51+
archs = ["aarch64"]
52+
#manylinux-x86_64-image = "manylinux_2_28"
53+
manylinux-aarch64-image = "manylinux_2_28"
4854
container-engine = "docker; disable_host_mount: True"
4955
# Google's internal Kokoro/RBE network uses a secure MITM proxy that resigns HTTPS
5056
# traffic with an internal Google CA. Since the public manylinux container does not
5157
# trust this CA, git fetches for external dependencies (like @cel-cpp) will fail
5258
# with SSL certificate errors. We disable http.sslVerify inside the container to
5359
# bypass this and allow Bazel to fetch SCM dependencies through the proxy.
54-
before-all = "git config --global http.sslVerify false && echo 'Installing bazelisk' && cp {project}/bazelisk-linux-amd64 /usr/local/bin/bazel"
60+
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"
5561

5662
[tool.cibuildwheel.macos]
5763
archs = ["x86_64", "arm64"]

release/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def build_extension(self, ext):
7171

7272
# Build with bazel
7373
# Use --compilation_mode=opt for release builds
74-
cmd = ['bazel', 'build', ext.target, '--compilation_mode=opt']
74+
cmd = ['bazel', 'build', ext.target, '--compilation_mode=opt', '--jobs=8']
7575
if sys.platform == 'win32':
7676
self.platform_config_windows(cmd, python_version)
7777
if sys.platform == 'darwin':

0 commit comments

Comments
 (0)