[gimp] m4macros, configure: add and use AM_PYTHON_CHECK_PYGOBJECT() macro.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] m4macros, configure: add and use AM_PYTHON_CHECK_PYGOBJECT() macro.
- Date: Fri, 9 Aug 2019 16:19:18 +0000 (UTC)
commit b1662443afbaa0ff6a9d200d346945087eefdf80
Author: Jehan <jehan girinstud io>
Date: Fri Aug 9 18:05:09 2019 +0200
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.
configure.ac | 26 ++++++++++++++------------
m4macros/python3dev.m4 | 14 ++++++++++++++
2 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 410bd86455..2263abd16f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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.
diff --git a/m4macros/python3dev.m4 b/m4macros/python3dev.m4
index bec231b166..44e0aff9cc 100644
--- a/m4macros/python3dev.m4
+++ b/m4macros/python3dev.m4
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]