mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
Use AM_PATH_PYTHON and python-config to detect Python configuration
Using AM_PATH_PYTHON solves the site-packages directory problem. At least in Ubuntu with Python 2.6 and later site-packages is renamed to dist-packages and site-packages is not part of sys.path anymore. So installing the libvirt Python bindings to site-packages renders them unusable, because they can be imported from there without manually including site-packages into sys.path. AM_PATH_PYTHON detects the correct site-packages/dist-packages directory. python-config --includes gives the correct include path for the Python header files. The old probing code stays there as fallback mechanism. * configure.in: use AM_PATH_PYTHON and python-config * python/Makefile.am: remove -I because PYTHON_INCLUDES contains it now
This commit is contained in:
parent
10616d7a1e
commit
66137344fe
76
configure.in
76
configure.in
@ -1464,75 +1464,71 @@ AC_ARG_WITH([python],
|
|||||||
|
|
||||||
PYTHON_VERSION=
|
PYTHON_VERSION=
|
||||||
PYTHON_INCLUDES=
|
PYTHON_INCLUDES=
|
||||||
PYTHON_SITE_PACKAGES=
|
|
||||||
PYTHON_TESTS=
|
|
||||||
pythondir=
|
pythondir=
|
||||||
if test "$with_python" != "no" ; then
|
if test "$with_python" != "no" ; then
|
||||||
if test -x "$with_python/bin/python"
|
if test -x "$with_python/bin/python"
|
||||||
then
|
then
|
||||||
echo Found python in $with_python/bin/python
|
AC_MSG_NOTICE(Found python in $with_python/bin/python)
|
||||||
PYTHON="$with_python/bin/python"
|
PYTHON="$with_python/bin/python"
|
||||||
|
with_python=yes
|
||||||
else
|
else
|
||||||
if test -x "$with_python"
|
if test -x "$with_python"
|
||||||
then
|
then
|
||||||
echo Found python in $with_python
|
AC_MSG_NOTICE(Found python in $with_python)
|
||||||
PYTHON="$with_python"
|
PYTHON="$with_python"
|
||||||
|
with_python=yes
|
||||||
else
|
else
|
||||||
if test -x "$PYTHON"
|
if test -x "$PYTHON"
|
||||||
then
|
then
|
||||||
echo Found python in environment PYTHON=$PYTHON
|
AC_MSG_NOTICE(Found python in environment PYTHON=$PYTHON)
|
||||||
with_python=`$PYTHON -c "import sys; print sys.exec_prefix"`
|
with_python=yes
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$with_python" == "yes" ; then
|
||||||
|
AM_PATH_PYTHON(,, [:])
|
||||||
|
|
||||||
|
if test "$PYTHON" != : ; then
|
||||||
|
PYTHON_CONFIG="$PYTHON-config"
|
||||||
|
|
||||||
|
if test -x "$PYTHON_CONFIG"
|
||||||
|
then
|
||||||
|
PYTHON_INCLUDES=`$PYTHON_CONFIG --includes`
|
||||||
else
|
else
|
||||||
AC_PATH_PROG([PYTHON], [python python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5])
|
if test -r $PYTHON_EXEC_PREFIX/include/python$PYTHON_VERSION/Python.h
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test "$PYTHON" != ""
|
|
||||||
then
|
then
|
||||||
PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
|
PYTHON_INCLUDES=-I$PYTHON_EXEC_PREFIX/include/python$PYTHON_VERSION
|
||||||
echo Found Python version $PYTHON_VERSION
|
|
||||||
fi
|
|
||||||
if test "$PYTHON_VERSION" != ""
|
|
||||||
then
|
|
||||||
if test -r $with_python/include/python$PYTHON_VERSION/Python.h -a \
|
|
||||||
-d $with_python/lib/python$PYTHON_VERSION/site-packages
|
|
||||||
then
|
|
||||||
PYTHON_INCLUDES=$with_python/include/python$PYTHON_VERSION
|
|
||||||
PYTHON_SITE_PACKAGES=$libdir/python$PYTHON_VERSION/site-packages
|
|
||||||
else
|
else
|
||||||
if test -r $prefix/include/python$PYTHON_VERSION/Python.h
|
if test -r $prefix/include/python$PYTHON_VERSION/Python.h
|
||||||
then
|
then
|
||||||
PYTHON_INCLUDES=$prefix/include/python$PYTHON_VERSION
|
PYTHON_INCLUDES=-I$prefix/include/python$PYTHON_VERSION
|
||||||
PYTHON_SITE_PACKAGES=$libdir/python$PYTHON_VERSION/site-packages
|
|
||||||
else
|
else
|
||||||
if test -r /usr/include/python$PYTHON_VERSION/Python.h
|
if test -r /usr/include/python$PYTHON_VERSION/Python.h
|
||||||
then
|
then
|
||||||
PYTHON_INCLUDES=/usr/include/python$PYTHON_VERSION
|
PYTHON_INCLUDES=-I/usr/include/python$PYTHON_VERSION
|
||||||
PYTHON_SITE_PACKAGES=$libdir/python$PYTHON_VERSION/site-packages
|
|
||||||
else
|
else
|
||||||
echo could not find python$PYTHON_VERSION/Python.h
|
AC_MSG_NOTICE([Could not find python$PYTHON_VERSION/Python.h, disabling bindings])
|
||||||
fi
|
with_python=no
|
||||||
fi
|
|
||||||
if test ! -d "$PYTHON_SITE_PACKAGES"
|
|
||||||
then
|
|
||||||
PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib()"`
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if test "$with_python" != "yes"
|
|
||||||
then
|
|
||||||
pythondir='$(PYTHON_SITE_PACKAGES)'
|
|
||||||
else
|
|
||||||
pythondir='$(libdir)/python$(PYTHON_VERSION)/site-packages'
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
PYTHON=
|
AC_MSG_NOTICE([Could not find python interpreter, disabling bindings])
|
||||||
|
with_python=no
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL([WITH_PYTHON], test "$PYTHON_INCLUDES" != "")
|
else
|
||||||
AC_SUBST([pythondir])
|
AC_MSG_NOTICE([Could not find python in $with_python, disabling bindings])
|
||||||
|
with_python=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL([WITH_PYTHON], [test "$with_python" = "yes"])
|
||||||
AC_SUBST([PYTHON_VERSION])
|
AC_SUBST([PYTHON_VERSION])
|
||||||
AC_SUBST([PYTHON_INCLUDES])
|
AC_SUBST([PYTHON_INCLUDES])
|
||||||
AC_SUBST([PYTHON_SITE_PACKAGES])
|
AC_SUBST([pythondir])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether this host is running a Xen kernel])
|
AC_MSG_CHECKING([whether this host is running a Xen kernel])
|
||||||
RUNNING_XEN=
|
RUNNING_XEN=
|
||||||
|
@ -4,7 +4,7 @@ SUBDIRS= . tests
|
|||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
$(WARN_CFLAGS) \
|
$(WARN_CFLAGS) \
|
||||||
-I$(PYTHON_INCLUDES) \
|
$(PYTHON_INCLUDES) \
|
||||||
-I$(top_srcdir)/include \
|
-I$(top_srcdir)/include \
|
||||||
-I$(top_builddir)/include \
|
-I$(top_builddir)/include \
|
||||||
-I$(top_builddir)/$(subdir)
|
-I$(top_builddir)/$(subdir)
|
||||||
|
Loading…
Reference in New Issue
Block a user