--strip-components=1 only stripped "." so ./configure was one level deeper; unpack plain and cd through hdf5/hdf5-*/ instead. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
80 lines
4.2 KiB
Python
Executable File
80 lines
4.2 KiB
Python
Executable File
#!/usr/bin/env modbuild
|
|
|
|
# upstream INSTALL.md: meson setup build && meson compile && meson install.
|
|
# default pbuild::prep downloads + sha-verifies the tarballs in files/config.yaml:
|
|
# crystfel is unpacked at $SRC_DIR root (strip_dirs:1), the hdf5 tarball is only
|
|
# copied there (unpacker: none) and unpacked by hand into $SRC_DIR/hdf5 below.
|
|
#
|
|
# meson/ninja: Ra's system meson is too old (meson.build wants >= 0.60) and its
|
|
# system python is 3.9 (EOL; meson >= 1.12 needs >= 3.10) -> uv syncs the
|
|
# versions pinned in pyproject.toml/uv.lock into a throwaway venv on a
|
|
# uv-managed Python 3.12, both kept in the build scratch dir, not in $PREFIX.
|
|
#
|
|
# hdf5: the Ra build node has no hdf5-devel / h5cc / hdf5.pc, so meson's
|
|
# dependency('hdf5') fails. HDF5 is compiled into $PREFIX first (autotools, NOT
|
|
# cmake: meson's hdf5 config-tool rejects a cmake-built h5cc) and meson finds it
|
|
# through $PREFIX/bin/h5cc. --libdir=lib64 matches the $ORIGIN/../lib64 RPATH
|
|
# crystfel bakes into its binaries, so the module needs no LD_LIBRARY_PATH.
|
|
#
|
|
# cd into SRC_DIR explicitly: hooks are not guaranteed to start there, and a
|
|
# wrong cwd silently builds nothing (modbuild has no errexit in hooks).
|
|
|
|
crystfel::env() {
|
|
# system uv on Ra; override with UV=/path/to/uv if needed
|
|
UV="${UV:-/usr/bin/uv}"
|
|
# ~/.cache/uv hits the home disk quota; shared cache reuses wheels across MX builds
|
|
export UV_CACHE_DIR="/opt/psi/MX/.uv-cache"
|
|
# cache (/opt/psi) and venv (tmpdir) are on different filesystems: uv can't hardlink, don't warn
|
|
export UV_LINK_MODE=copy
|
|
export UV_PROJECT_ENVIRONMENT="${SRC_DIR}/../meson-venv"
|
|
export UV_PYTHON_INSTALL_DIR="${SRC_DIR}/../uv-python"
|
|
# venv first (meson, ninja), then PREFIX (h5cc for meson's hdf5 lookup)
|
|
export PATH="${UV_PROJECT_ENVIRONMENT}/bin:${PREFIX}/bin:${PATH}"
|
|
cd "${SRC_DIR}" || std::die 42 "cannot cd to SRC_DIR=${SRC_DIR}"
|
|
}
|
|
|
|
pbuild::configure() {
|
|
crystfel::env
|
|
[[ -x "$UV" ]] || std::die 42 "uv not found at $UV - dnf install uv, or set UV=/path/to/uv"
|
|
for t in flex bison make; do
|
|
command -v "$t" >/dev/null || std::die 42 "$t not on PATH - crystfel/hdf5 need it (dnf install $t)"
|
|
done
|
|
# --locked: die if pyproject.toml and uv.lock disagree instead of silently re-resolving
|
|
"$UV" sync --locked --python 3.12 --project "${BUILDBLOCK_DIR}" \
|
|
|| std::die 42 "uv sync failed - no meson/ninja venv (PyPI/GitHub reachable? uv.lock stale -> uv lock)"
|
|
|
|
# HDF5 into $PREFIX: serial, C only, no test suite (halves the build time).
|
|
# HDF5_CONFIG_ABORT makes configure die when zlib is missing instead of
|
|
# silently building without deflate; szip is not on Ra, so it is switched off
|
|
# rather than aborting on it.
|
|
# no --strip-components: the GitHub tarball's entries start with ./hdf5-x.y.z/,
|
|
# so a fixed strip count lands configure one level off; cd through a glob instead
|
|
mkdir -p hdf5 && tar -xzf hdf5-*.tar.gz -C hdf5 \
|
|
|| std::die 42 "hdf5 tarball unpack failed - is hdf5-*.tar.gz in ${SRC_DIR}? (prep copies it there)"
|
|
( cd hdf5/hdf5-*/ \
|
|
&& HDF5_CONFIG_ABORT=yes ./configure --prefix="${PREFIX}" --libdir="${PREFIX}/lib64" \
|
|
--enable-build-mode=production --disable-tests --with-zlib=yes --with-szlib=no \
|
|
&& make -j"${JOBS}" && make install ) \
|
|
|| std::die 42 "hdf5 build failed - see ${SRC_DIR}/hdf5/hdf5-*/config.log (zlib-devel missing?)"
|
|
[[ -x "${PREFIX}/bin/h5cc" ]] || std::die 42 "h5cc missing from ${PREFIX}/bin - meson cannot find hdf5 without it"
|
|
|
|
meson setup build --prefix="${PREFIX}" --libdir=lib64 \
|
|
|| std::die 42 "meson setup failed - check build/meson-logs/meson-log.txt"
|
|
}
|
|
|
|
pbuild::compile() {
|
|
crystfel::env
|
|
meson compile -C build || std::die 42 "meson compile failed"
|
|
}
|
|
|
|
pbuild::install() {
|
|
crystfel::env
|
|
meson install -C build || std::die 42 "meson install failed"
|
|
[[ -x "${PREFIX}/bin/indexamajig" ]] || std::die 42 "indexamajig missing from ${PREFIX}/bin after install"
|
|
# ldd follows the whole closure (libcrystfel -> libhdf5): a "not found" here
|
|
# means the RPATH/libdir assumption above broke and the module would not run
|
|
if ldd "${PREFIX}/bin/indexamajig" | grep "not found"; then
|
|
std::die 42 "unresolved shared libs (above) - hdf5 libdir vs crystfel RPATH mismatch"
|
|
fi
|
|
}
|