build(python): gridfire uses fourdst wheel in python mode
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 <git-repo-url>"
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo "Usage: $0 <git-repo-url> [fourdst-wheels-dir]"
|
||||
echo " fourdst-wheels-dir: optional local directory of fourdst wheels to"
|
||||
echo " install from instead of PyPI (for bootstrapping a new fourdst+gridfire pair)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REPO_URL="$1"
|
||||
LOCAL_FOURDST_WHEELS="${2:-}"
|
||||
WORK_DIR="$(pwd)"
|
||||
WHEEL_DIR="${WORK_DIR}/wheels_linux_x86_64"
|
||||
|
||||
@@ -17,19 +20,68 @@ TMPDIR="$(mktemp -d)"
|
||||
echo "➤ Cloning ${REPO_URL} → ${TMPDIR}/project"
|
||||
git clone "${REPO_URL}" "${TMPDIR}/project"
|
||||
|
||||
DOCKER_MOUNTS=(-v "${WHEEL_DIR}":/io/wheels -v "${TMPDIR}/project":/io/project)
|
||||
if [[ -n "${LOCAL_FOURDST_WHEELS}" ]]; then
|
||||
DOCKER_MOUNTS+=(-v "${LOCAL_FOURDST_WHEELS}":/io/fourdst-wheels)
|
||||
fi
|
||||
|
||||
for IMAGE in \
|
||||
tboudreaux/manylinux_2_28_x86_64_boost_1_88_0:latest
|
||||
do
|
||||
docker run --rm \
|
||||
-v "${WHEEL_DIR}":/io/wheels \
|
||||
-v "${TMPDIR}/project":/io/project \
|
||||
"${DOCKER_MOUNTS[@]}" \
|
||||
"${IMAGE}" \
|
||||
/bin/bash -eux -c '
|
||||
cd /io/project
|
||||
|
||||
# Does this project link against the fourdst wheel? Single source of
|
||||
# truth: the pin in pyproject.toml.
|
||||
FOURDST_PIN="$(grep -oE "fourdst==[0-9][0-9a-zA-Z.]*" pyproject.toml | head -n1 || true)"
|
||||
|
||||
# If a local fourdst wheel dir was mounted, let pip (including the
|
||||
# isolated build env) resolve fourdst from it.
|
||||
if [ -d /io/fourdst-wheels ]; then
|
||||
export PIP_FIND_LINKS=/io/fourdst-wheels
|
||||
fi
|
||||
|
||||
for PY in /opt/python/*/bin/python; do
|
||||
"$PY" -m pip install --upgrade pip setuptools wheel meson meson-python
|
||||
CC=clang CXX=clang++ "$PY" -m pip wheel . --config-settings=setup-args=-Dunity=on -w /io/wheels -vv
|
||||
auditwheel repair /io/wheels/*.whl -w /io/wheels
|
||||
|
||||
# Build into a per-iteration temp dir so we repair exactly the
|
||||
# wheel we just built (the old glob re-repaired every accumulated
|
||||
# wheel on every loop iteration).
|
||||
BUILD_WHEEL_DIR="$(mktemp -d)"
|
||||
CC=clang CXX=clang++ "$PY" -m pip wheel . \
|
||||
--config-settings=setup-args=-Dunity=on \
|
||||
-w "$BUILD_WHEEL_DIR" -vv
|
||||
|
||||
CURRENT_WHEEL="$(find "$BUILD_WHEEL_DIR" -name "*.whl" | head -n1)"
|
||||
|
||||
if [ -n "$FOURDST_PIN" ]; then
|
||||
# Install fourdst for THIS interpreter so auditwheel can resolve
|
||||
# the libraries it must NOT graft. Excluding them keeps fourdst a
|
||||
# runtime dependency: grafting copies would break cross-package
|
||||
# pybind11 type compatibility.
|
||||
"$PY" -m pip install --force-reinstall "$FOURDST_PIN"
|
||||
FOURDST_LIB_PATH="$("$PY" -c "import fourdst, os; print(os.pathsep.join(fourdst.get_lib_dirs()))")"
|
||||
LD_LIBRARY_PATH="$FOURDST_LIB_PATH" auditwheel repair \
|
||||
--exclude "libcomposition.so*" \
|
||||
--exclude "liblogging.so*" \
|
||||
--exclude "libconst.so*" \
|
||||
--exclude "libreflect_cpp.so*" \
|
||||
-w /io/wheels "$CURRENT_WHEEL"
|
||||
|
||||
# Post-repair sanity check: no vendored fourdst libs.
|
||||
REPAIRED="$(ls -t /io/wheels/*.whl | head -n1)"
|
||||
if unzip -l "$REPAIRED" | grep -E "libcomposition|liblogging|libconst[^a-z]|libreflect_cpp"; then
|
||||
echo "ERROR: repaired wheel contains vendored fourdst libraries"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
auditwheel repair -w /io/wheels "$CURRENT_WHEEL"
|
||||
fi
|
||||
|
||||
rm -rf "$BUILD_WHEEL_DIR"
|
||||
done
|
||||
|
||||
echo "✅ Linux wheels ready in /io/wheels"
|
||||
|
||||
Reference in New Issue
Block a user