When we are using compiled languages – we are usually depending on pkg-config files. For example, “PKG_CHECK_MODULES(GLIB, glib2)”, but what if we are using Python?
Autoconf Archive has AX_PYTHON_MODULE macros. We can use it very easy.
How about Python + GObject Introspection? Let’s take GTK+ as an example. I wrote special m4 file (see below), you can place it in “m4” directory. Then you just need add “AX_PYTHON_GI(Gtk, 3.0)” into “configure.ac” and autoconf will check if GI works and Gtk-3.0.typelib is usable.
P.S. note that I’m not m4 expert, but it works for me.
# SYNOPSIS # # AX_PYTHON_GI(gi_module, version[, python]) # # DESCRIPTION # # Checks for Python GObject Introspection and GI module with the given # version. # # LICENSE # # Copyright (C) 2015 Igor Gnatenko <firstname.lastname@example.org> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. AC_DEFUN([AX_PYTHON_GI], [ AC_MSG_CHECKING([for bindings for GObject Introspection]) AX_PYTHON_MODULE([gi], [required], [$3]) AC_MSG_CHECKING([for version $2 of $1 GObject Introspection module]) $PYTHON -c "import gi; gi.require_version('$1', '$2')" 2> /dev/null AS_IF([test $? -eq 0], , [ AC_MSG_RESULT([no]) AC_MSG_ERROR([You need version $2 of the $1 GObject Introspection module.]) ]) AC_MSG_RESULT([yes]) ])