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])
17
# Check for a version of Python >= 2.1.0
19
AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
20
ac_supports_python_ver=`$PYTHON -c "import sys, string; \
21
ver = string.split(sys.version)[[0]]; \
22
print ver >= '2.1.0'"`
23
if test "$ac_supports_python_ver" != "True"; then
24
if test -z "$PYTHON_NOVERSIONCHECK"; then
27
This version of the AC@&t@_PYTHON_DEVEL macro
28
doesn't work properly with versions of Python before
29
2.1.0. You may need to re-run configure, setting the
30
variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
31
PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
32
Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
33
to something else than an empty string.
36
AC_MSG_RESULT([skip at user request])
43
# if the macro parameter ``version'' is set, honour it
46
AC_MSG_CHECKING([for a version of Python $1])
47
ac_supports_python_ver=`$PYTHON -c "import sys, string; \
48
ver = string.split(sys.version)[[0]]; \
50
if test "$ac_supports_python_ver" = "True"; then
54
AC_MSG_ERROR([this package requires Python $1.
55
If you have it installed, but it isn't the default Python
56
interpreter in your system path, please pass the PYTHON_VERSION
57
variable to configure. See ``configure --help'' for reference.
64
# Check if you have distutils, else fail
66
AC_MSG_CHECKING([for the distutils Python package])
67
ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
68
if test -z "$ac_distutils_result"; then
72
AC_MSG_ERROR([cannot import Python module "distutils".
73
Please check your Python installation. The error was:
74
$ac_distutils_result])
79
# Check for Python include path
81
AC_MSG_CHECKING([for Python include path])
82
if test -z "$PYTHON_CPPFLAGS"; then
83
python_path=`$PYTHON -c "import distutils.sysconfig; \
84
print distutils.sysconfig.get_python_inc();"`
85
if test -n "${python_path}"; then
86
python_path="-I$python_path"
88
PYTHON_CPPFLAGS=$python_path
90
AC_MSG_RESULT([$PYTHON_CPPFLAGS])
91
AC_SUBST([PYTHON_CPPFLAGS])
94
# Check for Python library path
96
AC_MSG_CHECKING([for Python library path])
97
if test -z "$PYTHON_LDFLAGS"; then
98
# (makes two attempts to ensure we've got a version number
99
# from the interpreter)
100
py_version=`$PYTHON -c "from distutils.sysconfig import *; \
101
from string import join; \
102
print join(get_config_vars('VERSION'))"`
103
if test "$py_version" == "[None]"; then
104
if test -n "$PYTHON_VERSION"; then
105
py_version=$PYTHON_VERSION
107
py_version=`$PYTHON -c "import sys; \
108
print sys.version[[:3]]"`
112
PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
113
from string import join; \
114
print '-L' + get_python_lib(0,1), \
115
'-lpython';"`$py_version
117
AC_MSG_RESULT([$PYTHON_LDFLAGS])
118
AC_SUBST([PYTHON_LDFLAGS])
121
# Check for site packages
123
AC_MSG_CHECKING([for Python site-packages path])
124
if test -z "$PYTHON_SITE_PKG"; then
125
PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
126
print distutils.sysconfig.get_python_lib(0,0);"`
128
AC_MSG_RESULT([$PYTHON_SITE_PKG])
129
AC_SUBST([PYTHON_SITE_PKG])
132
# libraries which must be linked in when embedding
134
AC_MSG_CHECKING(python extra libraries)
135
if test -z "$PYTHON_EXTRA_LIBS"; then
136
PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
137
conf = distutils.sysconfig.get_config_var; \
138
print conf('LOCALMODLIBS'), conf('LIBS')"`
140
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
141
AC_SUBST(PYTHON_EXTRA_LIBS)
144
# linking flags needed when embedding
146
AC_MSG_CHECKING(python extra linking flags)
147
if test -z "$PYTHON_EXTRA_LDFLAGS"; then
148
PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
149
conf = distutils.sysconfig.get_config_var; \
150
print conf('LINKFORSHARED')"`
152
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
153
AC_SUBST(PYTHON_EXTRA_LDFLAGS)
156
# final check to see if everything compiles alright
158
AC_MSG_CHECKING([consistency of all components of python development environment])
160
# save current global flags
161
LIBS="$ac_save_LIBS $PYTHON_LDFLAGS"
162
CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
167
],[pythonexists=yes],[pythonexists=no])
169
AC_MSG_RESULT([$pythonexists])
171
if test ! "$pythonexists" = "yes"; then
173
Could not link test program to Python. Maybe the main Python library has been
174
installed in some non-standard library path. If so, pass it to configure,
175
via the LDFLAGS environment variable.
176
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
177
============================================================================
179
You probably have to install the development version of the Python package
180
for your distribution. The exact name of this package varies among them.
181
============================================================================
186
# turn back to default flags
187
CPPFLAGS="$ac_save_CPPFLAGS"