From ea2e77fc12beb3f4f094efcbfcd59b2b0c6af0ef Mon Sep 17 00:00:00 2001 From: Daniele Rapetti <5535617+Iximiel@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:49:16 +0200 Subject: [PATCH] readding a donfiguration file --- docker/fedora39-pycv | 1 + docker/rocky8-pycv | 1 + plugins/pycv/Makefile | 16 ++++++++++------ plugins/pycv/configurePyCV.sh | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 6 deletions(-) create mode 100755 plugins/pycv/configurePyCV.sh diff --git a/docker/fedora39-pycv b/docker/fedora39-pycv index dd6f95d0e9..e2a0fb36ba 100644 --- a/docker/fedora39-pycv +++ b/docker/fedora39-pycv @@ -15,5 +15,6 @@ RUN source /etc/bashrc \ && cd plumed2 \ && source ./sourceme.sh \ && cd plugins/pycv \ + && ./configurePyCV.sh \ && ln -s $(realpath ../../regtest/scripts) ./regtest/scripts \ && make check diff --git a/docker/rocky8-pycv b/docker/rocky8-pycv index 7c541d3b17..35b12ad5ea 100644 --- a/docker/rocky8-pycv +++ b/docker/rocky8-pycv @@ -15,5 +15,6 @@ RUN . ./.bashrc \ && cd plumed2 \ && source ./sourceme.sh \ && cd plugins/pycv \ + && ./configurePyCV.sh \ && ln -s $(realpath ../../regtest/scripts) ./regtest/scripts \ && make check diff --git a/plugins/pycv/Makefile b/plugins/pycv/Makefile index a385ba0355..d045ccf3e6 100644 --- a/plugins/pycv/Makefile +++ b/plugins/pycv/Makefile @@ -1,3 +1,7 @@ + +PYTHON=python +#optional, just in case you want to override python with ./configurePyCV.sh +-include Makefile.conf #this makefiles assume that pip and pytest are installed .PHONY: clean check check_standalone check_python all @@ -5,12 +9,12 @@ all: pycv_here pycv_here: src/*.cpp src/*.h src/pycv/*.py @echo installing pycv - pip3 install . - touch $@ + $(PYTHON) -m pip install . + @touch $@ clean: - pip3 uninstall pycv - rm -fv pycv_here + @$(PYTHON) -m pip uninstall pycv -y + @rm -fv pycv_here check_standalone: pycv_here $(MAKE) -C regtest testclean @@ -18,7 +22,7 @@ check_standalone: pycv_here #just in case pytest is still not installed we install it before the tests check_python: pycv_here - pip3 install pytest - pytest -v + @$(PYTHON) -m pip install pytest + @$(PYTHON) -m pytest -v check: check_standalone check_python diff --git a/plugins/pycv/configurePyCV.sh b/plugins/pycv/configurePyCV.sh new file mode 100755 index 0000000000..f97dcaae8b --- /dev/null +++ b/plugins/pycv/configurePyCV.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +#formatted with shfmtv3.36.0 (https://github.com/mvdan/sh/releases) + +#A simple script to configure PyCV if python does not work +PYTHON="" +if which plumed >/dev/null; then + echo "plumed found" + PYTHON=$(plumed --no-mpi info --configuration | grep 'python_bin=') + PYTHON=${PYTHON#python_bin=} +fi + +if [ -z "$PYTHON" ]; then + echo "python not found using plumed" + echo "serching for available python with plumed module installed" + + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import plumed" 2>/dev/null; then + if [ $python_bin != python ]; then + PYTHON=$python_bin + fi + return 1 + fi + done + +fi + +if [ -z "$PYTHON" ]; then + echo "python not found" + exit 1 +fi + +cat <Makefile.conf +PYTHON=$(which "$PYTHON") +EOF