11#! /bin/bash
22set -e
33
4+ # Dynamically install podman inside the ktcb container to run self-contained
5+ # builds inside /tmp and avoid shared RBE volume-mount hangs.
6+ echo " Installing podman..."
7+ apt-get update && apt-get install -y podman || true
8+
9+ echo " Verifying podman installation..."
10+ podman --version || echo " podman not functional"
11+
12+ # Configure podman to use fuse-overlayfs for nested container efficiency,
13+ # preventing VFS disk bloat from exhausting the RBE disk quota.
14+ mkdir -p /etc/containers
15+ cat << 'EOF ' > /etc/containers/storage.conf
16+ [storage]
17+ driver = "overlay"
18+ runroot = "/run/containers/storage"
19+ graphroot = "/var/lib/containers/storage"
20+
21+ [storage.options.overlay]
22+ mount_program = "/usr/bin/fuse-overlayfs"
23+ EOF
24+
425# If running locally (not on Kokoro), authenticate with gcloud.
526if [ -z " ${KOKORO_BUILD_ID} " ]; then
627 if ! gcloud auth application-default print-access-token --quiet > /dev/null; then
728 gcloud auth application-default login
829 fi
930fi
1031
11- pip install -U keyring keyrings.google-artifactregistry-auth twine cibuildwheel
32+ pip install --no-cache-dir - U keyring keyrings.google-artifactregistry-auth twine cibuildwheel
1233
1334REPO_DIR=$( mktemp -d)
1435echo " Created temporary directory: ${REPO_DIR} "
@@ -23,7 +44,7 @@ if [ "${DRY_RUN}" = "true" ]; then
2344 # Get the latest tag or fallback
2445 VERSION=$( git tag --sort=-v:refname 2> /dev/null | head -n 1 || true)
2546 if [ -z " ${VERSION} " ]; then
26- VERSION=" 0 .1.2"
47+ VERSION=" v0 .1.2"
2748 fi
2849 popd
2950else
@@ -43,6 +64,23 @@ echo "Building release for version: ${VERSION}"
4364TMP_DIR=$( mktemp -d)
4465echo " Build directory: ${TMP_DIR} "
4566
67+ # Configure pip inside cibuildwheel to use Google's internal Airlock PyPI mirror,
68+ # since public PyPI (pypi.org) is blocked by the RBE VM's network firewall.
69+ # We dynamically fetch the GCE Service Account token from the GCE Metadata Server
70+ # to authenticate the request to the Artifact Registry repository.
71+ GCE_TOKEN=$( python3 -c ' import urllib.request, json; req = urllib.request.Request("http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default/token", headers={"Metadata-Flavor": "Google"}); print(json.loads(urllib.request.urlopen(req).read().decode())["access_token"])' )
72+ export PIP_INDEX_URL=" https://oauth2accesstoken:${GCE_TOKEN} @us-python.pkg.dev/artifact-foundry-prod/ah-3p-staging-python/simple/"
73+
74+ # Explicitly disable keyring searches and interactive prompts in pip inside the container
75+ # to prevent hangs on DBus or credential-helper lookups.
76+ export PIP_KEYRING_PROVIDER=" disabled"
77+ export PIP_NO_INPUT=" true"
78+
79+ export CIBW_ENVIRONMENT=" PIP_INDEX_URL=$PIP_INDEX_URL PIP_KEYRING_PROVIDER=$PIP_KEYRING_PROVIDER PIP_NO_INPUT=$PIP_NO_INPUT "
80+
81+ # Enable extremely verbose logs for cibuildwheel.
82+ export CIBW_BUILD_VERBOSITY=3
83+
4684# Add trap cleanup for TMP_DIR as well
4785trap ' echo "Cleaning up temporary directories: ${REPO_DIR} ${TMP_DIR}"; rm -rf "${REPO_DIR}" "${TMP_DIR}"' EXIT
4886
0 commit comments