Roger Pau Monne
2012-Apr-10 16:38 UTC
[PATCH] autoconf: use python-config when present, if not switch to distutils
Use python-config utility when possible, and if it is not present switch to distutils. Should fix the bug reported by Olaf Hering on SuSE. Rerun autoconf after applying the patch. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Cc: Olaf Hering <olaf@aepfle.de> --- tools/m4/python_devel.m4 | 42 +++++++++++++++++++++++++----------------- 1 files changed, 25 insertions(+), 17 deletions(-) diff --git a/tools/m4/python_devel.m4 b/tools/m4/python_devel.m4 index 8bfcd0c..0a2202c 100644 --- a/tools/m4/python_devel.m4 +++ b/tools/m4/python_devel.m4 @@ -1,23 +1,31 @@ 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 -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 -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_python_version=`$PYTHON -c ''import distutils.sysconfig; \ + print distutils.sysconfig.get_config_var("VERSION")''` +AC_PATH_PROG([pyconfig], [$PYTHON-config], [no]) +AS_IF([test x"$pyconfig" == x"no"], [ + dnl For those that don''t have python-config + 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")''`" + 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")''`" +], [ + dnl If python-config is found use it + CPPFLAGS="$CFLAGS `$PYTHON-config --cflags`" + LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags`" +]) AC_CHECK_HEADER([Python.h], [], [AC_MSG_ERROR([Unable to find Python development headers])],) -- 1.7.7.5 (Apple Git-26)
Olaf Hering
2012-Apr-11 10:00 UTC
Re: [PATCH] autoconf: use python-config when present, if not switch to distutils
On Tue, Apr 10, Roger Pau Monne wrote:> Use python-config utility when possible, and if it is not present switch to > distutils. > > Should fix the bug reported by Olaf Hering on SuSE. > > Rerun autoconf after applying the patch.Yes, this fixes the build on openSuSE 11.4 and later. Olaf
Ian Jackson
2012-Apr-24 17:50 UTC
Re: [PATCH] autoconf: use python-config when present, if not switch to distutils
Roger Pau Monne writes ("[Xen-devel] [PATCH] autoconf: use python-config when present, if not switch to distutils"):> Use python-config utility when possible, and if it is not present switch to > distutils. > > Should fix the bug reported by Olaf Hering on SuSE. > > Rerun autoconf after applying the patch. > > Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> > Cc: Olaf Hering <olaf@aepfle.de>Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>