From 91807d0c3e8c615c4e685a8417579bdefded9c75 Mon Sep 17 00:00:00 2001 From: Tyagi Date: Tue, 27 Jan 2026 12:21:15 +1100 Subject: [PATCH] find pixi env automatically while installing petsc --- petsc-custom/build-petsc.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/petsc-custom/build-petsc.sh b/petsc-custom/build-petsc.sh index b51ec8a5..ee246c8d 100755 --- a/petsc-custom/build-petsc.sh +++ b/petsc-custom/build-petsc.sh @@ -24,18 +24,19 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PETSC_DIR="${SCRIPT_DIR}/petsc" PETSC_ARCH="petsc-4-uw" -# Detect pixi environment - need MPI and HDF5 from there -if [ -n "$PIXI_PROJECT_ROOT" ]; then - PIXI_ENV="${PIXI_PROJECT_ROOT}/.pixi/envs/amr" - if [ ! -d "$PIXI_ENV" ]; then - PIXI_ENV="${PIXI_PROJECT_ROOT}/.pixi/envs/default" - fi -else +# Detect active pixi environment (robust) +if [ -z "$PIXI_PROJECT_ROOT" ]; then echo "Error: This script must be run from within a pixi environment" - echo "Use: pixi run -e amr petsc-build" + echo "Use: pixi run -e ./build-petsc.sh" exit 1 fi +PIXI_ENV="$(python3 - <<'EOF' +import sys, pathlib +print(pathlib.Path(sys.executable).resolve().parents[1]) +EOF +)" + echo "==========================================" echo "PETSc AMR Build Script" echo "=========================================="