diff --git a/configure b/configure index 5a6e3fe334..48127ef87e 100755 --- a/configure +++ b/configure @@ -655,6 +655,7 @@ CPPFLAGS LDFLAGS CXXFLAGS CXX +CYTHON_FOUND PYTHON_CFLAGS PYTHON_LDFLAGS PYBIND11_CFLAGS @@ -3251,6 +3252,7 @@ fi + # by default use -O flag # we override the autoconf default (-g) because in release build we do not want to # include symbol information (obj files are huge) @@ -8973,44 +8975,9 @@ $as_echo "$as_me: WARNING: cannot enable __PLUMED_HAS_FFTW" >&2;} fi -if test $pycv = true ; then - if test -n "$PYTHON_BIN" - then - { $as_echo "$as_me:${as_lineno-$LINENO}: Python executable is $PYTHON_BIN" >&5 -$as_echo "$as_me: Python executable is $PYTHON_BIN" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pycv: support for required python modules (python3, pybind11, numpy)" >&5 -$as_echo_n "checking pycv: support for required python modules (python3, pybind11, numpy)... " >&6; } -testimport=" -import numpy -import pybind11 -#no need to check for python3, if you have python2, you don't have pybind11 (and vice-versa) -" - if echo "$testimport" | "$PYTHON_BIN" 1>/dev/null 2>/dev/null; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - pyver=$($PYTHON_BIN -c "import sysconfig;print(sysconfig.get_config_var('VERSION'))") - python_config=python${pyver}-config - PYBIND11_CFLAGS="$($PYTHON_BIN -m pybind11 --includes) -fvisibility=hidden" - PYTHON_CFLAGS=$(${python_config} --cflags --embed) - PYTHON_LDFLAGS=$(${python_config} --ldflags --embed) - #TODO: conda_fixup - PLUMED_CAN_PYCV=yes - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable pycv" >&5 -$as_echo "$as_me: WARNING: cannot enable pycv" >&2;} - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable pycv" >&5 -$as_echo "$as_me: WARNING: cannot enable pycv" >&2;} - fi -fi - -if test $python = true ; then # if PYTHON_BIN is defined, it is expected to be the full path to python # Otherwise, search from a list of names: - if test -z "$PYTHON_BIN" ; then +if test -z "$PYTHON_BIN" ; then for ac_prog in python do # Extract the first word of "$ac_prog", so it can be a program name with args. @@ -9053,14 +9020,43 @@ fi test -n "$PYTHON_BIN" && break done - fi - if test -n "$PYTHON_BIN" - then +fi +if test -n "$PYTHON_BIN" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Python executable is $PYTHON_BIN" >&5 $as_echo "$as_me: Python executable is $PYTHON_BIN" >&6;} + if test $pycv = true ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pycv: support for required python modules (python3, pybind11, numpy)" >&5 +$as_echo_n "checking pycv: support for required python modules (python3, pybind11, numpy)... " >&6; } + testimport=" +import numpy +import pybind11 +#no need to check for python3, if you have python2, you don't have pybind11 (and vice-versa) +" + if echo "$testimport" | "$PYTHON_BIN" 1>/dev/null 2>/dev/null; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + pyver=$($PYTHON_BIN -c "import sysconfig;print(sysconfig.get_config_var('VERSION'))") + python_config=python${pyver}-config + PYBIND11_CFLAGS="$($PYTHON_BIN -m pybind11 --includes) -fvisibility=hidden" + PYTHON_CFLAGS=$(${python_config} --cflags --embed) + PYTHON_LDFLAGS=$(${python_config} --ldflags --embed) + #TODO: conda_fixup + PLUMED_CAN_PYCV=yes + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable pycv" >&5 +$as_echo "$as_me: WARNING: cannot enable pycv" >&2;} + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable pycv" >&5 +$as_echo "$as_me: WARNING: cannot enable pycv" >&2;} + fi + + if test $python = true ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking support for required python modules (python3, setuptools, cython)" >&5 $as_echo_n "checking support for required python modules (python3, setuptools, cython)... " >&6; } -testimport=" + testimport=" from setuptools import setup from setuptools import Extension from Cython.Build import cythonize @@ -9073,12 +9069,12 @@ if sys.version_info < (3,): $as_echo "yes" >&6; } $as_echo "#define __PLUMED_HAS_PYTHON 1" >>confdefs.h + CYTHON_FOUND=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable python interface" >&5 $as_echo "$as_me: WARNING: cannot enable python interface" >&2;} - PYTHON_BIN= fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot enable python interface" >&5 @@ -9086,6 +9082,11 @@ $as_echo "$as_me: WARNING: cannot enable python interface" >&2;} fi fi +if test "${PLUMED_CAN_PYCV}" != yes && test "${CYTHON_FOUND}" != yes; then + #this deactivate python bin if no package was found + PYTHON_BIN= +fi + if test "$af_ocl" = true ; then found=ko diff --git a/configure.ac b/configure.ac index 44dfac3d8e..7c65c52008 100644 --- a/configure.ac +++ b/configure.ac @@ -844,12 +844,16 @@ if test $fftw = true ; then PLUMED_CHECK_PACKAGE([fftw3.h],[fftw_execute],[__PLUMED_HAS_FFTW],[fftw3]) fi -if test $pycv = true ; then - if test -n "$PYTHON_BIN" - then +# if PYTHON_BIN is defined, it is expected to be the full path to python +# Otherwise, search from a list of names: +if test -z "$PYTHON_BIN" ; then + AC_CHECK_PROGS([PYTHON_BIN],[python]) +fi +if test -n "$PYTHON_BIN" ; then AC_MSG_NOTICE([Python executable is $PYTHON_BIN]) + if test $pycv = true ; then AC_MSG_CHECKING([pycv: support for required python modules (python3, pybind11, numpy)]) -testimport=" + testimport=" import numpy import pybind11 #no need to check for python3, if you have python2, you don't have pybind11 (and vice-versa) @@ -870,19 +874,10 @@ import pybind11 else AC_MSG_WARN([cannot enable pycv]) fi -fi -if test $python = true ; then -# if PYTHON_BIN is defined, it is expected to be the full path to python -# Otherwise, search from a list of names: - if test -z "$PYTHON_BIN" ; then - AC_CHECK_PROGS([PYTHON_BIN],[python]) - fi - if test -n "$PYTHON_BIN" - then - AC_MSG_NOTICE([Python executable is $PYTHON_BIN]) + if test $python = true ; then AC_MSG_CHECKING([support for required python modules (python3, setuptools, cython)]) -testimport=" + testimport=" from setuptools import setup from setuptools import Extension from Cython.Build import cythonize @@ -903,6 +898,11 @@ if sys.version_info < (3,): fi fi +if test "${PLUMED_CAN_PYCV}" != yes && test "${CYTHON_FOUND}" != yes; then + #this deactivate python bin if no package was found + PYTHON_BIN= +fi + if test "$af_ocl" = true ; then PLUMED_CHECK_PACKAGE([arrayfire.h],[af_is_double],[__PLUMED_HAS_ARRAYFIRE],[afopencl]) PLUMED_CHECK_PACKAGE([arrayfire.h],[af_is_double],[__PLUMED_HAS_ARRAYFIRE_OCL],[afopencl])