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 ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
26 if test -z "$ac_distutils_result"; then
30 AC_MSG_ERROR([cannot import Python module "distutils".
31 Please check your Python installation. The error was:
32 $ac_distutils_result])
37 # Check for Python include path
39 AC_MSG_CHECKING([for Python include path])
40 if test -z "$PYTHON_CPPFLAGS"; then
41 python_path=`$PYTHON -c "import distutils.sysconfig; \
42 print(distutils.sysconfig.get_python_inc());"`
43 if test -n "${python_path}"; then
44 python_path="-I$python_path"
46 PYTHON_CPPFLAGS=$python_path
48 AC_MSG_RESULT([$PYTHON_CPPFLAGS])
49 AC_SUBST([PYTHON_CPPFLAGS])
52 # Check for Python library path
54 AC_MSG_CHECKING([for Python library path])
55 if test -z "$PYTHON_LDFLAGS"; then
56 PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
57 print(get_config_var('BLDLIBRARY'));"`
59 AC_MSG_RESULT([$PYTHON_LDFLAGS])
60 AC_SUBST([PYTHON_LDFLAGS])
63 # Check for site packages
65 AC_MSG_CHECKING([for Python site-packages path])
66 if test -z "$PYTHON_SITE_PKG"; then
67 PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
68 print(distutils.sysconfig.get_python_lib(1,0));"`
70 AC_MSG_RESULT([$PYTHON_SITE_PKG])
71 AC_SUBST([PYTHON_SITE_PKG])
74 # final check to see if everything compiles alright
76 AC_MSG_CHECKING([consistency of all components of python development environment])
78 # save current global flags
80 ac_save_CPPFLAGS="$CPPFLAGS"
82 LIBS="$LIBS $PYTHON_LDFLAGS"
83 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
88 ],[pythonexists=yes],[pythonexists=no])
90 AC_MSG_RESULT([$pythonexists])
92 if test ! "$pythonexists" = "yes"; then
94 Could not link test program to Python. Maybe the main Python library has been
95 installed in some non-standard library path. If so, pass it to configure,
96 via the LDFLAGS environment variable.
97 Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
98 ============================================================================
100 You probably have to install the development version of the Python package
101 for your distribution. The exact name of this package varies among them.
102 ============================================================================
107 # turn back to default flags
108 CPPFLAGS="$ac_save_CPPFLAGS"