11#! /bin/bash
22set -e
3+ set -x
4+
5+ # Debug: Print host proxy settings
6+ echo " === Host Proxy Settings ==="
7+ echo " http_proxy: ${http_proxy} "
8+ echo " https_proxy: ${https_proxy} "
9+ echo " no_proxy: ${no_proxy} "
10+ echo " HTTP_PROXY: ${HTTP_PROXY} "
11+ echo " HTTPS_PROXY: ${HTTPS_PROXY} "
12+ echo " NO_PROXY: ${NO_PROXY} "
13+
14+ # Avoid virtualenv/pip trying to download/upgrade tools from PyPI on host
15+ export VIRTUALENV_NO_DOWNLOAD=1
16+ export PIP_DISABLE_PIP_VERSION_CHECK=1
17+
18+ # Detect proxy settings on host and pass them to cibuildwheel container
19+ PROXY_ENV=" "
20+ if [ -n " ${http_proxy} " ]; then PROXY_ENV=" ${PROXY_ENV} http_proxy=${http_proxy} " ; fi
21+ if [ -n " ${https_proxy} " ]; then PROXY_ENV=" ${PROXY_ENV} https_proxy=${https_proxy} " ; fi
22+ if [ -n " ${no_proxy} " ]; then PROXY_ENV=" ${PROXY_ENV} no_proxy=${no_proxy} " ; fi
23+ if [ -n " ${HTTP_PROXY} " ]; then PROXY_ENV=" ${PROXY_ENV} HTTP_PROXY=${HTTP_PROXY} " ; fi
24+ if [ -n " ${HTTPS_PROXY} " ]; then PROXY_ENV=" ${PROXY_ENV} HTTPS_PROXY=${HTTPS_PROXY} " ; fi
25+ if [ -n " ${NO_PROXY} " ]; then PROXY_ENV=" ${PROXY_ENV} NO_PROXY=${NO_PROXY} " ; fi
26+
27+ # Pass these environment variables to the cibuildwheel Docker container
28+ export CIBW_ENVIRONMENT=" VIRTUALENV_NO_DOWNLOAD=1 PIP_DISABLE_PIP_VERSION_CHECK=1${PROXY_ENV} "
329
430# If running locally (not on Kokoro), authenticate with gcloud.
531if [ -z " ${KOKORO_BUILD_ID} " ]; then
@@ -8,7 +34,7 @@ if [ -z "${KOKORO_BUILD_ID}" ]; then
834 fi
935fi
1036
11- pip install -U keyring keyrings.google-artifactregistry-auth twine cibuildwheel
37+ pip install --no-cache-dir - U keyring keyrings.google-artifactregistry-auth twine cibuildwheel
1238
1339REPO_DIR=$( mktemp -d)
1440echo " Created temporary directory: ${REPO_DIR} "
@@ -52,17 +78,64 @@ cp -r "${SRC_DIR}"/{*,.*} . 2>/dev/null || true
5278cp -r " ${SRC_DIR} " /release/* . 2> /dev/null || true
5379rm -rf cel_expr_python/* _test.py
5480
81+ echo " Downloading bazelisk on host..."
82+ curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64
83+ chmod +x bazelisk-linux-amd64
84+
5585# Check if pyproject.toml exists before running sed
5686if [ -f pyproject.toml ]; then
5787 sed -i " " " s/\$ VERSION/${VERSION} /g" pyproject.toml || sed -i " s/\$ VERSION/${VERSION} /g" pyproject.toml
5888fi
5989
90+ export CIBW_CONTAINER_ENGINE_EXTRA_ARGS=" --network=host"
91+
6092echo " Running cibuildwheel: ${CIBWHEEL_BIN} "
6193# Default CIBWHEEL_BIN if not set
6294if [ -z " ${CIBWHEEL_BIN} " ]; then
6395 CIBWHEEL_BIN=" python3 -m cibuildwheel"
6496fi
65- ${CIBWHEEL_BIN} --platform linux --output-dir dist
97+
98+ # Run cibuildwheel in background
99+ ${CIBWHEEL_BIN} --platform linux --output-dir dist &
100+ CIBW_PID=$!
101+ echo " cibuildwheel started in background with PID: ${CIBW_PID} "
102+
103+ # Run debugger in foreground
104+ echo " === Starting Foreground Container Debugger ==="
105+ # Wait for 9 minutes (540 seconds) to ensure we reach the hang point
106+ sleep 540
107+ echo " === 9 minutes elapsed, checking container status ==="
108+
109+ echo " Active Docker Containers:"
110+ docker ps -a || true
111+
112+ # Find sibling container (usually has 'manylinux' or 'cibuildwheel' in image/name)
113+ CONTAINER_ID=$( docker ps --format ' {{.ID}} {{.Image}}' | grep -E " manylinux|cibuildwheel|pypa" | awk ' {print $1}' | head -n 1 || true)
114+
115+ if [ -z " ${CONTAINER_ID} " ]; then
116+ echo " Could not identify sibling container automatically. Running diagnostics on all containers."
117+ for cid in $( docker ps -q || true) ; do
118+ echo " --- Diagnostics for Container ${cid} ---"
119+ echo " Image: $( docker inspect --format=' {{.Config.Image}}' ${cid} || true) "
120+ echo " Processes:"
121+ docker exec " ${cid} " ps aux || true
122+ echo " Docker Top:"
123+ docker top " ${cid} " || true
124+ done
125+ else
126+ echo " Identified sibling container ID: ${CONTAINER_ID} "
127+ echo " === Process list inside sibling container ==="
128+ docker exec " ${CONTAINER_ID} " ps aux || true
129+ echo " === Docker Top ==="
130+ docker top " ${CONTAINER_ID} " || true
131+ echo " === Container Logs ==="
132+ docker logs " ${CONTAINER_ID} " --tail 100 || true
133+ fi
134+
135+ echo " === Diagnostics finished. Killing cibuildwheel (PID: ${CIBW_PID} ) ==="
136+ kill -9 ${CIBW_PID} || true
137+ wait ${CIBW_PID} || true
138+ echo " === cibuildwheel terminated. Exiting. ==="
66139
67140if [ " ${DRY_RUN} " = " true" ]; then
68141 echo " [DRY RUN] Skipping upload to PyPI exit gate."
0 commit comments