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
This commit is contained in:
Thomas Haller 2016-12-14 18:18:37 +01:00
parent dfeebfb3e1
commit 6070fe697a
3 changed files with 10 additions and 3 deletions

View File

@ -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 $@

View File

@ -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

View File

@ -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);