Lines 1-5
Link Here
|
1 |
# =========================================================================== |
1 |
# =========================================================================== |
2 |
# http://www.nongnu.org/autoconf-archive/ax_python_devel.html |
2 |
# http://www.gnu.org/software/autoconf-archive/ax_python_devel.html |
3 |
# =========================================================================== |
3 |
# =========================================================================== |
4 |
# |
4 |
# |
5 |
# SYNOPSIS |
5 |
# SYNOPSIS |
Lines 12-20
Link Here
|
12 |
# in your configure.ac. |
12 |
# in your configure.ac. |
13 |
# |
13 |
# |
14 |
# This macro checks for Python and tries to get the include path to |
14 |
# This macro checks for Python and tries to get the include path to |
15 |
# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) |
15 |
# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LIBS) output |
16 |
# output variables. It also exports $(PYTHON_EXTRA_LIBS) |
16 |
# variables. It also exports $(PYTHON_EXTRA_LIBS) and |
17 |
# for embedding Python in your code. |
17 |
# $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. |
18 |
# |
18 |
# |
19 |
# You can search for some particular version of Python by passing a |
19 |
# You can search for some particular version of Python by passing a |
20 |
# parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please |
20 |
# parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please |
Lines 34-44
Link Here
|
34 |
# LICENSE |
34 |
# LICENSE |
35 |
# |
35 |
# |
36 |
# Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de> |
36 |
# Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de> |
37 |
# Copyright (c) 2009 Alan W. Irwin <irwin@beluga.phys.uvic.ca> |
37 |
# Copyright (c) 2009 Alan W. Irwin |
38 |
# Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net> |
38 |
# Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net> |
39 |
# Copyright (c) 2009 Andrew Collier <colliera@ukzn.ac.za> |
39 |
# Copyright (c) 2009 Andrew Collier |
40 |
# Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org> |
40 |
# Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org> |
41 |
# Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org> |
41 |
# Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org> |
|
|
42 |
# Copyright (c) 2013 Daniel Mullner <muellner@math.stanford.edu> |
42 |
# |
43 |
# |
43 |
# This program is free software: you can redistribute it and/or modify it |
44 |
# This program is free software: you can redistribute it and/or modify it |
44 |
# under the terms of the GNU General Public License as published by the |
45 |
# under the terms of the GNU General Public License as published by the |
Lines 66-71
Link Here
|
66 |
# modified version of the Autoconf Macro, you may extend this special |
67 |
# modified version of the Autoconf Macro, you may extend this special |
67 |
# exception to the GPL to apply to your modified version as well. |
68 |
# exception to the GPL to apply to your modified version as well. |
68 |
|
69 |
|
|
|
70 |
#serial 18 |
71 |
|
69 |
AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) |
72 |
AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) |
70 |
AC_DEFUN([AX_PYTHON_DEVEL],[ |
73 |
AC_DEFUN([AX_PYTHON_DEVEL],[ |
71 |
# |
74 |
# |
Lines 96-103
Link Here
|
96 |
This version of the AC@&t@_PYTHON_DEVEL macro |
99 |
This version of the AC@&t@_PYTHON_DEVEL macro |
97 |
doesn't work properly with versions of Python before |
100 |
doesn't work properly with versions of Python before |
98 |
2.1.0. You may need to re-run configure, setting the |
101 |
2.1.0. You may need to re-run configure, setting the |
99 |
variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, |
102 |
variables PYTHON_CPPFLAGS, PYTHON_LIBS, PYTHON_SITE_PKG, |
100 |
PYTHON_EXTRA_LIBS by hand. |
103 |
PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. |
101 |
Moreover, to disable this check, set PYTHON_NOVERSIONCHECK |
104 |
Moreover, to disable this check, set PYTHON_NOVERSIONCHECK |
102 |
to something else than an empty string. |
105 |
to something else than an empty string. |
103 |
]) |
106 |
]) |
Lines 117-123
Link Here
|
117 |
ver = sys.version.split ()[[0]]; \ |
120 |
ver = sys.version.split ()[[0]]; \ |
118 |
print (ver $1)"` |
121 |
print (ver $1)"` |
119 |
if test "$ac_supports_python_ver" = "True"; then |
122 |
if test "$ac_supports_python_ver" = "True"; then |
120 |
AC_MSG_RESULT([yes]) |
123 |
AC_MSG_RESULT([yes]) |
121 |
else |
124 |
else |
122 |
AC_MSG_RESULT([no]) |
125 |
AC_MSG_RESULT([no]) |
123 |
AC_MSG_ERROR([this package requires Python $1. |
126 |
AC_MSG_ERROR([this package requires Python $1. |
Lines 133-139
Link Here
|
133 |
# Check if you have distutils, else fail |
136 |
# Check if you have distutils, else fail |
134 |
# |
137 |
# |
135 |
AC_MSG_CHECKING([for the distutils Python package]) |
138 |
AC_MSG_CHECKING([for the distutils Python package]) |
136 |
ac_distutils_result=`$PYTHON -c "import distutils" >/dev/null 2>&1` |
139 |
ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` |
137 |
if test -z "$ac_distutils_result"; then |
140 |
if test -z "$ac_distutils_result"; then |
138 |
AC_MSG_RESULT([yes]) |
141 |
AC_MSG_RESULT([yes]) |
139 |
else |
142 |
else |
Lines 150-158
Link Here
|
150 |
AC_MSG_CHECKING([for Python include path]) |
153 |
AC_MSG_CHECKING([for Python include path]) |
151 |
if test -z "$PYTHON_CPPFLAGS"; then |
154 |
if test -z "$PYTHON_CPPFLAGS"; then |
152 |
python_path=`$PYTHON -c "import distutils.sysconfig; \ |
155 |
python_path=`$PYTHON -c "import distutils.sysconfig; \ |
153 |
print (distutils.sysconfig.get_python_inc ());"` |
156 |
print (distutils.sysconfig.get_python_inc ());"` |
|
|
157 |
plat_python_path=`$PYTHON -c "import distutils.sysconfig; \ |
158 |
print (distutils.sysconfig.get_python_inc (plat_specific=1));"` |
154 |
if test -n "${python_path}"; then |
159 |
if test -n "${python_path}"; then |
155 |
python_path="-I$python_path" |
160 |
if test "${plat_python_path}" != "${python_path}"; then |
|
|
161 |
python_path="-I$python_path -I$plat_python_path" |
162 |
else |
163 |
python_path="-I$python_path" |
164 |
fi |
156 |
fi |
165 |
fi |
157 |
PYTHON_CPPFLAGS=$python_path |
166 |
PYTHON_CPPFLAGS=$python_path |
158 |
fi |
167 |
fi |
Lines 163-169
Link Here
|
163 |
# Check for Python library path |
172 |
# Check for Python library path |
164 |
# |
173 |
# |
165 |
AC_MSG_CHECKING([for Python library path]) |
174 |
AC_MSG_CHECKING([for Python library path]) |
166 |
if test -z "$PYTHON_LDFLAGS"; then |
175 |
if test -z "$PYTHON_LIBS"; then |
167 |
# (makes two attempts to ensure we've got a version number |
176 |
# (makes two attempts to ensure we've got a version number |
168 |
# from the interpreter) |
177 |
# from the interpreter) |
169 |
ac_python_version=`cat<<EOD | $PYTHON - |
178 |
ac_python_version=`cat<<EOD | $PYTHON - |
Lines 171-181
Link Here
|
171 |
# join all versioning strings, on some systems |
180 |
# join all versioning strings, on some systems |
172 |
# major/minor numbers could be in different list elements |
181 |
# major/minor numbers could be in different list elements |
173 |
from distutils.sysconfig import * |
182 |
from distutils.sysconfig import * |
174 |
ret = '' |
183 |
e = get_config_var('VERSION') |
175 |
for e in get_config_vars ('VERSION'): |
184 |
if e is not None: |
176 |
if (e != None): |
185 |
print(e) |
177 |
ret += e |
|
|
178 |
print (ret) |
179 |
EOD` |
186 |
EOD` |
180 |
|
187 |
|
181 |
if test -z "$ac_python_version"; then |
188 |
if test -z "$ac_python_version"; then |
Lines 196-250
Link Here
|
196 |
|
203 |
|
197 |
# There should be only one |
204 |
# There should be only one |
198 |
import distutils.sysconfig |
205 |
import distutils.sysconfig |
199 |
for e in distutils.sysconfig.get_config_vars ('LIBDIR'): |
206 |
e = distutils.sysconfig.get_config_var('LIBDIR') |
200 |
if e != None: |
207 |
if e is not None: |
201 |
print (e) |
208 |
print (e) |
202 |
break |
|
|
203 |
EOD` |
209 |
EOD` |
204 |
|
210 |
|
205 |
# Before checking for libpythonX.Y, we need to know |
|
|
206 |
# the extension the OS we're on uses for libraries |
207 |
# (we take the first one, if there's more than one fix me!): |
208 |
ac_python_soext=`$PYTHON -c \ |
209 |
"import distutils.sysconfig; \ |
210 |
print (distutils.sysconfig.get_config_vars('SO')[[0]])"` |
211 |
|
212 |
# Now, for the library: |
211 |
# Now, for the library: |
213 |
ac_python_soname=`$PYTHON -c \ |
212 |
ac_python_library=`cat<<EOD | $PYTHON - |
214 |
"import distutils.sysconfig; \ |
|
|
215 |
print (distutils.sysconfig.get_config_vars('LDLIBRARY')[[0]])"` |
216 |
|
213 |
|
217 |
# Strip away extension from the end to canonicalize its name: |
214 |
import distutils.sysconfig |
218 |
ac_python_library=`echo "$ac_python_soname" | sed "s/${ac_python_soext}$//"` |
215 |
c = distutils.sysconfig.get_config_vars() |
|
|
216 |
if 'LDVERSION' in c: |
217 |
print ('python'+c[['LDVERSION']]) |
218 |
else: |
219 |
print ('python'+c[['VERSION']]) |
220 |
EOD` |
219 |
|
221 |
|
220 |
# This small piece shamelessly adapted from PostgreSQL python macro; |
222 |
# This small piece shamelessly adapted from PostgreSQL python macro; |
221 |
# credits goes to momjian, I think. I'd like to put the right name |
223 |
# credits goes to momjian, I think. I'd like to put the right name |
222 |
# in the credits, if someone can point me in the right direction... ? |
224 |
# in the credits, if someone can point me in the right direction... ? |
223 |
# |
225 |
# |
224 |
if test -n "$ac_python_libdir" -a -n "$ac_python_library" \ |
226 |
if test -n "$ac_python_libdir" -a -n "$ac_python_library" |
225 |
-a x"$ac_python_library" != x"$ac_python_soname" |
|
|
226 |
then |
227 |
then |
227 |
# use the official shared library |
228 |
# use the official shared library |
228 |
ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"` |
229 |
ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"` |
229 |
PYTHON_LDFLAGS="-L$ac_python_libdir -l$ac_python_library" |
230 |
PYTHON_LIBS="-L$ac_python_libdir -l$ac_python_library" |
230 |
else |
231 |
else |
231 |
# old way: use libpython from python_configdir |
232 |
# old way: use libpython from python_configdir |
232 |
ac_python_libdir=`$PYTHON -c \ |
233 |
ac_python_libdir=`$PYTHON -c \ |
233 |
"from distutils.sysconfig import get_python_lib as f; \ |
234 |
"from distutils.sysconfig import get_python_lib as f; \ |
234 |
import os; \ |
235 |
import os; \ |
235 |
print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"` |
236 |
print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"` |
236 |
PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version" |
237 |
PYTHON_LIBS="-L$ac_python_libdir -lpython$ac_python_version" |
237 |
fi |
238 |
fi |
238 |
|
239 |
|
239 |
if test -z "PYTHON_LDFLAGS"; then |
240 |
if test -z "PYTHON_LIBS"; then |
240 |
AC_MSG_ERROR([ |
241 |
AC_MSG_ERROR([ |
241 |
Cannot determine location of your Python DSO. Please check it was installed with |
242 |
Cannot determine location of your Python DSO. Please check it was installed with |
242 |
dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand. |
243 |
dynamic libraries enabled, or try setting PYTHON_LIBS by hand. |
243 |
]) |
244 |
]) |
244 |
fi |
245 |
fi |
245 |
fi |
246 |
fi |
246 |
AC_MSG_RESULT([$PYTHON_LDFLAGS]) |
247 |
AC_MSG_RESULT([$PYTHON_LIBS]) |
247 |
AC_SUBST([PYTHON_LDFLAGS]) |
248 |
AC_SUBST([PYTHON_LIBS]) |
248 |
|
249 |
|
249 |
# |
250 |
# |
250 |
# Check for site packages |
251 |
# Check for site packages |
Lines 252-258
Link Here
|
252 |
AC_MSG_CHECKING([for Python site-packages path]) |
253 |
AC_MSG_CHECKING([for Python site-packages path]) |
253 |
if test -z "$PYTHON_SITE_PKG"; then |
254 |
if test -z "$PYTHON_SITE_PKG"; then |
254 |
PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \ |
255 |
PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \ |
255 |
print (distutils.sysconfig.get_python_lib(0,0));"` |
256 |
print (distutils.sysconfig.get_python_lib(0,0));"` |
256 |
fi |
257 |
fi |
257 |
AC_MSG_RESULT([$PYTHON_SITE_PKG]) |
258 |
AC_MSG_RESULT([$PYTHON_SITE_PKG]) |
258 |
AC_SUBST([PYTHON_SITE_PKG]) |
259 |
AC_SUBST([PYTHON_SITE_PKG]) |
Lines 261-270
Link Here
|
261 |
# libraries which must be linked in when embedding |
262 |
# libraries which must be linked in when embedding |
262 |
# |
263 |
# |
263 |
AC_MSG_CHECKING(python extra libraries) |
264 |
AC_MSG_CHECKING(python extra libraries) |
264 |
if test -z "$PYTHON_EXTRA_LIBS"; then |
265 |
if test -z "$PYTHON_EXTRA_LDFLAGS"; then |
265 |
PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ |
266 |
PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \ |
266 |
conf = distutils.sysconfig.get_config_var; \ |
267 |
conf = distutils.sysconfig.get_config_var; \ |
267 |
print (conf('LOCALMODLIBS') + ' ' + conf('LIBS'))"` |
268 |
print (conf('LIBS') + ' ' + conf('SYSLIBS'))"` |
|
|
269 |
fi |
270 |
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS]) |
271 |
AC_SUBST(PYTHON_EXTRA_LDFLAGS) |
272 |
|
273 |
# |
274 |
# linking flags needed when embedding |
275 |
# |
276 |
AC_MSG_CHECKING(python extra linking flags) |
277 |
if test -z "$PYTHON_EXTRA_LIBS"; then |
278 |
PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ |
279 |
conf = distutils.sysconfig.get_config_var; \ |
280 |
print (conf('LINKFORSHARED'))"` |
268 |
fi |
281 |
fi |
269 |
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS]) |
282 |
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS]) |
270 |
AC_SUBST(PYTHON_EXTRA_LIBS) |
283 |
AC_SUBST(PYTHON_EXTRA_LIBS) |
Lines 275-282
Link Here
|
275 |
AC_MSG_CHECKING([consistency of all components of python development environment]) |
288 |
AC_MSG_CHECKING([consistency of all components of python development environment]) |
276 |
# save current global flags |
289 |
# save current global flags |
277 |
ac_save_LIBS="$LIBS" |
290 |
ac_save_LIBS="$LIBS" |
|
|
291 |
ac_save_LDFLAGS="$LDFLAGS" |
278 |
ac_save_CPPFLAGS="$CPPFLAGS" |
292 |
ac_save_CPPFLAGS="$CPPFLAGS" |
279 |
LIBS="$ac_save_LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LIBS" |
293 |
LIBS="$ac_save_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYTHON_EXTRA_LIBS" |
|
|
294 |
LDFLAGS="$ac_save_LDFLAGS $PYTHON_EXTRA_LDFLAGS" |
280 |
CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" |
295 |
CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" |
281 |
AC_LANG_PUSH([C]) |
296 |
AC_LANG_PUSH([C]) |
282 |
AC_LINK_IFELSE([ |
297 |
AC_LINK_IFELSE([ |
Lines 287-292
Link Here
|
287 |
# turn back to default flags |
302 |
# turn back to default flags |
288 |
CPPFLAGS="$ac_save_CPPFLAGS" |
303 |
CPPFLAGS="$ac_save_CPPFLAGS" |
289 |
LIBS="$ac_save_LIBS" |
304 |
LIBS="$ac_save_LIBS" |
|
|
305 |
LDFLAGS="$ac_save_LDFLAGS" |
290 |
|
306 |
|
291 |
AC_MSG_RESULT([$pythonexists]) |
307 |
AC_MSG_RESULT([$pythonexists]) |
292 |
|
308 |
|
Lines 294-301
Link Here
|
294 |
AC_MSG_FAILURE([ |
310 |
AC_MSG_FAILURE([ |
295 |
Could not link test program to Python. Maybe the main Python library has been |
311 |
Could not link test program to Python. Maybe the main Python library has been |
296 |
installed in some non-standard library path. If so, pass it to configure, |
312 |
installed in some non-standard library path. If so, pass it to configure, |
297 |
via the LDFLAGS environment variable. |
313 |
via the LIBS environment variable. |
298 |
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib" |
314 |
Example: ./configure LIBS="-L/usr/non-standard-path/python/lib" |
299 |
============================================================================ |
315 |
============================================================================ |
300 |
ERROR! |
316 |
ERROR! |
301 |
You probably have to install the development version of the Python package |
317 |
You probably have to install the development version of the Python package |