#!/usr/bin/env bash # Runs inside the selected manylinux_2_28 image with the repo mounted at /src. # Builds one Nuitka wheel per CPython ABI listed in ORISYS_PYTHON_TAGS. set -euo pipefail TARGET="${ORISYS_BUILD_TARGET:-pypi-linux}" # Comma-separated manylinux tags, e.g. "cp310-cp310,cp311-cp311,cp312-cp312" PYTHON_TAGS="${ORISYS_PYTHON_TAGS:-cp310-cp310,cp311-cp311,cp312-cp312}" WHEELHOUSE_ROOT="${ORISYS_WHEELHOUSE_ROOT:-/opt/orisys-wheelhouse}" # The image already bakes in pip/setuptools/wheel/nuitka/auditwheel. Re-resolving # them from PyPI on every container start costs a network round-trip per ABI and # lets the running container drift from the image it was built from. UPDATE_BUILD_TOOLS="${ORISYS_UPDATE_BUILD_TOOLS:-0}" cd /src echo "=== manylinux entrypoint ===" echo "Target: ${TARGET}" echo "Python tags: ${PYTHON_TAGS}" echo "Wheelhouse root: ${WHEELHOUSE_ROOT}" uname -a IFS=',' read -r -a TAG_ARRAY <<< "${PYTHON_TAGS}" FAILED=0 BUILT=() for tag in "${TAG_ARRAY[@]}"; do tag="$(echo "${tag}" | tr -d '[:space:]')" if [[ -z "${tag}" ]]; then continue fi PYBIN="/opt/python/${tag}/bin" if [[ ! -x "${PYBIN}/python" ]]; then echo "[ERROR] Python not found for tag ${tag}: ${PYBIN}/python" >&2 FAILED=1 continue fi echo "" echo "========================================" echo "Building orisys wheel: ${tag}" echo "Python: $("${PYBIN}/python" -V)" echo "========================================" export PATH="${PYBIN}:${PATH}" export PYTHONPATH="/src/src${PYTHONPATH:+:${PYTHONPATH}}" # Point pip at the per-ABI wheelhouse baked into the image. The pypi-linux # target force-enables verification, which creates a throwaway venv and # pip-installs the built wheel plus its declared runtime deps; serving those # from the wheelhouse keeps the venv isolated (no --system-site-packages) while # removing a ~200 MB download per ABI. PIP_* is inherited by every pip # subprocess, including that venv. wheelhouse="${WHEELHOUSE_ROOT}/${tag}" if [[ -d "${wheelhouse}" ]]; then export PIP_NO_INDEX=1 export PIP_FIND_LINKS="${wheelhouse}" echo "[info] pip is offline, installing from ${wheelhouse}" else echo "[warn] no wheelhouse at ${wheelhouse}; pip will use the network." >&2 echo "[warn] rebuild the image without -SkipImageBuild to bake it in." >&2 unset PIP_NO_INDEX PIP_FIND_LINKS || true fi if [[ "${UPDATE_BUILD_TOOLS}" == "1" ]]; then echo "[info] refreshing build tooling (ORISYS_UPDATE_BUILD_TOOLS=1)" "${PYBIN}/python" -m pip install -q --upgrade pip setuptools wheel auditwheel fi if "${PYBIN}/python" build/wheel/build.py --target "${TARGET}"; then BUILT+=("${tag}") else echo "[ERROR] Build failed for ${tag}" >&2 FAILED=1 fi unset PIP_NO_INDEX PIP_FIND_LINKS || true done echo "" echo "=== Build artifacts ===" ls -la /src/dist/repaired/ || true ls -la /src/SDK/*/ || true if [[ ${#BUILT[@]} -gt 0 ]]; then echo "Built tags: ${BUILT[*]}" fi if [[ "${FAILED}" -ne 0 ]]; then echo "[ERROR] One or more Python ABI builds failed." >&2 exit 1 fi echo "[SUCCESS] All requested manylinux wheels built."