myxce/src/xceadmin/meson.build
Rongsong Shen db2b5f17f0 fix(admin-config-tool): pin xceadmin's python3 to meson's own resolution
Both meson-build.sh (venv creation) and meson-install.sh (wrapper
shebang) resolved python3 independently at run time (bare `python3 -m
venv` / `command -v python3`) -- correct as long as invoked inside
nix develop/build, but nothing prevented a stray non-nix system
python3 earlier on PATH from shadowing it.

meson.build now resolves python3 once via import('python').
find_installation('python3') -- same mechanism as find_program('go')/
capnp/packcc elsewhere in this build, printed at `meson setup` time
as "Program python3 found: YES (/nix/store/...)" -- and threads that
exact resolved path into both scripts as an explicit argument instead
of a fresh lookup.

Verified: meson setup prints the pinned python3, xceadmin target
rebuilds clean (165/165 passed), and the built venv's own python3
resolves through to that exact nix store path.
2026-07-22 13:07:23 +00:00

53 lines
2.7 KiB
Meson

# xceadmin (admin-config-tool): Python package, no C compilation.
#
# Unlike every other subdir here, there is no single build artifact for
# meson/ninja to track -- `pip install` produces a multi-file venv tree.
# custom_target()'s output is a stamp file representing "install +
# test succeeded", following the same pattern used to wrap non-native
# build systems (cargo, npm, etc.) inside meson elsewhere in the
# ecosystem. The real work happens in meson-build.sh, out-of-tree in
# this subdir's own build directory -- never writing into the live
# source checkout, unlike xce-build.sh's separate editable-install
# fast dev-loop path (`xce-build.sh xceadmin`, still available
# standalone, but no longer xce-build.sh's OWN xceadmin implementation
# -- see tools/xce-build.sh, which now just calls this same target).
# Resolved once via meson's own dependency machinery (same pattern as
# find_program('go')/capnp/packcc elsewhere in this build, printed as
# "Program python3 found: YES (/nix/store/...)" at `meson setup` time) and
# threaded explicitly into both scripts below -- NOT left to each script's
# own `python3 -m venv`/`command -v python3` PATH lookup at run time. A bare
# PATH lookup would happen to match nix's python3 when invoked correctly
# (inside `nix develop` / a nix build sandbox), but nothing would catch a
# stray non-nix system python3 shadowing it earlier on PATH -- pinning the
# exact interpreter meson already found makes that impossible, not just
# unlikely.
python3_prog = import('python').find_installation('python3')
xceadmin_stamp = custom_target('xceadmin',
output: 'xceadmin-build.stamp',
# No meaningful per-file `input:` list: meson-build.sh copies the whole
# subdir tree regardless, so tracking a subset of .py files would only
# give false confidence about staleness detection. build_always_stale
# instead matches this project's existing convention (every
# xce-build.sh component does `rm -rf "$BUILD_DIR"` and rebuilds clean
# on every invocation) rather than relying on ninja's file-mtime cache.
command: [
find_program('bash'),
meson.current_source_dir() / 'meson-build.sh',
meson.current_source_dir(),
meson.current_build_dir(),
meson.current_source_dir() / '..' / '..', # repo root (contains ha/, src/)
python3_prog.full_path(),
'@OUTPUT@',
],
build_by_default: true,
build_always_stale: true,
console: true,
)
# Installs a standalone $out/bin/xceadmin -- runs after xceadmin_stamp
# (ninja install always depends on build_by_default targets first) so the
# build-dir venv it copies from already exists. See meson-install.sh for
# why this isn't a plain `cp` of that venv.
meson.add_install_script('meson-install.sh', python3_prog.full_path())