From f9c4a894aa03cde3b87166d8f65366f844496148 Mon Sep 17 00:00:00 2001 From: Gaspard Jankowiak Date: Mon, 26 Feb 2024 13:25:43 +0100 Subject: [PATCH] make patch_n2v guess paths --- patch_n2v.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/patch_n2v.sh b/patch_n2v.sh index c0e0912..73670ee 100755 --- a/patch_n2v.sh +++ b/patch_n2v.sh @@ -1,5 +1,15 @@ #!/bin/bash +set -e + +if [[ -z "$CONDA_PREFIX" ]]; then + echo "You do not seem to have an active conda environment active, aborting" + exit 1 +fi +PYTHON_VERSION=$(python --version | sed -e 's/.* \([0-9]\.[0-9]\{2\}\).*/\1/') +echo "Detected python v$PYTHON_VERSION" +N2V_DIR="$CONDA_PREFIX/lib/python$PYTHON_VERSION/site-packages/n2v" + case $1 in r | reset) echo "Unpatching n2v" @@ -7,12 +17,21 @@ r | reset) cp -v n2v.bak/inverter.py n2v/inverter.py cp -v n2v.bak/methods/zmp.py n2v/methods/zmp.py cp -v n2v.bak/grid/grider.py n2v/grid/grider.py + echo "Success" ;; *) echo "Patching n2v" + if [[ ! -d n2v.bak ]]; then + echo "Backing up n2v ..." + cp -v -r $N2V_DIR n2v.bak + echo "Done" + echo + fi + cp -v n2v.patched/engines/psi4.py n2v/engines/psi4.py cp -v n2v.patched/inverter.py n2v/inverter.py cp -v n2v.patched/methods/zmp.py n2v/methods/zmp.py cp -v n2v.patched/grid/grider.py n2v/grid/grider.py + echo "Success" ;; esac