Roger Pau Monne
2012-Mar-29 13:54 UTC
[PATCH] 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.
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 | 34 +++++++++++++++-------------------
1 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/tools/m4/python_devel.m4 b/tools/m4/python_devel.m4
index 3bcca7b..5f161f1 100644
--- a/tools/m4/python_devel.m4
+++ b/tools/m4/python_devel.m4
@@ -1,27 +1,23 @@
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 "-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")''`"
+
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)
Roger Pau Monné
2012-Mar-29 13:57 UTC
Re: [PATCH] autoconf: fix python-dev detection on old python versions
2012/3/29 Roger Pau Monne <roger.pau@entel.upc.edu>:> 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. >I've forgot to say, but this has only been tested on my Mac, which has Python 2.7, because I'm not able to test it anywhere else right now. I hope it works with older Python versions, so we can get rid of python-config.> 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 | 34 +++++++++++++++------------------- > 1 files changed, 15 insertions(+), 19 deletions(-) > > diff --git a/tools/m4/python_devel.m4 b/tools/m4/python_devel.m4 > index 3bcca7b..5f161f1 100644 > --- a/tools/m4/python_devel.m4 > +++ b/tools/m4/python_devel.m4 > @@ -1,27 +1,23 @@ > 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 "-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")'`" > + > 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) >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Jan Beulich
2012-Mar-29 15:26 UTC
Re: [PATCH] autoconf: fix python-dev detection on old python versions
>>> Roger Pau Monne <roger.pau@entel.upc.edu> 03/29/12 3:55 PM >>> >Replaced the use of python-config (that is only present in Python > 2.5.x) >with the distutils python module.And that is available everywhere? I actually found it pretty simple to grab python-config from a newer Python version and put it (maybe after some minor adjustment) somewhere in $PATH. Jan
Zhang, Yang Z
2012-Mar-30 00:54 UTC
Re: [PATCH] autoconf: fix python-dev detection on old python versions
The python-config error is fixed, but still get the following message: checking Python.h presence... yes checking for Python.h... yes checking for PyArg_ParseTuple in -lpython2.4... no configure: error: Unable to find a suitable python development library best regards yang> -----Original Message----- > From: Roger Pau Monné [mailto:royger@gmail.com] On Behalf Of Roger Pau > Monne > Sent: Thursday, March 29, 2012 9:55 PM > To: xen-devel@lists.xen.org > Cc: Roger Pau Monne; Zhang, Yang Z; KUWAMURA Shin''ya; Ian Campbell > Subject: [PATCH] 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. > > 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 | 34 +++++++++++++++------------------- > 1 files changed, 15 insertions(+), 19 deletions(-) > > diff --git a/tools/m4/python_devel.m4 b/tools/m4/python_devel.m4 > index 3bcca7b..5f161f1 100644 > --- a/tools/m4/python_devel.m4 > +++ b/tools/m4/python_devel.m4 > @@ -1,27 +1,23 @@ > 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 "-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")''`" > + > 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-Mar-30 06:47 UTC
Re: [PATCH] autoconf: fix python-dev detection on old python versions
Hi,>>>>> On Fri, 30 Mar 2012 00:54:23 +0000 >>>>> yang.z.zhang@intel.com("Zhang, Yang Z") said: > > The python-config error is fixed, but still get the following message: > > checking Python.h presence... yes > checking for Python.h... yes > checking for PyArg_ParseTuple in -lpython2.4... no > configure: error: Unable to find a suitable python development libraryI got the same result on CentOS 5.7, since libpython2.4.so needs -lm. Workaround: ./configure APPEND_LDFLAGS=-lm Best regards, -- KUWAMURA Shin''ya