#!/bin/bash # Setup Python environment on login node, not inside SLURM compute job. # Run from the project root: bash scripts/setup_env_login.sh set -euo pipefail cd "$(dirname "$0")/.." PYTHON_BIN="${PYTHON_BIN:-python3}" VENV_DIR="${VENV_DIR:-venv_bcml}" # Prevent accidental source builds on HPC. If a wheel is unavailable, stop immediately. PIP_ONLY_BINARY=":all:" export PIP_ONLY_BINARY # Avoid using Intel compiler variables that may make source builds fail. unset CC || true unset CXX || true unset FC || true unset F77 || true unset F90 || true # Keep BLAS/OpenMP quiet during import tests. export OMP_NUM_THREADS=1 export MKL_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 export NUMEXPR_NUM_THREADS=1 echo "Project directory: $(pwd)" echo "Python command : ${PYTHON_BIN}" echo "Virtual env dir : ${VENV_DIR}" if [ ! -d "${VENV_DIR}" ]; then echo "Creating virtual environment ${VENV_DIR} ..." "${PYTHON_BIN}" -m venv "${VENV_DIR}" fi source "${VENV_DIR}/bin/activate" echo "Python in use : $(which python)" python -V echo "Installing pinned Python packages from wheels only." echo "If this fails, the HPC does not have the required wheel in its internet/cache/local mirror." python -m pip install --no-cache-dir --only-binary=:all: -r requirements.txt echo "Checking imports ..." python scripts/check_env.py echo "Environment is ready. Now submit: sbatch scripts/run_slurm_array.sbatch"