[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH for-next RFC 1/4] build/m4: make python_devel.m4 work with both python 2 and 3
On Tue, Mar 05, 2019 at 04:42:03PM +0000, Wei Liu wrote: > Do the following: > > 1. Change the form of "print". > 2. Check for ABI flags -- this is complicated because it is only > introduced in 3.2. Is this a recommanded way of doing this? I may have a better way of fixing this macro, see below. > 3. Fix library name in AC_CHECK_LIB. > 4. Remove other-libs in AC_CHECK_LIB. Why did you remove the other libs? Also, with this change, PYTHON_LIBS isn't used anywhere anymore, and can be removed. > > Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> > --- > I doubt the non python-pkg branch works, because the paths generated > seem rather off. It definitely doesn't work on my machine, but I > don't know how other systems could possibly be configured before the > existence of python-config. > --- > m4/python_devel.m4 | 27 ++++++++++++++++----------- > tools/configure | 34 ++++++++++++++++++++-------------- > 2 files changed, 36 insertions(+), 25 deletions(-) > > diff --git a/m4/python_devel.m4 b/m4/python_devel.m4 > index 05ea4ef7e2..1e2f41b6aa 100644 > --- a/m4/python_devel.m4 > +++ b/m4/python_devel.m4 > @@ -2,37 +2,42 @@ AC_DEFUN([AX_CHECK_PYTHON_DEVEL], [ > ac_previous_cppflags=$CPPFLAGS > ac_previous_ldflags=$LDFLAGS > ac_python_version=`$PYTHON -c 'import distutils.sysconfig; \ > - print distutils.sysconfig.get_config_var("VERSION")'` > + print(distutils.sysconfig.get_config_var("VERSION"))'` > +ac_python_abiflags= > 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")'`" > + print(distutils.sysconfig.get_config_var("CFLAGS"))'`" > PYTHON_LIBS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ > - print distutils.sysconfig.get_config_var("LIBS")'`" > + print(distutils.sysconfig.get_config_var("LIBS"))'`" > PYTHON_LIBS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ > - print distutils.sysconfig.get_config_var("SYSLIBS")'`" > + 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"'`" > + 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")'`" > + print(distutils.sysconfig.get_config_var("LINKFORSHARED"))'`" > LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ > - print distutils.sysconfig.get_config_var("LDFLAGS")'`" > + 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`" > PYTHON_LIBS="$LIBS `$PYTHON-config --libs`" > + abiflags="`$PYTHON-config --abiflags`" > + if test "$?" == "0" > + then > + ac_python_abiflags="$abiflags" > + fi > ]) > > AC_CHECK_HEADER([Python.h], [], > [AC_MSG_ERROR([Unable to find Python development headers])],) > -AC_CHECK_LIB(python$ac_python_version, PyArg_ParseTuple, [], > - [AC_MSG_ERROR([Unable to find a suitable python development library])], > - [$PYTHON_LIBS]) > +AC_CHECK_LIB(python$ac_python_version$ac_python_abiflags, PyArg_ParseTuple, > [], > + [AC_MSG_ERROR([Unable to find a suitable python development library])]) So, AC_CHECK_LIB seems to only be used to check if PyArg_ParseTuple exist, and requires as argument the name of the lib which is now complicated. But, AC_CHECK_LIB do test compilation using the LDFLAGS which already contain the python lib we want, so instead, we could only do the part of the jobs that we need: AC_LINK_IFELSE([AC_LANG_CALL([], [PyArg_ParseTuple])], [], [AC_MSG_ERROR([Unable to find a suitable python development library])]) That generate a main.c with PyArg_ParseTuple() call like AC_CHECK_LIB do, and do build/link. If that fails, throw an error. That avoid to use the --abiflags, which we don't need. What do you thing? Some progress message can be added, similair to AC_CHECK_LIB: AC_MSG_CHECKING([for PyArg_ParseTuple]) and [AC_MSG_RESULT([yes])] on success. (I think AC_CHECK_LIB would also update $LIBS, but I don't think our build system is using that.) > CPPFLAGS=$ac_previous_cppflags > LDFLAGS=$ac_previous_ldflags > ]) -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |