From 6070fe697a4ccf9c90817f6d7268ba184fc744ea Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 14 Dec 2016 18:18:37 +0100 Subject: [PATCH] build: allow specifying the python interpreter for building As build-requirement, we either require - python2 with python-gobject-base - python3 with python3-gobject-base Previously, we would require that a plain `python` gives the desired interpreter version. If somebody's "/usr/bin/env python" however points to a different python version, there was no easy way to change it -- aside resetting the $PATH variable to some desired "python" binary. Now, you can specify it during configure: ./configure PYTHON=python3 ... This especially matters, if you only have python3-gobject-base installed, you /usr/bin/python is a symlink to python2. https://bugzilla.gnome.org/show_bug.cgi?id=775768 --- Makefile.am | 1 + configure.ac | 6 +++++- shared/nm-test-utils-impl.c | 6 ++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 5eccc8b30e..0df6a8380c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -871,6 +871,7 @@ libnm/nm-property-docs.xml: libnm/generate-setting-docs.py $(libnm_docs_sources) export GI_TYPELIB_PATH=$(abs_builddir)/libnm$${GI_TYPELIB_PATH:+:$$GI_TYPELIB_PATH}; \ export LD_LIBRARY_PATH=$(abs_builddir)/libnm/.libs$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH}; \ $(call set_sanitizer_env,$(abs_builddir)/libnm/.libs/libnm.so); \ + "$(PYTHON)" \ $(srcdir)/libnm/generate-setting-docs.py \ --gir $(builddir)/libnm/NM-1.0.gir \ --output $@ diff --git a/configure.ac b/configure.ac index 0d9742814b..08bebebfac 100644 --- a/configure.ac +++ b/configure.ac @@ -1100,11 +1100,15 @@ if test "$enable_gtk_doc" != "yes" \ fi AM_CONDITIONAL(INSTALL_PREGEN_MANPAGES, test "x${install_pregen_manpages}" = "xyes") +AM_PATH_PYTHON([], [], [PYTHON=python]) +AC_SUBST(PYTHON, [$PYTHON]) +AC_DEFINE_UNQUOTED(TEST_NM_PYTHON, "$PYTHON", [Define python path for test binary]) + # check if we can build setting property documentation build_setting_docs=no if test -n "$INTROSPECTION_MAKEFILE"; then # If g-i is installed we know we have python, but we might not have pygobject - if ! python -c 'from gi.repository import GObject' >& /dev/null; then + if ! "$PYTHON" -c 'from gi.repository import GObject' >& /dev/null; then AC_MSG_ERROR(["--enable-introspection aims to build the settings documentation. This requires GObject introspection for python (pygobject)]) fi diff --git a/shared/nm-test-utils-impl.c b/shared/nm-test-utils-impl.c index 613a6dfea8..6926ea3060 100644 --- a/shared/nm-test-utils-impl.c +++ b/shared/nm-test-utils-impl.c @@ -82,7 +82,7 @@ NMTstcServiceInfo * nmtstc_service_init (void) { NMTstcServiceInfo *info; - const char *args[2] = { TEST_NM_SERVICE, NULL }; + const char *args[] = { TEST_NM_PYTHON, TEST_NM_SERVICE, NULL }; GError *error = NULL; int i; @@ -95,7 +95,9 @@ nmtstc_service_init (void) * stdin; if it closes, the service will exit immediately. We use this to * make sure the service exits if the test program crashes. */ - g_spawn_async_with_pipes (NULL, (char **) args, NULL, 0, NULL, NULL, + g_spawn_async_with_pipes (NULL, (char **) args, NULL, + G_SPAWN_SEARCH_PATH, + NULL, NULL, &info->pid, &info->keepalive_fd, NULL, NULL, &error); g_assert_no_error (error);