+])
+fi
+
+# Find our python paths
+AC_MSG_CHECKING([for Python version])
+# Need to do this hack since autoconf replaces __file__ with the name of the configure file
+filehack="file__"
+PYVERSION=`($PYTHON -c "import string,operator; print operator.getitem(string.split(string.__$filehack,'/'),-2)")`
+AC_MSG_RESULT([$PYVERSION])
+
+AC_MSG_CHECKING([for Python prefix])
+PYPREFIX=`($PYTHON -c "import sys; print sys.prefix") 2>/dev/null`
+AC_MSG_RESULT([$PYPREFIX])
+AC_MSG_CHECKING([for Python exec-prefix])
+PYEPREFIX=`($PYTHON -c "import sys; print sys.exec_prefix") 2>/dev/null`
+AC_MSG_RESULT([$PYEPREFIX])
+
+# Find the include directory
+AC_MSG_CHECKING([for Python header files])
+if test -r "$PYPREFIX/include/$PYVERSION/Python.h"; then
+ PYTHON_CFLAGS="-I$PYPREFIX/include/$PYVERSION"
+fi
+if test -z "$PYTHON_CFLAGS"; then
+ if test -r "$PYPREFIX/include/Py/Python.h"; then
+ PYTHON_CFLAGS="-I$PYPREFIX/include/Py"
+ fi
+fi
+if ! test "$PYTHON_CFLAGS"; then
+ AC_MSG_ERROR([Not found])
+else
+ AC_MSG_RESULT([$PYTHON_CFLAGS])
+fi
+
+# Set the library directory blindly. This probably won't work with older versions
+AC_MSG_CHECKING([for Python library])
+dirs="$PYVERSION/config $PYVERSION/lib python/lib"
+for i in $dirs; do
+ if test -d "$PYEPREFIX/lib/$i"; then
+ PYLIB="$PYEPREFIX/lib/$i"
+ break
+ fi
+done
+if ! test "$PYLIB"; then
+ AC_MSG_ERROR([Not found])
+else
+ AC_MSG_RESULT([$PYLIB])
+fi
+
+# Check for really old versions
+if test -r "$PYLIB/libPython.a"; then
+ PYTHON_LIBS="-L$PYLIB -lModules -lPython -lObjects -lParser"
+else
+ PYTHON_LIBS="-L$PYLIB -l$PYVERSION"
+fi
+