1 AC_DEFUN([AC_PYTHON_DEVEL],[
3 # Allow the use of a (user set) custom python version
5 AC_ARG_VAR([PYTHON_VERSION],[The installed Python
6 version to use, for example '2.3'. This string
7 will be appended to the Python interpreter
10 AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
11 if test -z "$PYTHON"; then
12 AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path])
16 if test -z "$PYTHON_VERSION"; then
17 PYTHON_VERSION=`$PYTHON -c "import sys; \
18 print(sys.version.split()[[0]])"`
22 # Check if you have distutils, else fail
24 AC_MSG_CHECKING([for the distutils Python package])
25 if ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`; then
29 AC_MSG_ERROR([cannot import Python module "distutils".
30 Please check your Python installation. The error was:
31 $ac_distutils_result])
36 # Check for Python include path
38 AC_MSG_CHECKING([for Python include path])
39 if test -z "$PYTHON_CPPFLAGS"; then
40 python_path=`$PYTHON -c "import distutils.sysconfig; \
41 print(distutils.sysconfig.get_python_inc());"`
42 if test -n "${python_path}"; then
43 python_path="-I$python_path"
45 PYTHON_CPPFLAGS=$python_path
47 AC_MSG_RESULT([$PYTHON_CPPFLAGS])
48 AC_SUBST([PYTHON_CPPFLAGS])
51 # Check for Python library path
53 AC_MSG_CHECKING([for Python library path])
54 if test -z "$PYTHON_LDFLAGS"; then
55 PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
56 print('-L'+get_config_var('LIBDIR')+' -L'+get_config_var('LIBDEST')+' '+get_config_var('BLDLIBRARY'));"`
58 AC_MSG_RESULT([$PYTHON_LDFLAGS])
59 AC_SUBST([PYTHON_LDFLAGS])
62 # Check for site packages
64 AC_MSG_CHECKING([for Python site-packages path])
65 if test -z "$PYTHON_SITE_PKG"; then
66 PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
67 print(distutils.sysconfig.get_python_lib(1,0));"`
69 AC_MSG_RESULT([$PYTHON_SITE_PKG])
70 AC_SUBST([PYTHON_SITE_PKG])
73 # final check to see if everything compiles alright
75 AC_MSG_CHECKING([consistency of all components of python development environment])
77 # save current global flags
79 ac_save_CPPFLAGS="$CPPFLAGS"
81 LIBS="$LIBS $PYTHON_LDFLAGS"
82 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
87 ],[pythonexists=yes],[pythonexists=no])
89 AC_MSG_RESULT([$pythonexists])
91 if test ! "$pythonexists" = "yes"; then
93 Could not link test program to Python. Maybe the main Python library has been
94 installed in some non-standard library path. If so, pass it to configure,
95 via the LDFLAGS environment variable.
96 Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
97 ============================================================================
99 You probably have to install the development version of the Python package
100 for your distribution. The exact name of this package varies among them.
101 ============================================================================
106 # turn back to default flags
107 CPPFLAGS="$ac_save_CPPFLAGS"