m4macros, configure: add and use AM_PYTHON_CHECK_PYGOBJECT() macro.

Rather than looking for pygobject-3.0 with pkg-config, run an actual
test in python, loading the 'gi' module.
I also added a version parameter making it possible to even check for a
required version of PyGObject, though it is currently unused (as I have
no idea if we have a minimum requirement for our plug-ins to work well).

This is an improvement of commit 8e938e0960 as I realized that we don't
need any development files, therefore I don't think that searching with
pkg-config was the right idea in our case.
This commit is contained in:
Jehan 2019-08-09 18:05:09 +02:00
parent 96a33277d4
commit b1662443af
2 changed files with 28 additions and 12 deletions

View File

@ -2267,14 +2267,15 @@ elif test "x$with_python" = xforce; then
with_python="yes"
warning_python=
AM_PATH_PYTHON3(python3_required_version, ,
warning_python="Python python3_required_version or newer not found
")
PKG_CHECK_MODULES(PYGOBJECT, pygobject-3.0, ,
warning_python="PyGObject 3.0 not found
$warning_python")
warning_python="Python python3_required_version or newer not found")
if test "x$warning_python" = "x"; then
AM_PYTHON_CHECK_PYGOBJECT("$PYTHON", , ,
warning_python="PyGObject 3.0 not found")
fi
if test "x$warning_python" != "x"; then
warning_python="
WARNING: ${warning_python} Python plug-ins will be installed anyway but you should make
WARNING: ${warning_python}
Python plug-ins will be installed anyway but you should make
sure that a compatible Python interpreter and PyGObject are
available at installation, otherwise installed plug-ins won't
be usable."
@ -2284,14 +2285,15 @@ else
with_python="yes"
error_python=
AM_PATH_PYTHON3(python3_required_version,,
error_python="- Python python3_required_version or newer not found
")
PKG_CHECK_MODULES(PYGOBJECT, pygobject-3.0, ,
error_python="- PyGObject 3.0 not found
$error_python")
error_python="- Python python3_required_version or newer not found")
if test "x$error_python" = "x"; then
AM_PYTHON_CHECK_PYGOBJECT("$PYTHON", , ,
error_python="PyGObject 3.0 not found")
fi
if test "x$error_python" != "x"; then
required_deps="$required_deps
$error_python *** Please install Python 3 and PyGObject 3.
$error_python
*** Please install Python 3 and PyGObject 3.
*** Note that you may install the Python plug-ins even if you have
*** no Python interpreter at build-time by passing the configure
*** option --with-python=force.

View File

@ -181,6 +181,20 @@ AC_DEFUN([AM_PATH_PYTHON3],
])
# AM_PYTHON_CHECK_PYGOBJECT(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
# ---------------------------------------------------------------------------
# Run ACTION-IF-TRUE if PyGObject is present and at least VERSION.
# Run ACTION-IF-FALSE otherwise.
# This supports any version of Python.
AC_DEFUN([AM_PYTHON_CHECK_PYGOBJECT],
[prog="import sys, gi
version = '3.0'
if '$2' != '':
version = '$2'
sys.exit(gi.check_version(version))"
AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
# AM_PYTHON3_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
# ---------------------------------------------------------------------------
# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION