--- a/m4/python.m4 2011-06-13 20:30:25.000000000 +0400 +++ b/m4/python.m4 2014-02-01 11:34:44.000000000 +0400 @@ -43,16 +43,14 @@ [AC_REQUIRE([AM_PATH_PYTHON]) AC_MSG_CHECKING(for headers required to compile python extensions) dnl deduce PYTHON_INCLUDES -py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"` -py_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"` -PYTHON_CONFIG=`which $PYTHON`-config -if test -x "$PYTHON_CONFIG"; then -PYTHON_INCLUDES=`$PYTHON_CONFIG --includes 2>/dev/null` -else -PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" -if test "$py_prefix" != "$py_exec_prefix"; then - PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" -fi +if test "x$PYTHON_INCLUDES" = x; then + PYTHON_CONFIG=`which $PYTHON`-config + if test -x "$PYTHON_CONFIG"; then + PYTHON_INCLUDES=`$PYTHON_CONFIG --includes 2>/dev/null` + else + PYTHON_INCLUDES=`$PYTHON -c "import distutils.sysconfig, sys; sys.stdout.write(distutils.sysconfig.get_python_inc(True))"` + PYTHON_INCLUDES="-I$PYTHON_INCLUDES" + fi fi AC_SUBST(PYTHON_INCLUDES) dnl check if the headers exist: @@ -66,24 +64,35 @@ CPPFLAGS="$save_CPPFLAGS" ]) -# JD_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) -# --------------------------------------------------------------------------- -# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. -# Run ACTION-IF-FALSE otherwise. -# This test uses sys.hexversion instead of the string equivalent. -# This is similar to AM_PYTHON_CHECK_VERSION, but without python 1.5.x support -# and with python 3.0 support. -AC_DEFUN([JD_PYTHON_CHECK_VERSION], - [prog="import sys -# split strings by '.' and convert to numeric. Append some zeros -# because we need at least 4 digits for the hex conversion. -# map returns an iterator in Python 3.0 and a list in 2.x -minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]] -minverhex = 0 -# xrange is not present in Python 3.0 and range returns an iterator -for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]] -sys.exit(sys.hexversion < minverhex)" - AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) +dnl a macro to check for ability to embed python +dnl AM_CHECK_PYTHON_LIBS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) +dnl function also defines PYTHON_LIBS +AC_DEFUN([AM_CHECK_PYTHON_LIBS], +[AC_REQUIRE([AM_PATH_PYTHON]) +AC_MSG_CHECKING(for libraries required to embed python) +dnl deduce PYTHON_LIBS +py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"` +if test "x$PYTHON_LIBS" = x; then + PYTHON_CONFIG=`which $PYTHON`-config + if test -x "$PYTHON_CONFIG"; then + PYTHON_LIBS=`$PYTHON_CONFIG --ldflags 2>/dev/null` + else + PYTHON_LIBS="-L${py_prefix}/lib -lpython${PYTHON_VERSION}" + fi +fi +if test "x$PYTHON_LIB_LOC" = x; then + PYTHON_LIB_LOC="${py_prefix}/lib" +fi +AC_SUBST(PYTHON_LIBS) +AC_SUBST(PYTHON_LIB_LOC) +dnl check if the headers exist: +save_LIBS="$LIBS" +LIBS="$LIBS $PYTHON_LIBS" +AC_TRY_LINK_FUNC(Py_Initialize, dnl + [LIBS="$save_LIBS"; AC_MSG_RESULT(yes); $1], dnl + [LIBS="$save_LIBS"; AC_MSG_RESULT(no); $2]) + +]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. @@ -119,8 +123,7 @@ dnl Find a Python interpreter. Python versions prior to 2.0 are not dnl supported m4_define_default([_AM_PYTHON_INTERPRETER_LIST], - [python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 dnl -python2.1 python2.0]) + [python3 python3.3 python3.2 python3.1 python2 python2.7 python]) m4_if([$1],[],[ dnl No version check is needed. @@ -134,7 +137,7 @@ if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. AC_MSG_CHECKING([whether $PYTHON version >= $1]) - JD_PYTHON_CHECK_VERSION([$PYTHON], [$1], + AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], [AC_MSG_RESULT(yes)], [AC_MSG_ERROR(too old)]) am_display_PYTHON=$PYTHON @@ -145,7 +148,7 @@ [am_cv_pathless_PYTHON],[ for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do test "$am_cv_pathless_PYTHON" = none && break - JD_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) + AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) done]) # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. if test "$am_cv_pathless_PYTHON" = none; then --- a/configure.ac.orig 2014-02-23 10:45:36.212800000 +0400 +++ b/configure.ac 2014-02-23 10:47:01.700800000 +0400 @@ -89,36 +89,28 @@ JD_PATH_PYTHON(python_min_ver) # check if we are building for python 3 -JD_PYTHON_CHECK_VERSION([$PYTHON], [3.0], +AM_PYTHON_CHECK_VERSION([$PYTHON], [3.0], build_py3k=true, build_py3k=false) # if building for python 3 make sure we have the minimum version supported if test $build_py3k = true ; then AC_MSG_CHECKING([for $PYTHON >=] python3_min_ver) - JD_PYTHON_CHECK_VERSION([$PYTHON], python3_min_ver, + AM_PYTHON_CHECK_VERSION([$PYTHON], python3_min_ver, [AC_MSG_RESULT(yes)], [AC_MSG_ERROR(too old)]) fi -AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)]) - -AC_MSG_CHECKING([for PySignal_SetWakeupFd in Python.h]) -old_CPPFLAGS=$CPPFLAGS -CPPFLAGS="-Wall -Werror $PYTHON_INCLUDES" -AC_TRY_COMPILE([#include ], - [PySignal_SetWakeupFd(0);], - setwakeupfd_ok=yes, - setwakeupfd_ok=no) -AC_MSG_RESULT($setwakeupfd_ok) -if test "x$setwakeupfd_ok" != xno; then - AC_DEFINE(HAVE_PYSIGNAL_SETWAKEUPFD, 1, - [Define to 1 if PySignal_SetWakeupFd is available]) +# - 'SO' for PyPy, CPython 2.7-3.2 +# - 'EXT_SUFFIX' for CPython3.3+ (http://bugs.python.org/issue16754) +# - fallback to '.so' +PYTHON_SO=`$PYTHON -c "import distutils.sysconfig, sys; get = distutils.sysconfig.get_config_var; sys.stdout.write(get('EXT_SUFFIX') or get('SO') or '.so');"` +AC_SUBST(PYTHON_SO) + +AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found])) +if test "x$os_win32" = "xyes"; then + AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found. Windows requires Python modules to be explicitly linked to libpython.])) fi -CPPFLAGS=$old_CPPFLAGS - -PLATFORM=`$PYTHON -c "import sys; from distutils import util; sys.stdout.write(util.get_platform())"` -AC_SUBST(PLATFORM) AC_ARG_ENABLE(thread, AC_HELP_STRING([--disable-thread], [Disable pygobject threading support]),,