diff --git a/.github/workflows/linuxWF.yml b/.github/workflows/linuxWF.yml index 21a1237ea2..8c96987838 100644 --- a/.github/workflows/linuxWF.yml +++ b/.github/workflows/linuxWF.yml @@ -198,8 +198,7 @@ jobs: if: contains( matrix.variant, '-pycv-' ) working-directory: ./plugins/pycv/ run: | - pip install --user -r requirements.txt source ../../sourceme.sh ln -s $(realpath ../../regtest/scripts) ./regtest/scripts - ./prepareMakeForDevelop.sh make check + diff --git a/docker/fedora39-pycv b/docker/fedora39-pycv index 80b6ed15d7..e2a0fb36ba 100644 --- a/docker/fedora39-pycv +++ b/docker/fedora39-pycv @@ -2,10 +2,19 @@ FROM plumed:fedora39 RUN source /etc/bashrc \ && module load mpi \ + && export OMPI_MCA_btl_base_warn_component_unused=0 \ + && export OMPI_MCA_btl_base_verbose=0 \ + && export OMPI_MCA_plm=isolated \ + && export OMPI_MCA_btl_vader_single_copy_mechanism=none \ + && export OMPI_MCA_rmaps_base_oversubscribe=yes \ + && export PATH=$HOME/opt/bin:$PATH \ + && export CPATH=$HOME/opt/include:$CPATH \ + && export INCLUDE=$HOME/opt/include:$INCLUDE \ + && export LIBRARY_PATH=$HOME/opt/lib:$LIBRARY_PATH \ + && export LD_LIBRARY_PATH=$HOME/opt/lib:$LD_LIBRARY_PATH \ && cd plumed2 \ && source ./sourceme.sh \ && cd plugins/pycv \ - && pip3 install -r requirements.txt \ + && ./configurePyCV.sh \ && ln -s $(realpath ../../regtest/scripts) ./regtest/scripts \ - && python_bin=python3 ./prepareMakeForDevelop.sh \ && make check diff --git a/docker/rocky8-pycv b/docker/rocky8-pycv index 7dedd42ce3..35b12ad5ea 100644 --- a/docker/rocky8-pycv +++ b/docker/rocky8-pycv @@ -1,11 +1,20 @@ FROM plumed:rocky8 -RUN source ./.bashrc \ +RUN . ./.bashrc \ && module load mpi \ + && export OMPI_MCA_btl_base_warn_component_unused=0 \ + && export OMPI_MCA_btl_base_verbose=0 \ + && export OMPI_MCA_plm=isolated \ + && export OMPI_MCA_btl_vader_single_copy_mechanism=none \ + && export OMPI_MCA_rmaps_base_oversubscribe=yes \ + && export PATH=$HOME/opt/bin:$PATH \ + && export CPATH=$HOME/opt/include:$CPATH \ + && export INCLUDE=$HOME/opt/include:$INCLUDE \ + && export LIBRARY_PATH=$HOME/opt/lib:$LIBRARY_PATH \ + && export LD_LIBRARY_PATH=$HOME/opt/lib:$LD_LIBRARY_PATH \ && cd plumed2 \ && source ./sourceme.sh \ && cd plugins/pycv \ - && pip3 install --user -r requirements.txt \ + && ./configurePyCV.sh \ && ln -s $(realpath ../../regtest/scripts) ./regtest/scripts \ - && python_bin=python3 ./prepareMakeForDevelop.sh \ && make check diff --git a/plugins/pycv/.gitignore b/plugins/pycv/.gitignore index 7df00fe885..9b90bc2d91 100644 --- a/plugins/pycv/.gitignore +++ b/plugins/pycv/.gitignore @@ -1,4 +1,7 @@ /Makefile.conf *.o *.so -env +/env*/ +/build*/ +/dist*/ +*.whl \ No newline at end of file diff --git a/plugins/pycv/CMakeLists.txt b/plugins/pycv/CMakeLists.txt new file mode 100644 index 0000000000..e3f6f69a2b --- /dev/null +++ b/plugins/pycv/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 3.15...3.27) +project( + ${SKBUILD_PROJECT_NAME} + VERSION ${SKBUILD_PROJECT_VERSION} + LANGUAGES CXX) +set(CMAKE_CXX_STANDARD 17) + +message( + STATUS + "Everithing should work fine if you are in the same environment in which you have compiled plumed" +) +# FinPlumed is here: +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") +# Finding necessary packages +find_package(Python REQUIRED COMPONENTS Interpreter Development) +find_package(pybind11 CONFIG REQUIRED) +find_package(Plumed REQUIRED) + +# Finding optionals things +if(Plumed_HAS_MPI) + find_package(MPI REQUIRED) +endif() +if(MPI_CXX_FOUND) + list(APPEND extraLibs MPI::MPI_CXX) +endif() + +if(Plumed_HAS_OPENMP) + find_package(OpenMP REQUIRED) +endif() +if(OpenMP_CXX_FOUND) + list(APPEND extraLibs OpenMP::OpenMP_CXX) +endif() + +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-fno-gnu-unique USE_NO_GNU_UNIQUE) +if(USE_NO_GNU_UNIQUE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-gnu-unique") +endif() + +# plumed_STATIC_LDFLAGS_OTHER:INTERNAL=-rdynamic;-Wl,-Bsymbolic;-fopenmp +# -rdynamic is automatically set by cmake, and also -fPIC + +################################################################################ +################################the pycv library################################ +################################################################################ + +add_library( + PythonCVInterface SHARED src/ActionWithPython.cpp src/PythonCVInterface.cpp + src/PythonFunction.cpp) +# public, so they trickle down to the python module +target_compile_definitions(PythonCVInterface PUBLIC ${Plumed_CFLAGS}) +target_include_directories(PythonCVInterface PUBLIC src ${Plumed_INCLUDEDIR}) +# #################################################################### +# uncommenting this brings problems since some symbols here are needed +# by the python module even if it should be the correct setting... +# https://gcc.gnu.org/wiki/Visibility could be a starting point +####################################################################### +# target_compile_options(PythonCVInterface PRIVATE -fvisibility=hidden) +target_link_libraries(PythonCVInterface PRIVATE pybind11::embed) +target_link_libraries(PythonCVInterface PUBLIC plumedKernel ${extraLibs}) +# this removes the "lib" prefix +set_target_properties(PythonCVInterface PROPERTIES PREFIX "") + +install(TARGETS PythonCVInterface DESTINATION pycv) + +################################################################################ +###########################The pvCV companion module############################ +################################################################################ + +pybind11_add_module(plumedCommunications src/PlumedPythonEmbeddedModule.cpp) +target_link_libraries(plumedCommunications PRIVATE pybind11::headers) +target_link_libraries(plumedCommunications PUBLIC PythonCVInterface) + +# The install directory is the output (wheel) directory +install(TARGETS plumedCommunications DESTINATION .) diff --git a/plugins/pycv/FindPlumed.cmake b/plugins/pycv/FindPlumed.cmake new file mode 100644 index 0000000000..160518c7cf --- /dev/null +++ b/plugins/pycv/FindPlumed.cmake @@ -0,0 +1,87 @@ +if(NOT Plumed_FOUND) + find_package(PkgConfig) + if(Plumed_FIND_QUIETLY) + function(message) + # THIS completely shuts down messages + endfunction() + pkg_check_modules(PLUMED QUIET plumedInternals) + else() + pkg_check_modules(PLUMED plumedInternals) + endif() + + if(Plumed_FOUND) + if("-D__PLUMED_HAS_MPI=1" IN_LIST Plumed_CFLAGS) + set(Plumed_HAS_MPI + 1 + CACHE INTERNAL "plumed has MPI") + endif() + if("-fopenmp" IN_LIST Plumed_STATIC_LDFLAGS_OTHER) + set(Plumed_HAS_OPENMP + 1 + CACHE INTERNAL "plumed has OpenMP") + endif() + else() + message(STATUS "plumed not found via pkgconfig, trying executable") + + execute_process( + COMMAND plumed --no-mpi info --include-dir + RESULT_VARIABLE PLUMED_EXECUTABLE + OUTPUT_QUIET ERROR_QUIET) + if(PLUMED_EXECUTABLE EQUAL 0) + set(Plumed_FOUND + 1 + CACHE INTERNAL "plumed found") + + message(STATUS "Configuring plumed from executable") + execute_process( + COMMAND plumed --no-mpi info --include-dir + OUTPUT_VARIABLE Plumed_INCLUDEDIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(Plumed_INCLUDEDIR + ${Plumed_INCLUDEDIR} + CACHE INTERNAL "plumed include dir") + execute_process( + COMMAND plumed --no-mpi info --configuration + OUTPUT_VARIABLE Plumed_CONFIG + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(Plumed_CPP_FLAGS "") + + string(REPLACE "\n" ";" ProcessFile_LINES "${Plumed_CONFIG}") + foreach(_line ${ProcessFile_LINES}) + if(${_line} MATCHES "CPPFLAGS=.*") + set(Plumed_CPP_FLAGS ${_line}) + string(REGEX REPLACE "CPPFLAGS= *" "" Plumed_CPP_FLAGS + ${Plumed_CPP_FLAGS}) + string(REPLACE "\\" "" Plumed_CPP_FLAGS ${Plumed_CPP_FLAGS}) + string(REPLACE "-D" ";" Plumed_CPP_FLAGS ${Plumed_CPP_FLAGS}) + # message(STATUS "Found PLUMED CPP_FLAGS: \"${Plumed_CPP_FLAGS}\"") + # message(STATUS "Found PLUMED CPP_FLAGS:") foreach(_flag + # ${Plumed_CPP_FLAGS}) message(STATUS " \"${_flag}\"") endforeach() + endif() + if(${_line} MATCHES ".*-fopenmp.*") + set(Plumed_HAS_MPI + 1 + CACHE INTERNAL "plumed has MPI") + endif() + endforeach() + set(Plumed_CFLAGS + ${Plumed_CPP_FLAGS} + CACHE INTERNAL "plumed Definitions flags") + + execute_process(COMMAND plumed --no-mpi config -q has mpi + RESULT_VARIABLE Plumed_WITH_MPI) + if(Plumed_WITH_MPI EQUAL 0) + set(Plumed_HAS_MPI + 1 + CACHE INTERNAL "plumed has MPI") + endif() + + else() + if(Plumed_FIND_REQUIRED) + message(FATAL_ERROR "plumed not found") + endif() + endif() + endif() +endif() diff --git a/plugins/pycv/Makefile b/plugins/pycv/Makefile index 9e9ee703cf..d045ccf3e6 100644 --- a/plugins/pycv/Makefile +++ b/plugins/pycv/Makefile @@ -1,53 +1,28 @@ -# include the machine dependent configuration -ifneq ($(MAKECMDGOALS),clean) - -include ../../Makefile.conf - ifndef canPyCV - include ./Makefile.conf - endif -endif -.PHONY: clean check all -#Dependency tracking based on https://make.mad-scientist.net/papers/advanced-auto-dependency-generation/#tldr -#this assumes gcc -DEPDIR := .deps -DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.d -PYBIND11FLAG = -ADDCPPFLAGS:=$(python_cf_embedded) $(pybind11_cflags) $(ADDCPPFLAGS) -ADDCLDFLAGS:=$(ADDCLDFLAGS) $(python_ld_embedded) -OBJS = ActionWithPython.o PythonCVInterface.o PythonFunction.o PlumedPythonEmbeddedModule.o +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 -ifeq ($(SOEXT),dylib) - SONAME_OPTION:=-Wl,-install_name -else - SONAME_OPTION:=-Wl,-soname -endif +all: pycv_here -all: PythonCVInterface.$(SOEXT) - -#-fvisibility=hidden is needed for pybind11 (to not conflict with different pybind11 versions) -#I think I enforced this nearly everywhere I set up a flag for the compiler -ActionWithPython.o PythonCVInterface.o PythonFunction.o PlumedPythonEmbeddedModule.o: PYBIND11FLAG= -fvisibility=hidden - -%.o: %.cpp $(DEPDIR)/%.d | $(DEPDIR) - @echo Compiling object $@ - @$(CXX) -c $(DEPFLAGS) $(CPPFLAGS) $(PYBIND11FLAG) $(ADDCPPFLAGS) $(CXXFLAGS) $< -o $@ - - -$(DEPDIR): ; @mkdir -p $@ - -DEPFILES := $(OBJS:%.o=$(DEPDIR)/%.d) -$(DEPFILES): -include $(wildcard $(DEPFILES)) - -#-Wl,--no-as-needed forces the python library to be linked, without this in a WSL does not work -#TODO: seems that $PLUMED_KERNEL is not needed, check -PythonCVInterface.$(SOEXT): $(OBJS) - @echo Linking $@ - $(LDSHARED) $(SONAME_OPTION),"$(notdir $@)" $(DYNAMIC_LIBS) $(PLUMED_KERNEL) $(ADDCLDFLAGS) $^ -o $@ +pycv_here: src/*.cpp src/*.h src/pycv/*.py + @echo installing pycv + $(PYTHON) -m pip install . + @touch $@ clean: - rm -f $(OBJS) PythonCVInterface.$(SOEXT) + @$(PYTHON) -m pip uninstall pycv -y + @rm -fv pycv_here -check: all +check_standalone: pycv_here $(MAKE) -C regtest testclean $(MAKE) -C regtest checkfail + +#just in case pytest is still not installed we install it before the tests +check_python: pycv_here + @$(PYTHON) -m pip install pytest + @$(PYTHON) -m pytest -v + +check: check_standalone check_python diff --git a/plugins/pycv/astyle.sh b/plugins/pycv/astyle.sh index 51b0a7be36..86a2d3da7f 100755 --- a/plugins/pycv/astyle.sh +++ b/plugins/pycv/astyle.sh @@ -3,13 +3,14 @@ #formatted with shfmt https://github.com/mvdan/sh/releases #checked with shellcheck +cd src || exit 1 for file in *.c *.cpp *.h *.inc.in; do test -f "$file" || continue echo -n "astyle $file" - ../../astyle/astyle --options=../../.astyle.options <"$file" >"${file}.tmp" && { + ../../../astyle/astyle --options=../../../.astyle.options <"$file" >"${file}.tmp" && { if cmp -s "$file" "${file}.tmp"; then echo else diff --git a/plugins/pycv/compileConfiguration.sh b/plugins/pycv/compileConfiguration.sh deleted file mode 100644 index e9eac1fdbe..0000000000 --- a/plugins/pycv/compileConfiguration.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/env bash - -#formatted with shfmt https://github.com/mvdan/sh/releases -#checked with shellcheck -# shellcheck disable=SC2034 # The unused variables will be used in sourcer files - -#please source this file - -#for some reason, on the WSL I need to compile with -# `export PYCV_EXTRA_LDFLAGS="-Wl,--no-as-needed"` -#-Wl,--no-as-needed forces the python library to be linked -#I do not undestand why, since -as-needed should be disabled by default - -plumed_program_name=${plumed_program_name:-plumed} - -#check if during config time the settings for compiling PyCV where got -plumed_canPyCV=$( - ${plumed_program_name} --no-mpi config makefile_conf | grep canPyCV | sed -e s/^canPyCV=// -) - -if [[ $plumed_canPyCV = yes ]]; then - pybind11_cflags=$(plumed --no-mpi config makefile_conf | grep pybind11_cflags | sed -e s/^pybind11_cflags=//) - python_cf_embedded=$(plumed --no-mpi config makefile_conf | grep python_cf_embedded | sed -e s/^python_cf_embedded=//) - python_ld_embedded=$(plumed --no-mpi config makefile_conf | grep python_ld_embedded | sed -e s/^python_ld_embedded=//) -else - #assign a default value to python bin and plumed - python_bin=${python_bin:-python} - #python3-config may be any python3.* version, this should avoid contamination from other environments - #and use pythonX.Y-config, as suggested in the manual - pyver=$($python_bin -c "import sysconfig;print(sysconfig.get_config_var('VERSION'))") - python_config=python${pyver}-config - - # Note that in conda libpython3xx is not found in the path returned by ldflags. IMHO it is a bug. - # The workaround is to -L appropriately. Will be fixed here. - conda_fixup=${CONDA_PREFIX+-L$CONDA_PREFIX/lib} - if [ -n "$conda_fixup" ]; then - echo "CONDA_PREFIX is set. Assuming conda and enabling a workaround for missing -L in ${python_config} --ldflags --embed" - fi - - if ! ${python_config} --embed >/dev/null 2>/dev/null; then - #TODO: verify that this does not give problems with conda - echo "PyCV needs python to be built to be embedable" - echo "(compiling python with --enable-shared should be enough)" - exit 1 - fi - if ! ${python_bin} -m pybind11 --includes >/dev/null; then - #python will automatically say that there is non pybind11 - exit 1 - fi - #-fvisibility=hidden is needed to correct the warnings for the visibility of some pybind11 functionalities - pybind11_cflags="$(${python_bin} -m pybind11 --includes) -fvisibility=hidden" - python_cf_embedded=$(${python_config} --cflags --embed) - python_ld_embedded=$(${python_config} --ldflags --embed) -fi 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 diff --git a/plugins/pycv/prepareMakeForDevelop.sh b/plugins/pycv/prepareMakeForDevelop.sh deleted file mode 100755 index 375851c5a9..0000000000 --- a/plugins/pycv/prepareMakeForDevelop.sh +++ /dev/null @@ -1,27 +0,0 @@ -#! /usr/bin/env bash - -#formatted with shfmt https://github.com/mvdan/sh/releases -#checked with shellcheck -# the SC2154 warnings are variables present in the sourced file - -source compileConfiguration.sh - - -if [[ -z $PLUMED_KERNEL ]]; then - echo "$(basename $0) can work only if \"PLUMED_KERNEL\" is defined" - echo "either via module load or sourceme.sh, or manually exported" - exit 1 -fi - -plumed_include=$(${plumed_program_name} --no-mpi info --include-dir) -{ - ${plumed_program_name} --no-mpi config makefile_conf - echo "PLUMED_KERNEL=${PLUMED_KERNEL}" - if [[ ! $plumed_canPyCV = yes ]]; then - echo "pybind11_cflags=$pybind11_cflags" - echo "python_cf_embedded=$python_cf_embedded" - echo "python_ld_embedded=$python_ld_embedded" - fi - echo "ADDCPPFLAGS=-I${plumed_include}/plumed" - echo "ADDCLDFLAGS=${PYCV_EXTRA_LDFLAGS} ${conda_fixup}" -} > Makefile.conf diff --git a/plugins/pycv/pyproject.toml b/plugins/pycv/pyproject.toml new file mode 100644 index 0000000000..ac06ea8c2a --- /dev/null +++ b/plugins/pycv/pyproject.toml @@ -0,0 +1,61 @@ +[build-system] +requires = ["scikit-build-core>=0.10", "pybind11>=2.10.3,<=2.11.1", "numpy"] +build-backend = "scikit_build_core.build" + + +[project] +name = "pycv" +dependencies = [ + "numpy", + "pybind11>=2.10.3,<=2.11.1" +] +version = "0.0.1" +description="PyCV support module for plumed" +readme = "README.md" +authors = [ + { name = "Toni Giorgino", email = "toni.giorgino@gmail.com" }, + { name = "Daniele Rapetti", email = "daniele.rapetti@sissa.it" }, +] +requires-python = ">=3.9" +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] + +[project.optional-dependencies] +test = ["pytest", "plumed"] + +[project.scripts] +pycv = "pycv:main" + +[tool.scikit-build] +wheel.expand-macos-universal-tags = true +minimum-version = "build-system.requires" + + +[tool.pytest.ini_options] +minversion = "8.0" +addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] +xfail_strict = true +log_cli_level = "INFO" +filterwarnings = [ + "error", + "ignore::pytest.PytestCacheWarning", +] +testpaths = ["pythontests"] + + +[tool.cibuildwheel] +build-frontend = "build[uv]" +test-command = "pytest {project}/pythontests" +test-extras = ["test"] + +[tool.cibuildwheel.pyodide] +build-frontend = {name = "build", args = ["--exports", "whole_archive"]} + diff --git a/plugins/pycv/pythontests/.gitignore b/plugins/pycv/pythontests/.gitignore new file mode 100644 index 0000000000..e378414052 --- /dev/null +++ b/plugins/pycv/pythontests/.gitignore @@ -0,0 +1,4 @@ +bck* +*.out +logfile +*.log diff --git a/plugins/pycv/pythontests/atoms_number.py b/plugins/pycv/pythontests/atoms_number.py new file mode 100644 index 0000000000..0f3bca1aaf --- /dev/null +++ b/plugins/pycv/pythontests/atoms_number.py @@ -0,0 +1,19 @@ +import plumedCommunications as PLMD + +from sys import stderr as log +# log = open("pydist.log", "w") + +print("Imported my pydist+.", file=log) + + +def plumedInitio(action: PLMD.PythonCVInterface): + # return {"Value": {"period": [None,0,0]}} + # return {"Value": {"period": None}} + return {"Value": {"period": ["0",0.3]}} +plumedInit={"Value": {"period": None},"NOPBC":False, + "ATOMS":"1,2"} + +def plumedCalculate(action: PLMD.PythonCVInterface): + ret = [action.nat] + print ("Hello from plumedCalculate") + return ret diff --git a/plugins/pycv/pythontests/justInit.py b/plugins/pycv/pythontests/justInit.py new file mode 100644 index 0000000000..b0df723d36 --- /dev/null +++ b/plugins/pycv/pythontests/justInit.py @@ -0,0 +1,10 @@ +import numpy as np +import plumedCommunications + + +def myInit(_: plumedCommunications.PythonCVInterface): + return{"Value": plumedCommunications.defaults.COMPONENT_NODEV,} + +def plumedCalculate(action: plumedCommunications.PythonCVInterface): + at: np.ndarray = action.getPositions() + return at[0][0]+at[0][1] diff --git a/plugins/pycv/pythontests/justInitDict.py b/plugins/pycv/pythontests/justInitDict.py new file mode 100644 index 0000000000..009b089f4f --- /dev/null +++ b/plugins/pycv/pythontests/justInitDict.py @@ -0,0 +1,8 @@ +import numpy as np +import plumedCommunications + +plumedInit={"Value": plumedCommunications.defaults.COMPONENT,} + +def plumedCalculate(action: plumedCommunications.PythonCVInterface): + at: np.ndarray = action.getPositions() + return at[0][0]+at[0][1] diff --git a/plugins/pycv/pythontests/justPrepare.py b/plugins/pycv/pythontests/justPrepare.py new file mode 100644 index 0000000000..1e1bb7301f --- /dev/null +++ b/plugins/pycv/pythontests/justPrepare.py @@ -0,0 +1,13 @@ +import numpy as np +import plumedCommunications + +plumedInit={"Value": plumedCommunications.defaults.COMPONENT,} + +def plumedPrepare(_: plumedCommunications.PythonCVInterface): + toret = {"setAtomRequest": f"1"} + return toret + + +def plumedCalculate(action: plumedCommunications.PythonCVInterface): + at: np.ndarray = action.getPositions() + return at[0][0]+at[0][1] diff --git a/plugins/pycv/pythontests/justUpdate.py b/plugins/pycv/pythontests/justUpdate.py new file mode 100644 index 0000000000..182049abf5 --- /dev/null +++ b/plugins/pycv/pythontests/justUpdate.py @@ -0,0 +1,12 @@ +import numpy as np +import plumedCommunications + +plumedInit={"Value": plumedCommunications.defaults.COMPONENT,} + +def myUpdate(_: plumedCommunications.PythonCVInterface): + print("myUpdate") + return {} + +def plumedCalculate(action: plumedCommunications.PythonCVInterface): + at: np.ndarray = action.getPositions() + return at[0][0]+at[0][1] diff --git a/plugins/pycv/pythontests/pycvPerFrame.py b/plugins/pycv/pythontests/pycvPerFrame.py new file mode 120000 index 0000000000..72efc4907a --- /dev/null +++ b/plugins/pycv/pythontests/pycvPerFrame.py @@ -0,0 +1 @@ +../regtest/pycvcomm/rt-newFrameNewAtom/pycvPerFrame.py \ No newline at end of file diff --git a/plugins/pycv/pythontests/pycvPerFrameSTR.py b/plugins/pycv/pythontests/pycvPerFrameSTR.py new file mode 120000 index 0000000000..fe96d1970c --- /dev/null +++ b/plugins/pycv/pythontests/pycvPerFrameSTR.py @@ -0,0 +1 @@ +../regtest/pycvcomm/rt-newFrameNewAtomSTR/pycvPerFrame.py \ No newline at end of file diff --git a/plugins/pycv/pythontests/pycvPersistentData b/plugins/pycv/pythontests/pycvPersistentData new file mode 120000 index 0000000000..e74d2380e4 --- /dev/null +++ b/plugins/pycv/pythontests/pycvPersistentData @@ -0,0 +1 @@ +../regtest/pycvcomm/rt-persistentData/pycvPersistentData \ No newline at end of file diff --git a/plugins/pycv/pythontests/pydistancePBCs.py b/plugins/pycv/pythontests/pydistancePBCs.py new file mode 120000 index 0000000000..7e45c7145a --- /dev/null +++ b/plugins/pycv/pythontests/pydistancePBCs.py @@ -0,0 +1 @@ +../regtest/pycvcomm/rt-PBCs/pydistancePBCs.py \ No newline at end of file diff --git a/plugins/pycv/pythontests/pydistancegetAtPos.py b/plugins/pycv/pythontests/pydistancegetAtPos.py new file mode 120000 index 0000000000..7d693ec5cd --- /dev/null +++ b/plugins/pycv/pythontests/pydistancegetAtPos.py @@ -0,0 +1 @@ +../regtest/pycvcomm/rt-getPosition/pydistancegetAtPos.py \ No newline at end of file diff --git a/plugins/pycv/pythontests/pyfuncINITdict.py b/plugins/pycv/pythontests/pyfuncINITdict.py new file mode 120000 index 0000000000..eb9f725611 --- /dev/null +++ b/plugins/pycv/pythontests/pyfuncINITdict.py @@ -0,0 +1 @@ +../regtest/pycvfunc/rt-argumentsArray/unitTest.py \ No newline at end of file diff --git a/plugins/pycv/pythontests/pyfuncINITfunc.py b/plugins/pycv/pythontests/pyfuncINITfunc.py new file mode 120000 index 0000000000..d6961d59ba --- /dev/null +++ b/plugins/pycv/pythontests/pyfuncINITfunc.py @@ -0,0 +1 @@ +../regtest/pycvfunc/rt-derivative/unitTest.py \ No newline at end of file diff --git a/plugins/pycv/pythontests/test_cv.py b/plugins/pycv/pythontests/test_cv.py new file mode 100644 index 0000000000..7d0ddc1631 --- /dev/null +++ b/plugins/pycv/pythontests/test_cv.py @@ -0,0 +1,200 @@ +import unittest +import numpy as np + +from utilities_for_test import * + +import os + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + + +class TestPyCV(unittest.TestCase): + def test_nat(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, num_frames, num_atoms, box, virial, masses, forces, charges = ( + setUpTraj("traj.xyz") + ) + plmd = preparePlumed(num_atoms) + cvPy = create_plumed_var(plmd, "cvPy", "PYCVINTERFACE IMPORT=atoms_number") + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + # Open an output file + with open("logfile", "w+") as of: + # Now analyze the trajectory + for step in range(0, num_frames): + of.write("RUNNING ANALYSIS FOR STEP " + str(step) + "\n") + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + + self.assertEqual(cvPy, 2) + + def test_atomPositions(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, num_frames, num_atoms, box, virial, masses, forces, charges = ( + setUpTraj("traj.xyz") + ) + plmd = preparePlumed(num_atoms) + + cvPy = create_plumed_var( + plmd, + "cvPy", + "PYCVINTERFACE ATOMS=1,4 IMPORT=pydistancegetAtPos CALCULATE=pydist", + ) + cvCPP = create_plumed_var(plmd, "cvCPP", "DISTANCE ATOMS=1,4 NOPBC") + + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + # Open an output file + with open("logfile", "w+") as of: + # Now analyze the trajectory + for step in range(0, num_frames): + of.write("RUNNING ANALYSIS FOR STEP " + str(step) + "\n") + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + + np.testing.assert_almost_equal(cvPy, cvCPP, decimal=4) + + def test_atomPositionsPBC(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, num_frames, num_atoms, box, virial, masses, forces, charges = ( + setUpTraj("traj.xyz") + ) + plmd = preparePlumed(num_atoms) + + cvPy = create_plumed_var( + plmd, + "cvPy", + "PYCVINTERFACE ATOMS=1,4 IMPORT=pydistancePBCs CALCULATE=pydist", + ) + cvCPP = create_plumed_var(plmd, "cvCPP", "DISTANCE ATOMS=1,4") + + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + # Open an output file + with open("logfile", "w+") as of: + # Now analyze the trajectory + for step in range(0, num_frames): + of.write("RUNNING ANALYSIS FOR STEP " + str(step) + "\n") + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + + np.testing.assert_almost_equal(cvPy, cvCPP, decimal=4) + + def test_newFrameNewAtomSTR(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, num_frames, num_atoms, box, virial, masses, forces, charges = ( + setUpTraj("trajnewFrameNewAtom.xyz") + ) + plmd = preparePlumed(num_atoms) + + cvPy = create_plumed_var( + plmd, + "cvPy", + "PYCVINTERFACE ATOMS=@mdatoms IMPORT=pycvPerFrameSTR CALCULATE=pydist PREPARE=changeAtom", + ) + + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + # Open an output file + with open("logfile", "w+") as of: + # Now analyze the trajectory + for step in range(0, num_frames): + of.write("RUNNING ANALYSIS FOR STEP " + str(step) + "\n") + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + + np.testing.assert_almost_equal(cvPy, step + 1.0, decimal=4) + + def test_newFrameNewAtom(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, num_frames, num_atoms, box, virial, masses, forces, charges = ( + setUpTraj("trajnewFrameNewAtom.xyz") + ) + plmd = preparePlumed(num_atoms) + + cvPy = create_plumed_var( + plmd, + "cvPy", + "PYCVINTERFACE ATOMS=@mdatoms IMPORT=pycvPerFrame CALCULATE=pydist PREPARE=changeAtom", + ) + + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + # Open an output file + with open("logfile", "w+") as of: + # Now analyze the trajectory + for step in range(0, num_frames): + of.write("RUNNING ANALYSIS FOR STEP " + str(step) + "\n") + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + + np.testing.assert_almost_equal(cvPy, step + 1.0, decimal=4) + + def test_loadAmodule_and_persistData(self): + """This test loads a module that is a directory and stores some data within plumed""" + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, num_frames, num_atoms, box, virial, masses, forces, charges = ( + setUpTraj("trajnewFrameNewAtom.xyz") + ) + plmd = preparePlumed(num_atoms) + + cvPy = create_plumed_var( + plmd, + "cvPy", + "PYCVINTERFACE ATOMS=@mdatoms IMPORT=pycvPersistentData CALCULATE=pydist INIT=pyinit", + ) + + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + + # Now analyze the trajectory + for step in range(0, num_frames): + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + # this cv sums the number of the step till now: + # to future me: "//" is integer (floor) division + np.testing.assert_almost_equal( + cvPy, ((step) * (step + 1)) // 2, decimal=4 + ) + + +if __name__ == "__main__": + # Output to four decimal places only + np.set_printoptions(precision=4) + unittest.main() diff --git a/plugins/pycv/pythontests/test_cv_calls.py b/plugins/pycv/pythontests/test_cv_calls.py new file mode 100644 index 0000000000..4c6086cbf4 --- /dev/null +++ b/plugins/pycv/pythontests/test_cv_calls.py @@ -0,0 +1,123 @@ +import unittest +import numpy as np + +from utilities_for_test import * + +import os + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + + +class TestPyCVCalls(unittest.TestCase): + def test_INIT(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, _, num_atoms, box, virial, masses, forces, charges = setUpTraj( + "traj.xyz" + ) + plmd = preparePlumed(num_atoms) + + cvPy = create_plumed_var( + plmd, "cvPy", "PYCVINTERFACE ATOMS=4 IMPORT=justInit INIT=myInit" + ) + + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + + step = 0 + + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + np.testing.assert_almost_equal(cvPy, 10.0, decimal=4) + + def test_INITDICT(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, _, num_atoms, box, virial, masses, forces, charges = setUpTraj( + "traj.xyz" + ) + plmd = preparePlumed(num_atoms) + + cvPy = create_plumed_var( + plmd, "cvPy", "PYCVINTERFACE ATOMS=4 IMPORT=justInitDict" + ) + + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + + step = 0 + + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + np.testing.assert_almost_equal(cvPy, 10.0, decimal=4) + + def test_UPDATE(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, _, num_atoms, box, virial, masses, forces, charges = setUpTraj( + "traj.xyz" + ) + plmd = preparePlumed(num_atoms) + + cvPy = create_plumed_var( + plmd, "cvPy", "PYCVINTERFACE ATOMS=4 IMPORT=justUpdate UPDATE=myUpdate" + ) + + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + + step = 0 + + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + np.testing.assert_almost_equal(cvPy, 10.0, decimal=4) + + def test_PREPARE(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, _, num_atoms, box, virial, masses, forces, charges = setUpTraj( + "traj.xyz" + ) + plmd = preparePlumed(num_atoms) + # atoms=4 but the module choses 1 + cvPy = create_plumed_var( + plmd, + "cvPy", + "PYCVINTERFACE ATOMS=4 IMPORT=justPrepare PREPARE=plumedPrepare", + ) + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + # Open an output file + + step = 0 + + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + + np.testing.assert_almost_equal(cvPy, 5.0, decimal=4) + + +if __name__ == "__main__": + # Output to four decimal places only + np.set_printoptions(precision=4) + unittest.main() diff --git a/plugins/pycv/pythontests/test_fun_calls.py b/plugins/pycv/pythontests/test_fun_calls.py new file mode 100644 index 0000000000..3ba155d062 --- /dev/null +++ b/plugins/pycv/pythontests/test_fun_calls.py @@ -0,0 +1,92 @@ +import unittest +import numpy as np + +from utilities_for_test import * + +import os + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) + +# CALCULATE is tested "by default" + + +class TestFunctionCalls(unittest.TestCase): + def test_INIT(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, num_frames, num_atoms, box, virial, masses, forces, charges = ( + setUpTraj("traj.xyz") + ) + plmd = preparePlumed(num_atoms) + d1 = create_plumed_var(plmd, "d1", "DISTANCE ATOMS=1,2") + d2 = create_plumed_var(plmd, "d2", "DISTANCE ATOMS=1,3") + + fPy = create_plumed_var( + plmd, + "fPY", + "PYFUNCTION IMPORT=pyfuncINITfunc INIT=initForF CALCULATE=function ARG=d1,d2", + ) + + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + + for step in range(num_frames): + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + + np.testing.assert_almost_equal(fPy, d1 * d2, decimal=4) + + def test_INITDICT(self): + with cd(THIS_DIR): + os.environ["PLUMED_MAXBACKUP"] = "0" + traj, num_frames, num_atoms, box, virial, masses, forces, charges = ( + setUpTraj("traj.xyz") + ) + plmd = preparePlumed(num_atoms) + + plmd.cmd("readInputLine", "dc: DISTANCE ATOMS=1,2 COMPONENTS") + shape = np.zeros(1, dtype=np.int_) + plmd.cmd("getDataRank " + "dc.x", shape) + plmd.cmd("getDataRank " + "dc.y", shape) + plmd.cmd("getDataRank " + "dc.z", shape) + dcx = np.zeros((1)) + dcy = np.zeros((1)) + dcz = np.zeros((1)) + plmd.cmd("setMemoryForData dc.x", dcx) + plmd.cmd("setMemoryForData dc.y", dcy) + plmd.cmd("setMemoryForData dc.z", dcz) + + d = create_plumed_var(plmd, "d", "DISTANCE ATOMS=1,2") + + fPy = create_plumed_var( + plmd, + "fPY", + "PYFUNCTION IMPORT=pyfuncINITdict INIT=initForF CALCULATE=function ARG=dc.x,dc.y,dc.z,d", + ) + + plmd.cmd("readInputLine", "PRINT FILE=colvar.out ARG=*") + + for step in range(num_frames): + plmd.cmd("setStep", step) + plmd.cmd("setBox", box) + plmd.cmd("setMasses", masses) + plmd.cmd("setCharges", charges) + plmd.cmd("setPositions", traj[step]) + plmd.cmd("setForces", forces) + plmd.cmd("setVirial", virial) + plmd.cmd("calc") + + np.testing.assert_almost_equal( + fPy, np.abs(np.sqrt(dcx**2 + dcy**2 + dcz**2) - d[0]), decimal=4 + ) + + +if __name__ == "__main__": + # Output to four decimal places only + np.set_printoptions(precision=4) + unittest.main() diff --git a/plugins/pycv/pythontests/traj.xyz b/plugins/pycv/pythontests/traj.xyz new file mode 100644 index 0000000000..c0e66cf2b2 --- /dev/null +++ b/plugins/pycv/pythontests/traj.xyz @@ -0,0 +1,24 @@ +4 +100 100 100 +X 5 0 0 +X 0 0 0 +X 0 5 0 +X 5 5 0 +4 +100 100 100 +X 5 0 0 +X 0 0 0 +X 0 5 0 +X 0 5 5 +4 +100 100 100 +X 5 0 0 +X 0 0 0 +X 0 5 0 +X -5 5 0 +4 +100 100 100 +X 5 0 0 +X 0 0 0 +X 0 5 0 +X 0 5 -5 diff --git a/plugins/pycv/pythontests/trajnewFrameNewAtom.xyz b/plugins/pycv/pythontests/trajnewFrameNewAtom.xyz new file mode 100644 index 0000000000..ead294112f --- /dev/null +++ b/plugins/pycv/pythontests/trajnewFrameNewAtom.xyz @@ -0,0 +1,24 @@ +4 +100 100 100 +X 0 0 0 +X 0 0 1 +X 0 0 0 +X 0 0 0 +4 +100 100 100 +X 0 0 0 +X 0 0 0 +X 0 0 2 +X 0 0 0 +4 +100 100 100 +X 0 0 0 +X 0 0 0 +X 0 0 0 +X 0 0 3 +4 +100 100 100 +X 0 0 0 +X 0 0 4 +X 0 0 0 +X 0 0 0 diff --git a/plugins/pycv/pythontests/utilities_for_test.py b/plugins/pycv/pythontests/utilities_for_test.py new file mode 100644 index 0000000000..1c62b7ddab --- /dev/null +++ b/plugins/pycv/pythontests/utilities_for_test.py @@ -0,0 +1,84 @@ +from plumed import Plumed +from contextlib import contextmanager +import os +import numpy as np + +__all__ = ["read_xyz", "setUpTraj", "preparePlumed", "cd", "create_plumed_var"] + + +@contextmanager +def cd(newdir): + prevdir = os.getcwd() + os.chdir(newdir) + try: + yield + finally: + os.chdir(prevdir) + + +def read_xyz(filename: str): + xyz = open(filename) + n_atoms = int(xyz.readline()) + _ = xyz.readline() + trajectory = [] + while True: + atom_type = np.zeros(n_atoms).astype(str) + coordinates = np.zeros([n_atoms, 3]) + for i in range(0, n_atoms): + line = xyz.readline() + atom, x, y, z = line.split() + atom_type[i] = atom + coordinates[i, :] = np.array([x, y, z], dtype=np.float64) + trajectory.append(coordinates) + nextline = xyz.readline() + if nextline == "": + break + c_atoms = int(nextline) + if c_atoms != n_atoms: + break + _ = xyz.readline() + xyz.close() + return trajectory + + +def setUpTraj(trajfile: str): + traj = read_xyz(trajfile) + num_frames = len(traj) + num_atoms = traj[0].shape[0] + + # Create arrays for stuff + box = np.diag(12.41642 * np.ones(3, dtype=np.float64)) + virial = np.zeros((3, 3), dtype=np.float64) + masses = np.ones(num_atoms, dtype=np.float64) + forces = np.random.rand(num_atoms, 3) + charges = np.zeros(num_atoms, dtype=np.float64) + + return traj, num_frames, num_atoms, box, virial, masses, forces, charges + + +def preparePlumed(num_atoms: int): + from pycv import getPythonCVInterface + + # Create PLUMED object and read input + plmd = Plumed() + + # not really needed, used to check https://github.com/plumed/plumed2/issues/916 + plumed_version = np.zeros(1, dtype=np.intc) + plmd.cmd("getApiVersion", plumed_version) + plmd.cmd("setMDEngine", "python") + plmd.cmd("setTimestep", 1.0) + plmd.cmd("setKbT", 1.0) + plmd.cmd("setNatoms", num_atoms) + plmd.cmd("setLogFile", "test.log") + plmd.cmd("init") + plmd.cmd("readInputLine", f"LOAD FILE={getPythonCVInterface()}") + return plmd + + +def create_plumed_var(plmd: Plumed, name: str, command: str): + plmd.cmd("readInputLine", name + ": " + command) + shape = np.zeros(1, dtype=np.int_) + plmd.cmd("getDataRank " + name, shape) + data = np.zeros((1)) + plmd.cmd("setMemoryForData " + name, data) + return data diff --git a/plugins/pycv/regtest/pycvcomm/rt-MDinformations/config b/plugins/pycv/regtest/pycvcomm/rt-MDinformations/config index 7429ccc9fa..af185de1f2 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-MDinformations/config +++ b/plugins/pycv/regtest/pycvcomm/rt-MDinformations/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz --mc massCharges.dat" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-MDinformations/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-MDinformations/plumed.dat index b2aa6e0aa5..fc6d26d9b9 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-MDinformations/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-MDinformations/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvcomm/rt-PBC-getBox/config b/plugins/pycv/regtest/pycvcomm/rt-PBC-getBox/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-PBC-getBox/config +++ b/plugins/pycv/regtest/pycvcomm/rt-PBC-getBox/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-PBC-getBox/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-PBC-getBox/plumed.dat index 99aca77cbe..8e0f71ac14 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-PBC-getBox/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-PBC-getBox/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvcomm/rt-PBC-getInvBox/config b/plugins/pycv/regtest/pycvcomm/rt-PBC-getInvBox/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-PBC-getInvBox/config +++ b/plugins/pycv/regtest/pycvcomm/rt-PBC-getInvBox/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-PBC-getInvBox/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-PBC-getInvBox/plumed.dat index 58aa94faa7..ccfaae24fd 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-PBC-getInvBox/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-PBC-getInvBox/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvcomm/rt-PBCs/config b/plugins/pycv/regtest/pycvcomm/rt-PBCs/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-PBCs/config +++ b/plugins/pycv/regtest/pycvcomm/rt-PBCs/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-PBCs/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-PBCs/plumed.dat index 4d73a47b57..d26fa5f694 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-PBCs/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-PBCs/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: PYCVINTERFACE ATOMS=1,4 IMPORT=pydistancePBCs CALCULATE=pydist diff --git a/plugins/pycv/regtest/pycvcomm/rt-absoluteIndexes/config b/plugins/pycv/regtest/pycvcomm/rt-absoluteIndexes/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-absoluteIndexes/config +++ b/plugins/pycv/regtest/pycvcomm/rt-absoluteIndexes/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-absoluteIndexes/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-absoluteIndexes/plumed.dat index b5ab5a470d..8cb195373b 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-absoluteIndexes/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-absoluteIndexes/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvcomm/rt-autoFunctions/config b/plugins/pycv/regtest/pycvcomm/rt-autoFunctions/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-autoFunctions/config +++ b/plugins/pycv/regtest/pycvcomm/rt-autoFunctions/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-autoFunctions/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-autoFunctions/plumed.dat index a9cf9e0185..5a9cfb8f26 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-autoFunctions/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-autoFunctions/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvcomm/rt-doc/config b/plugins/pycv/regtest/pycvcomm/rt-doc/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-doc/config +++ b/plugins/pycv/regtest/pycvcomm/rt-doc/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-doc/config.reference b/plugins/pycv/regtest/pycvcomm/rt-doc/config.reference index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-doc/config.reference +++ b/plugins/pycv/regtest/pycvcomm/rt-doc/config.reference @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-doc/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-doc/plumed.dat index 34b82a81c2..d3657abc0d 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-doc/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-doc/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvdist: PYCVINTERFACE IMPORT=pyhelp diff --git a/plugins/pycv/regtest/pycvcomm/rt-getPosition/config b/plugins/pycv/regtest/pycvcomm/rt-getPosition/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-getPosition/config +++ b/plugins/pycv/regtest/pycvcomm/rt-getPosition/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-getPosition/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-getPosition/plumed.dat index 4f10c542cc..aa7cc493f0 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-getPosition/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-getPosition/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: PYCVINTERFACE ATOMS=1,4 IMPORT=pydistancegetAtPos CALCULATE=pydist diff --git a/plugins/pycv/regtest/pycvcomm/rt-getPositionNL/config b/plugins/pycv/regtest/pycvcomm/rt-getPositionNL/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-getPositionNL/config +++ b/plugins/pycv/regtest/pycvcomm/rt-getPositionNL/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-getPositionNL/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-getPositionNL/plumed.dat index 75d37d16bc..1c7340e6d4 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-getPositionNL/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-getPositionNL/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: PYCVINTERFACE GROUPA=1,4 IMPORT=pydistancegetAtPos CALCULATE=pydist diff --git a/plugins/pycv/regtest/pycvcomm/rt-getPositionNLPair/config b/plugins/pycv/regtest/pycvcomm/rt-getPositionNLPair/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-getPositionNLPair/config +++ b/plugins/pycv/regtest/pycvcomm/rt-getPositionNLPair/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-getPositionNLPair/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-getPositionNLPair/plumed.dat index a8b77fa7ef..e35d02e559 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-getPositionNLPair/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-getPositionNLPair/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvcomm/rt-getPositions/config b/plugins/pycv/regtest/pycvcomm/rt-getPositions/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-getPositions/config +++ b/plugins/pycv/regtest/pycvcomm/rt-getPositions/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-getPositions/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-getPositions/plumed.dat index 41acc74975..5995120f82 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-getPositions/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-getPositions/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: PYCVINTERFACE ATOMS=1,4 IMPORT=pydistancegetAt CALCULATE=pydist diff --git a/plugins/pycv/regtest/pycvcomm/rt-makeWhole/config b/plugins/pycv/regtest/pycvcomm/rt-makeWhole/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-makeWhole/config +++ b/plugins/pycv/regtest/pycvcomm/rt-makeWhole/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-makeWhole/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-makeWhole/plumed.dat index 7c72b82cb1..79bb423ec4 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-makeWhole/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-makeWhole/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvcomm/rt-massesAndCharges/config b/plugins/pycv/regtest/pycvcomm/rt-massesAndCharges/config index 7429ccc9fa..af185de1f2 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-massesAndCharges/config +++ b/plugins/pycv/regtest/pycvcomm/rt-massesAndCharges/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz --mc massCharges.dat" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-massesAndCharges/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-massesAndCharges/plumed.dat index b5ab5a470d..8cb195373b 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-massesAndCharges/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-massesAndCharges/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvcomm/rt-massesAndChargesArray/config b/plugins/pycv/regtest/pycvcomm/rt-massesAndChargesArray/config index 7429ccc9fa..af185de1f2 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-massesAndChargesArray/config +++ b/plugins/pycv/regtest/pycvcomm/rt-massesAndChargesArray/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz --mc massCharges.dat" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-massesAndChargesArray/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-massesAndChargesArray/plumed.dat index 2124644f0e..517ddbfa7d 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-massesAndChargesArray/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-massesAndChargesArray/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvcomm/rt-multipleComponents/config b/plugins/pycv/regtest/pycvcomm/rt-multipleComponents/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-multipleComponents/config +++ b/plugins/pycv/regtest/pycvcomm/rt-multipleComponents/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-multipleComponents/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-multipleComponents/plumed.dat index 77e7340b95..a3a0ee55a3 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-multipleComponents/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-multipleComponents/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: PYCVINTERFACE ATOMS=1,2,4 IMPORT=pydistancegetAt CALCULATE=pydist NOPBC diff --git a/plugins/pycv/regtest/pycvcomm/rt-multipleValuePeriodicity/config b/plugins/pycv/regtest/pycvcomm/rt-multipleValuePeriodicity/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-multipleValuePeriodicity/config +++ b/plugins/pycv/regtest/pycvcomm/rt-multipleValuePeriodicity/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-multipleValuePeriodicity/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-multipleValuePeriodicity/plumed.dat index 5250932b26..5e41a1ab40 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-multipleValuePeriodicity/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-multipleValuePeriodicity/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvcomm/rt-multiplecalls/config b/plugins/pycv/regtest/pycvcomm/rt-multiplecalls/config index 82e4472874..dca9b502ca 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-multiplecalls/config +++ b/plugins/pycv/regtest/pycvcomm/rt-multiplecalls/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz --dump-forces forces --dump-forces-fmt=%10.6f" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-multiplecalls/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-multiplecalls/plumed.dat index 527ea33178..1752024b03 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-multiplecalls/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-multiplecalls/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cv1: PYCVINTERFACE ATOMS=1,3 IMPORT=distcv CALCULATE=cv cv2: PYCVINTERFACE ATOMS=1,4 IMPORT=distcv CALCULATE=cv diff --git a/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtom/config b/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtom/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtom/config +++ b/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtom/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtom/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtom/plumed.dat index 4c7b6b9735..a31f126c5f 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtom/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtom/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cv1: PYCVINTERFACE ATOMS=@mdatoms IMPORT=pycvPerFrame CALCULATE=pydist PREPARE=changeAtom diff --git a/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtomSTR/config b/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtomSTR/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtomSTR/config +++ b/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtomSTR/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtomSTR/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtomSTR/plumed.dat index 4c7b6b9735..a31f126c5f 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtomSTR/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-newFrameNewAtomSTR/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cv1: PYCVINTERFACE ATOMS=@mdatoms IMPORT=pycvPerFrame CALCULATE=pydist PREPARE=changeAtom diff --git a/plugins/pycv/regtest/pycvcomm/rt-persistentData/config b/plugins/pycv/regtest/pycvcomm/rt-persistentData/config index 66a5c0dad7..a0ec704a92 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-persistentData/config +++ b/plugins/pycv/regtest/pycvcomm/rt-persistentData/config @@ -4,5 +4,31 @@ arg="--plumed plumed.dat --ixyz traj.xyz" #this will showcase that you can import a complex module!!! plumed_regtest_before(){ - cp -r ../pycvPersistentData . + cp -r ../pycvPersistentData . + + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 } diff --git a/plugins/pycv/regtest/pycvcomm/rt-persistentData/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-persistentData/plumed.dat index b5ebc5d1a4..dbbb42b33d 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-persistentData/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-persistentData/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cv1: PYCVINTERFACE ATOMS=@mdatoms IMPORT=pycvPersistentData CALCULATE=pydist INIT=pyinit diff --git a/plugins/pycv/regtest/pycvcomm/rt-valuePeriodicity/config b/plugins/pycv/regtest/pycvcomm/rt-valuePeriodicity/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-valuePeriodicity/config +++ b/plugins/pycv/regtest/pycvcomm/rt-valuePeriodicity/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvcomm/rt-valuePeriodicity/plumed.dat b/plugins/pycv/regtest/pycvcomm/rt-valuePeriodicity/plumed.dat index 52ea575ec2..c4ea179df8 100644 --- a/plugins/pycv/regtest/pycvcomm/rt-valuePeriodicity/plumed.dat +++ b/plugins/pycv/regtest/pycvcomm/rt-valuePeriodicity/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/regtest/pycvfunc/rt-ArgsMethods/config b/plugins/pycv/regtest/pycvfunc/rt-ArgsMethods/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-ArgsMethods/config +++ b/plugins/pycv/regtest/pycvfunc/rt-ArgsMethods/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvfunc/rt-ArgsMethods/plumed.dat b/plugins/pycv/regtest/pycvfunc/rt-ArgsMethods/plumed.dat index 658124827e..3a6dda360f 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-ArgsMethods/plumed.dat +++ b/plugins/pycv/regtest/pycvfunc/rt-ArgsMethods/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ d12c: DISTANCE ATOMS=1,2 COMPONENTS diff --git a/plugins/pycv/regtest/pycvfunc/rt-Components/config b/plugins/pycv/regtest/pycvfunc/rt-Components/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-Components/config +++ b/plugins/pycv/regtest/pycvfunc/rt-Components/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvfunc/rt-Components/plumed.dat b/plugins/pycv/regtest/pycvfunc/rt-Components/plumed.dat index bb48f0c8f4..9521aa747d 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-Components/plumed.dat +++ b/plugins/pycv/regtest/pycvfunc/rt-Components/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ dc: DISTANCE ATOMS=1,2 COMPONENTS diff --git a/plugins/pycv/regtest/pycvfunc/rt-MDinformations/config b/plugins/pycv/regtest/pycvfunc/rt-MDinformations/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-MDinformations/config +++ b/plugins/pycv/regtest/pycvfunc/rt-MDinformations/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvfunc/rt-MDinformations/plumed.dat b/plugins/pycv/regtest/pycvfunc/rt-MDinformations/plumed.dat index b75648d8e9..163660f533 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-MDinformations/plumed.dat +++ b/plugins/pycv/regtest/pycvfunc/rt-MDinformations/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ fPY: ... PYFUNCTION diff --git a/plugins/pycv/regtest/pycvfunc/rt-arguments/config b/plugins/pycv/regtest/pycvfunc/rt-arguments/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-arguments/config +++ b/plugins/pycv/regtest/pycvfunc/rt-arguments/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvfunc/rt-arguments/plumed.dat b/plugins/pycv/regtest/pycvfunc/rt-arguments/plumed.dat index ced0f2f8df..9bcea812e5 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-arguments/plumed.dat +++ b/plugins/pycv/regtest/pycvfunc/rt-arguments/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ d1: DISTANCE ATOMS=1,2 d2: DISTANCE ATOMS=1,3 diff --git a/plugins/pycv/regtest/pycvfunc/rt-argumentsArray/config b/plugins/pycv/regtest/pycvfunc/rt-argumentsArray/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-argumentsArray/config +++ b/plugins/pycv/regtest/pycvfunc/rt-argumentsArray/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvfunc/rt-argumentsArray/plumed.dat b/plugins/pycv/regtest/pycvfunc/rt-argumentsArray/plumed.dat index 84460382e5..e4fb18fbd6 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-argumentsArray/plumed.dat +++ b/plugins/pycv/regtest/pycvfunc/rt-argumentsArray/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ dc: DISTANCE ATOMS=1,2 COMPONENTS d: DISTANCE ATOMS=1,2 diff --git a/plugins/pycv/regtest/pycvfunc/rt-argumentsWithComponents/config b/plugins/pycv/regtest/pycvfunc/rt-argumentsWithComponents/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-argumentsWithComponents/config +++ b/plugins/pycv/regtest/pycvfunc/rt-argumentsWithComponents/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvfunc/rt-argumentsWithComponents/plumed.dat b/plugins/pycv/regtest/pycvfunc/rt-argumentsWithComponents/plumed.dat index 84460382e5..e4fb18fbd6 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-argumentsWithComponents/plumed.dat +++ b/plugins/pycv/regtest/pycvfunc/rt-argumentsWithComponents/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ dc: DISTANCE ATOMS=1,2 COMPONENTS d: DISTANCE ATOMS=1,2 diff --git a/plugins/pycv/regtest/pycvfunc/rt-derivative/config b/plugins/pycv/regtest/pycvfunc/rt-derivative/config index 7e13a932fd..a9b93b35ca 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-derivative/config +++ b/plugins/pycv/regtest/pycvfunc/rt-derivative/config @@ -9,3 +9,31 @@ plumed_regtest_after() { awk 'function abs(v) {return v < 0 ? -v : v} NR>1{print $1, $2, 0.0001 < abs($3-$4) } ' deriv_delta } + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvfunc/rt-derivative/plumed.dat b/plugins/pycv/regtest/pycvfunc/rt-derivative/plumed.dat index 519df8b70c..4a1d9d609b 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-derivative/plumed.dat +++ b/plugins/pycv/regtest/pycvfunc/rt-derivative/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ d1: DISTANCE ATOMS=1,2 d2: DISTANCE ATOMS=1,3 diff --git a/plugins/pycv/regtest/pycvfunc/rt-derivative/unitTest.py b/plugins/pycv/regtest/pycvfunc/rt-derivative/unitTest.py index a0c386bfe1..a1ffa9d34c 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-derivative/unitTest.py +++ b/plugins/pycv/regtest/pycvfunc/rt-derivative/unitTest.py @@ -5,7 +5,7 @@ print("Imported my pydist+.", file=log) -initForF={"Value": PLMD.defaults.COMPONENT} +def initForF(_: PLMD.PythonFunction): return {"Value": PLMD.defaults.COMPONENT} def function(action: PLMD.PythonFunction): arg = [action.argument(0), diff --git a/plugins/pycv/regtest/pycvfunc/rt-doc/config b/plugins/pycv/regtest/pycvfunc/rt-doc/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-doc/config +++ b/plugins/pycv/regtest/pycvfunc/rt-doc/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvfunc/rt-doc/config.reference b/plugins/pycv/regtest/pycvfunc/rt-doc/config.reference index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-doc/config.reference +++ b/plugins/pycv/regtest/pycvfunc/rt-doc/config.reference @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvfunc/rt-doc/plumed.dat b/plugins/pycv/regtest/pycvfunc/rt-doc/plumed.dat index f9618b43cf..05d656eacf 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-doc/plumed.dat +++ b/plugins/pycv/regtest/pycvfunc/rt-doc/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvdist: PYFUNCTION IMPORT=pyhelp diff --git a/plugins/pycv/regtest/pycvfunc/rt-withPYCV/config b/plugins/pycv/regtest/pycvfunc/rt-withPYCV/config index 010fed6f0a..bca39af1e7 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-withPYCV/config +++ b/plugins/pycv/regtest/pycvfunc/rt-withPYCV/config @@ -1,3 +1,31 @@ type=driver arg="--plumed plumed.dat --ixyz traj.xyz" + +plumed_regtest_before() { + if [[ -z $PLUMED_PYTHON_BIN ]]; then + PLUMED_PYTHON_BIN=python + fi + pycvpath=$($PLUMED_PYTHON_BIN -m pycv) + sed -i "s%@pycvpath@%${pycvpath}%g" plumed.dat +} + +plumed_custom_skip() { + if test -n "$PLUMED_PYTHON_SELECT"; then + export PLUMED_PYTHON_BIN="$PLUMED_PYTHON_SELECT" + if $PLUMED_PYTHON_BIN -c "import pycv"; then + return 1 + fi + + return 0 + fi + for python_bin in python python3 python3.12 python3.11 python3.10 python3.9 python3.8 python3.7; do + if $python_bin -c "import pycv" 2>/dev/null; then + if [ $python_bin != python ]; then + export PLUMED_PYTHON_BIN=$python_bin + fi + return 1 + fi + done + return 0 +} diff --git a/plugins/pycv/regtest/pycvfunc/rt-withPYCV/plumed.dat b/plugins/pycv/regtest/pycvfunc/rt-withPYCV/plumed.dat index a749a417cb..8d344a4078 100644 --- a/plugins/pycv/regtest/pycvfunc/rt-withPYCV/plumed.dat +++ b/plugins/pycv/regtest/pycvfunc/rt-withPYCV/plumed.dat @@ -1,4 +1,4 @@ -LOAD FILE=../../../../PythonCVInterface.so +LOAD FILE=@pycvpath@ cvPY: ... PYCVINTERFACE diff --git a/plugins/pycv/ActionWithPython.cpp b/plugins/pycv/src/ActionWithPython.cpp similarity index 98% rename from plugins/pycv/ActionWithPython.cpp rename to plugins/pycv/src/ActionWithPython.cpp index 6886dc1123..49bf3434f0 100644 --- a/plugins/pycv/ActionWithPython.cpp +++ b/plugins/pycv/src/ActionWithPython.cpp @@ -17,8 +17,8 @@ along with plumed. If not, see . #include "ActionWithPython.h" -#include "core/ActionWithValue.h" -#include "tools/DLLoader.h" +#include "plumed/core/ActionWithValue.h" +#include "plumed/tools/DLLoader.h" #include // everything needed for embedding #include diff --git a/plugins/pycv/ActionWithPython.h b/plugins/pycv/src/ActionWithPython.h similarity index 99% rename from plugins/pycv/ActionWithPython.h rename to plugins/pycv/src/ActionWithPython.h index a941eb4bae..81ea0fccb1 100644 --- a/plugins/pycv/ActionWithPython.h +++ b/plugins/pycv/src/ActionWithPython.h @@ -20,7 +20,7 @@ along with plumed. If not, see . #include #include -#include "core/Action.h" +#include "plumed/core/Action.h" #include // everything needed for embedding diff --git a/plugins/pycv/PlumedPythonEmbeddedModule.cpp b/plugins/pycv/src/PlumedPythonEmbeddedModule.cpp similarity index 99% rename from plugins/pycv/PlumedPythonEmbeddedModule.cpp rename to plugins/pycv/src/PlumedPythonEmbeddedModule.cpp index 60ed89aca9..f991e49f75 100644 --- a/plugins/pycv/PlumedPythonEmbeddedModule.cpp +++ b/plugins/pycv/src/PlumedPythonEmbeddedModule.cpp @@ -21,8 +21,8 @@ along with plumed. If not, see . #include #include -#include "tools/Vector.h" -#include "tools/NeighborList.h" +#include "plumed/tools/Vector.h" +#include "plumed/tools/NeighborList.h" #include "PythonCVInterface.h" #include "PythonFunction.h" @@ -35,7 +35,7 @@ namespace py=pybind11; //NB: the action methods are written two times due to the diamond inheritance -PYBIND11_EMBEDDED_MODULE(plumedCommunications, m) { +PYBIND11_MODULE(plumedCommunications, m) { /*******************************default submodule****************************/ py::module_ defaults = m.def_submodule("defaults", "Submodule with the default definitions"); defaults.attr("COMPONENT") = py::dict(py::arg("period")=py::none(),py::arg("derivative")=true); diff --git a/plugins/pycv/PythonCVInterface.cpp b/plugins/pycv/src/PythonCVInterface.cpp similarity index 99% rename from plugins/pycv/PythonCVInterface.cpp rename to plugins/pycv/src/PythonCVInterface.cpp index 374c370ea1..4632abf8c6 100644 --- a/plugins/pycv/PythonCVInterface.cpp +++ b/plugins/pycv/src/PythonCVInterface.cpp @@ -16,10 +16,10 @@ along with plumed. If not, see . +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ #include "PythonCVInterface.h" -#include "core/ActionRegister.h" -#include "core/PlumedMain.h" -#include "tools/NeighborList.h" -#include "tools/Pbc.h" +#include "plumed/core/ActionRegister.h" +#include "plumed/core/PlumedMain.h" +#include "plumed/tools/NeighborList.h" +#include "plumed/tools/Pbc.h" #include // everything needed for embedding #include @@ -422,6 +422,7 @@ PythonCVInterface::PythonCVInterface(const ActionOptions&ao) ://the catch only a PLUMED_COLVAR_INIT(ao), ActionWithPython(ao) { try { + py::gil_scoped_acquire gil; //Loading the python module std::string import; parse("IMPORT",import); @@ -612,6 +613,7 @@ void PythonCVInterface::prepare() { } } if (hasPrepare) { + py::gil_scoped_acquire gil; py::dict prepareDict = pyPrepare(this); if (prepareDict.contains("setAtomRequest")) { //should I use "interpretAtomList"? @@ -641,6 +643,7 @@ void PythonCVInterface::prepare() { void PythonCVInterface::update() { try { if(hasUpdate) { + py::gil_scoped_acquire gil; py::dict updateDict=pyUpdate(this); //See what to do here } @@ -657,6 +660,7 @@ void PythonCVInterface::calculate() { nl->update(getPositions()); } } + py::gil_scoped_acquire gil; // Call the function py::object r = pyCalculate(this); if(getNumberOfComponents()>1) { // MULTIPLE NAMED COMPONENTS diff --git a/plugins/pycv/PythonCVInterface.h b/plugins/pycv/src/PythonCVInterface.h similarity index 98% rename from plugins/pycv/PythonCVInterface.h rename to plugins/pycv/src/PythonCVInterface.h index b5971029c1..23bd60f69f 100644 --- a/plugins/pycv/PythonCVInterface.h +++ b/plugins/pycv/src/PythonCVInterface.h @@ -18,7 +18,7 @@ along with plumed. If not, see . #define __PLUMED_pycv_PythonCVInterface_h #include "ActionWithPython.h" -#include "colvar/Colvar.h" +#include "plumed/colvar/Colvar.h" namespace PLMD { diff --git a/plugins/pycv/PythonFunction.cpp b/plugins/pycv/src/PythonFunction.cpp similarity index 98% rename from plugins/pycv/PythonFunction.cpp rename to plugins/pycv/src/PythonFunction.cpp index a0aa837f3f..633c04f3a8 100644 --- a/plugins/pycv/PythonFunction.cpp +++ b/plugins/pycv/src/PythonFunction.cpp @@ -16,8 +16,8 @@ along with plumed. If not, see . +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ #include "PythonFunction.h" -#include "core/ActionRegister.h" -#include "core/PlumedMain.h" // cite +#include "plumed/core/ActionRegister.h" +#include "plumed/core/PlumedMain.h" // cite #include // everything needed for embedding #include @@ -120,6 +120,7 @@ PythonFunction::PythonFunction(const ActionOptions&ao): Function(ao), ActionWithPython(ao) { try { + py::gil_scoped_acquire gil; //Loading the python module std::string import; parse("IMPORT",import); @@ -205,6 +206,7 @@ PythonFunction::PythonFunction(const ActionOptions&ao): // calculator void PythonFunction::calculate() { try { + py::gil_scoped_acquire gil; // Call the function py::object r = pyCalculate(this); if(getNumberOfComponents()>1) { // MULTIPLE NAMED COMPONENTS diff --git a/plugins/pycv/PythonFunction.h b/plugins/pycv/src/PythonFunction.h similarity index 97% rename from plugins/pycv/PythonFunction.h rename to plugins/pycv/src/PythonFunction.h index 1f1059b46d..aa55aaf766 100644 --- a/plugins/pycv/PythonFunction.h +++ b/plugins/pycv/src/PythonFunction.h @@ -17,7 +17,7 @@ along with plumed. If not, see . #ifndef __PLUMED_pycv_PythonFunction_h #define __PLUMED_pycv_PythonFunction_h #include "ActionWithPython.h" -#include "function/Function.h" +#include "plumed/function/Function.h" #include namespace PLMD { diff --git a/plugins/pycv/src/pycv/__init__.py b/plugins/pycv/src/pycv/__init__.py new file mode 100644 index 0000000000..7cae10a7dd --- /dev/null +++ b/plugins/pycv/src/pycv/__init__.py @@ -0,0 +1,46 @@ +# checked and formatted with ruff 0.6.9 + + +def getPythonCVInterface(): + """returns the location of the pycv shared object""" + # older version + # import inspect + # import pycv + + # path_of_this = inspect.getfile(pycv) + import importlib.util + + path_of_this = importlib.util.find_spec("pycv").origin + path_of_lib = path_of_this[: path_of_this.rfind("/")] + return path_of_lib + "/PythonCVInterface.so" + + +def main(): + from argparse import ArgumentParser + + parser = ArgumentParser( + prog="pyCV", + description="""shows the path for the pycv shared object. + + Just run this with no arguments to see the path. + """, + ) + parser.add_argument( + "-p", + "--plumed", + help="print on screen an example plumed.dat", + action="store_true", + ) + args = parser.parse_args() + + if args.plumed: + print( + f"""LOAD FILE={getPythonCVInterface()} +cvPy:PYCVINTERFACE IMPORT=mypycv +fPy: PYFUNCTION IMPORT=mypycvfunc ARG=cvPy +PRINT FILE=colvar.out ARG=*""" + ) + return 0 + + print(getPythonCVInterface()) + return 0 diff --git a/plugins/pycv/src/pycv/__main__.py b/plugins/pycv/src/pycv/__main__.py new file mode 100644 index 0000000000..770c223002 --- /dev/null +++ b/plugins/pycv/src/pycv/__main__.py @@ -0,0 +1,6 @@ +if __name__ == "__main__": + import sys + + from . import main + + sys.exit(main()) diff --git a/plugins/pycv/standaloneCompile.sh b/plugins/pycv/standaloneCompile.sh deleted file mode 100755 index e5ce28ec29..0000000000 --- a/plugins/pycv/standaloneCompile.sh +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/env bash - -#formatted with shfmt https://github.com/mvdan/sh/releases -#checked with shellcheck -# the SC2154 warnings are variables present in the sourced file - -source compileConfiguration.sh - - -export PLUMED_MKLIB_CFLAGS="${python_cf_embedded} ${pybind11_cflags}" -export PLUMED_MKLIB_LDFLAGS="${PYCV_EXTRA_LDFLAGS} ${python_ld_embedded} ${conda_fixup}" - -echo "PLUMED_MKLIB_CFLAGS=$PLUMED_MKLIB_CFLAGS" -echo "PLUMED_MKLIB_LDFLAGS=$PLUMED_MKLIB_LDFLAGS" - -${plumed_program_name} mklib PythonCVInterface.cpp ActionWithPython.cpp PythonFunction.cpp PlumedPythonEmbeddedModule.cpp