From: Anirudha Bose Date: Wed, 25 May 2016 19:44:47 +0000 (+0530) Subject: Allow specifying Python version during configure X-Git-Tag: ses5-milestone5~486^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c1d0f5491da339b56d41b26056537267244f8608;p=ceph.git Allow specifying Python version during configure * Uses the PYTHON environment variable allowed by configure scripts * Supports running inside Python virtual environments, in which case, setting the PYTHON variable is not required. * Example: $ PYTHON=python3.5 ./configure Signed-off-by: Anirudha Bose --- diff --git a/configure.ac b/configure.ac index b6453b18739..0493673af36 100644 --- a/configure.ac +++ b/configure.ac @@ -221,13 +221,27 @@ if test x"$with_cython" = xyes; then if test x"$CYTHON_CHECK" != xyes; then AC_MSG_FAILURE([cython not found]) fi - AC_CHECK_PROG(PYTHON_CONFIG_CHECK, python-config, yes) + + # Check if we are running inside a Python virtual environment + # Both `virtualenv' as well as PEP 405 `pyvenv' set the VIRTUAL_ENV + # environment variable upon activation + if test x"$VIRTUAL_ENV" != x; then + PYTHON="python" + fi + + # Set PYTHON to default system Python version if not specified + if test x"$PYTHON" = x; then + PYTHON="python" + fi + + AC_CHECK_PROG(PYTHON_CONFIG_CHECK, "$PYTHON"-config, yes) if test x"$PYTHON_CONFIG_CHECK" != xyes; then - AC_MSG_FAILURE([python-config not found]) + AC_MSG_FAILURE(["$PYTHON"-config not found]) fi - PYTHON_CFLAGS=`python-config --cflags` + + PYTHON_CFLAGS=`"$PYTHON"-config --cflags` AC_SUBST(PYTHON_CFLAGS) - PYTHON_LDFLAGS=`python-config --ldflags` + PYTHON_LDFLAGS=`"$PYTHON"-config --ldflags` AC_SUBST(PYTHON_LDFLAGS) fi