Files
MX_Pmodule/pymol-open-source/build
T
duan_jandClaude Fable 5 783c6325ad fix cache-clean hint: dist name is pymol, not pymol-open-source
uv registers the wheel as pymol==3.1.0, so 'uv cache clean
pymol-open-source' is a no-op and the poisoned pure-python wheel
keeps being reinstalled from cache (Prepared in 537ms = no compile).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-03 10:21:45 +02:00

52 lines
2.7 KiB
Python
Executable File

#!/usr/bin/env modbuild
# Open-source PyMOL, compiled from the GitHub source tarball into a uv venv
# (careless-style uv route; conda unreachable from Ra). Default pbuild::prep
# downloads + sha-verifies + unpacks both urls from files/config.yaml.
# GLEW/libpng/freetype/GL headers must exist as system RPMs on the build host;
# msgpack/MMTF, libxml2 (COLLADA) and VMD plugins (libnetcdf) are disabled
# because those libs are not on Ra.
pbuild::configure() {
# modbuild's shell strips ~/.local/bin from PATH; override with UV=/path/to/uv if needed
UV="${UV:-$HOME/.local/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"
# keep the standalone CPython inside PREFIX so venv symlinks never point at a home cache
export UV_PYTHON_INSTALL_DIR="$PREFIX/python"
"$UV" venv --python 3.12 "$PREFIX/venv" || std::die 42 "uv venv failed - is uv at \$UV?"
# stage glm where setup.py's PREFIX_PATH lookup expects it: <prefix>/include/glm.
# strip_dirs applies to the glm tarball too, so headers land at $SRC_DIR/glm directly
mkdir -p "$SRC_DIR/deps/include"
cp -r "$SRC_DIR/glm" "$SRC_DIR/deps/include/" || \
std::die 42 "glm staging failed - glm tarball missing from SRC_DIR?"
}
pbuild::compile() {
:
}
pbuild::install() {
UV="${UV:-$HOME/.local/bin/uv}"
export UV_CACHE_DIR="/opt/psi/MX/.uv-cache"
# force the gcc module's compilers; uv's standalone CPython records clang in sysconfig
export CC=gcc CXX=g++
export PREFIX_PATH="$SRC_DIR/deps"
# -C k=v reaches setup.py as `build_ext --k=v` (_custom_build/backend.py).
# str2bool accepts ONLY true/false (yes/no -> "Boolean value expected").
# no-vmd-plugins=false is deliberate: upstream dest is vmd_plugins, false disables them.
"$UV" pip install --python "$PREFIX/venv/bin/python" \
-C use-msgpackc=no -C no-libxml=true -C no-vmd-plugins=false \
"$SRC_DIR" || \
std::die 42 "pymol build failed - check system devel RPMs (glew, libpng, freetype, mesa-libGL)"
# Qt GUI; without it pymol falls back to CLI-only
"$UV" pip install --python "$PREFIX/venv/bin/python" PyQt5 || \
std::die 42 "PyQt5 install failed"
[[ -x "$PREFIX/venv/bin/pymol" ]] || std::die 42 "pymol launcher missing from venv"
# launcher can exist while the compiled ext is missing (pure-python wheel from a
# poisoned uv cache); import _cmd directly so a broken build dies here, not at runtime
"$PREFIX/venv/bin/python" -c "import pymol._cmd" || \
std::die 42 "pymol._cmd import failed - ext .so missing; try 'uv cache clean pymol' (dist name is pymol, not pymol-open-source) and rebuild"
}