Roger Pau Monne
2012-Apr-02 10:27 UTC
[PATCH v3] autoconf: fix python-dev detection on old python versions
Replaced the use of python-config (that is only present in Python >= 2.5.x)
with the distutils python module.
Please run ./autogen.sh after applying the patch.
Again, this has only been tested on OS X Python 2.7.
Changes since v2:
* Added SYSLIBS to library test.
Changes since v1:
* Added Python LDFLAGS to library test.
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Cc: Zhang, Yang Z <yang.z.zhang@intel.com>
Cc: KUWAMURA Shin''ya <kuwa@jp.fujitsu.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
---
tools/m4/python_devel.m4 | 38 +++++++++++++++++++-------------------
1 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/tools/m4/python_devel.m4 b/tools/m4/python_devel.m4
index 3bcca7b..8bfcd0c 100644
--- a/tools/m4/python_devel.m4
+++ b/tools/m4/python_devel.m4
@@ -1,27 +1,27 @@
AC_DEFUN([AX_CHECK_PYTHON_DEVEL], [
+ac_python_version=`$PYTHON -c ''import distutils.sysconfig; \
+ print distutils.sysconfig.get_config_var("VERSION")''`
ac_previous_cppflags=$CPPFLAGS
-CPPFLAGS="$CFLAGS `$PYTHON-config --includes`"
+CPPFLAGS="$CFLAGS `$PYTHON -c ''import distutils.sysconfig; \
+ print "-I" +
distutils.sysconfig.get_config_var("INCLUDEPY")''`"
+CPPFLAGS="$CPPFLAGS `$PYTHON -c ''import distutils.sysconfig; \
+ print
distutils.sysconfig.get_config_var("CFLAGS")''`"
ac_previous_ldflags=$LDFLAGS
-for flag in `$PYTHON-config --ldflags`
-do
- case $flag in
- -L*)
- LDFLAGS="$LDLFAGS $flag"
- ;;
- -lpython*)
- python_lib=`echo $flag | sed ''s/^-l//''`
- ;;
- -l*)
- # Ignore other libraries, we are only interested in testing python-dev
- ;;
- *)
- AC_MSG_WARN([Strange ldflag found in $PYTHON-config output: $flag])
- ;;
- esac
-done
+LDFLAGS="$LDFLAGS `$PYTHON -c ''import distutils.sysconfig; \
+ print distutils.sysconfig.get_config_var("LIBS")''`"
+LDFLAGS="$LDFLAGS `$PYTHON -c ''import distutils.sysconfig; \
+ print
distutils.sysconfig.get_config_var("SYSLIBS")''`"
+LDFLAGS="$LDFLAGS `$PYTHON -c ''import distutils.sysconfig; \
+ print "-L" + distutils.sysconfig.get_python_lib(plat_specific=1,\
+ standard_lib=1) + "/config"''`"
+LDFLAGS="$LDFLAGS `$PYTHON -c ''import distutils.sysconfig; \
+ print
distutils.sysconfig.get_config_var("LINKFORSHARED")''`"
+LDFLAGS="$LDFLAGS `$PYTHON -c ''import distutils.sysconfig; \
+ print
distutils.sysconfig.get_config_var("LDFLAGS")''`"
+
AC_CHECK_HEADER([Python.h], [],
[AC_MSG_ERROR([Unable to find Python development headers])],)
-AC_CHECK_LIB($python_lib, PyArg_ParseTuple, [],
+AC_CHECK_LIB(python$ac_python_version, PyArg_ParseTuple, [],
[AC_MSG_ERROR([Unable to find a suitable python development library])])
CPPFLAGS=$ac_previous_cppflags
LDLFAGS=$ac_previous_ldflags
--
1.7.7.5 (Apple Git-26)
KUWAMURA Shin''ya
2012-Apr-03 04:33 UTC
Re: [PATCH v3] autoconf: fix python-dev detection on old python versions
Hi,>>>>> On Mon, 2 Apr 2012 11:27:46 +0100 >>>>> roger.pau@entel.upc.edu(Roger Pau Monne) said: > > Replaced the use of python-config (that is only present in Python >= 2.5.x) > with the distutils python module. > > Please run ./autogen.sh after applying the patch. > Again, this has only been tested on OS X Python 2.7. > Changes since v2: > * Added SYSLIBS to library test. > Changes since v1: > * Added Python LDFLAGS to library test.This patch worked on RHEL4U2(Python 2.3), CentOS5.7(Python 2.4) and Fedora 16(Python 2.7). Best regards, -- KUWAMURA Shin''ya
Ian Jackson
2012-Apr-03 13:39 UTC
Re: [PATCH v3] autoconf: fix python-dev detection on old python versions [and 1 more messages]
Roger Pau Monne writes ("[Xen-devel] [PATCH v3] autoconf: fix python-dev
detection on old python versions"):> Replaced the use of python-config (that is only present in Python >=
2.5.x)
> with the distutils python module.
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian.
Olaf Hering
2012-Apr-07 14:07 UTC
Re: [PATCH v3] autoconf: fix python-dev detection on old python versions [and 1 more messages]
On Tue, Apr 03, Ian Jackson wrote:> Roger Pau Monne writes ("[Xen-devel] [PATCH v3] autoconf: fix python-dev detection on old python versions"): > > Replaced the use of python-config (that is only present in Python >= 2.5.x) > > with the distutils python module. > > Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>I think this is the cause for a regression between changeset 25138 and 25161 in openSuSE 11.4, 12.1 and upcoming 12.2. SLES11 still builds fine: ... configure:6205: checking for Python.h configure:6205: result: yes configure:6214: checking for PyArg_ParseTuple in -lpython2.7 configure:6239: gcc -o conftest -g -O2 -g -O2 -I/usr/include/python2.7 -fno-strict-aliasing -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -lpthread -ldl -lutil -lm -L/usr/lib64/python2.7/config -Xlinker -export-dynamic conftest.c -lpython2.7 >&5 /usr/lib64/python2.7/config/libpython2.7.a(longobject.o): In function `PyLong_FromString'': /home/abuild/rpmbuild/BUILD/Python-2.7.2/Objects/longobject.c:1851: undefined reference to `log'' /usr/lib64/python2.7/config/libpython2.7.a(signalmodule.o): In function `timeval_from_double'': /home/abuild/rpmbuild/BUILD/Python-2.7.2/./Modules/signalmodule.c:112: undefined reference to `floor'' /home/abuild/rpmbuild/BUILD/Python-2.7.2/./Modules/signalmodule.c:113: undefined reference to `fmod'' /home/abuild/rpmbuild/BUILD/Python-2.7.2/./Modules/signalmodule.c:112: undefined reference to `floor'' /home/abuild/rpmbuild/BUILD/Python-2.7.2/./Modules/signalmodule.c:113: undefined reference to `fmod'' /usr/lib64/python2.7/config/libpython2.7.a(complexobject.o): In function `_Py_c_pow'': /home/abuild/rpmbuild/BUILD/Python-2.7.2/Objects/complexobject.c:139: undefined reference to `hypot'' /home/abuild/rpmbuild/BUILD/Python-2.7.2/Objects/complexobject.c:140: undefined reference to `pow'' /home/abuild/rpmbuild/BUILD/Python-2.7.2/Objects/complexobject.c:141: undefined reference to `atan2'' /home/abuild/rpmbuild/BUILD/Python-2.7.2/Objects/complexobject.c:145: undefined reference to `sincos'' ... I havent followed the discussion about the python detection. My immediate reaction would be to use python-config when available. This is what I get in the build chroot: python-config --cflags -I/usr/include/python2.7 -I/usr/include/python2.7 -fno-strict-aliasing -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g python-config --ldflags -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic python-config --libs -lpthread -ldl -lutil -lm -lpython2.7 python-config --includes -I/usr/include/python2.7 -I/usr/include/python2.7 Olaf