[jhbuild/configure-prefer-py3] autotools: allow python3 and prefer it if both are available
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild/configure-prefer-py3] autotools: allow python3 and prefer it if both are available
- Date: Fri, 27 Sep 2019 12:06:32 +0000 (UTC)
commit a0189be328430118a2ec07b65e4af88caa9db4e7
Author: Christoph Reiter <reiter christoph gmail com>
Date: Mon Sep 23 19:33:32 2019 +0200
autotools: allow python3 and prefer it if both are available
In case --with-python is passed we allow 2.7+ and 3.5+.
In case nothing is passed we try to find 3.5+ first and then
fall back to 2.7+
.gitlab-ci.yml | 2 +-
configure.ac | 32 ++++++++++++++++++++++++++------
scripts/Makefile.am | 2 +-
3 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 507066dc..b88305ae 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -36,7 +36,7 @@ test-py3:
ub19.04-py2-glib:
image: registry.gitlab.gnome.org/gnome/jhbuild/jhbuild:v3
script:
- - ./autogen.sh
+ - ./autogen.sh --with-python=python2
- make
- make install
- export PATH=$HOME/.local/bin:$PATH
diff --git a/configure.ac b/configure.ac
index 9d30ecc8..77fc9cd7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,16 +26,36 @@ if test -n "$PYTHON" && ! command -v "$PYTHON" > /dev/null; then
AC_MSG_ERROR([Python interpreter $PYTHON does not exist])
fi
-# If PYTHON is set we use it, otherwise we only allow Python 2 until the Python 3 port is complete
+# All this is supposed to do is check the Python version against python_min_ver
+# and python3_min_ver and prefer Python 3.x if nothing is set.
+m4_define(python_min_ver, 2.7)
+m4_define(python3_min_ver, 3.5)
if test -n "$PYTHON"; then
- AM_PATH_PYTHON([2.7])
+ AM_PATH_PYTHON([python_min_ver])
+ AM_PYTHON_CHECK_VERSION([$PYTHON], [3.0],
+ build_py3k=true,
+ build_py3k=false)
+ if test $build_py3k = true ; then
+ AC_MSG_CHECKING([for $PYTHON >=] python3_min_ver)
+ AM_PYTHON_CHECK_VERSION([$PYTHON], python3_min_ver,
+ [AC_MSG_RESULT(yes)],
+ [AC_MSG_ERROR(too old)])
+ fi
else
- AM_PATH_PYTHON([], [
- AS_CASE(["$PYTHON_VERSION"],
- [2.*], [],
- [AC_MSG_ERROR([JHBuild only works with python 2])])])
+ AM_PATH_PYTHON([python3_min_ver], [], [
+ unset PYTHON;
+ # XXX: AM_PATH_PYTHON caching is broken and always returns the result of the first use
+ unset am_cv_pathless_PYTHON;
+ AM_PATH_PYTHON([python_min_ver], [
+ AS_CASE(["$PYTHON_VERSION"],
+ [2.*], [],
+ [AC_MSG_ERROR([JHBuild requires Python ] python_min_ver [or]
python3_min_ver)])
+ ])
+ ])
fi
+AC_SUBST([PYTHON_BASENAME], [$(basename "$PYTHON")])
+
PKG_PROG_PKG_CONFIG
# i18n
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index f49dbbd8..bf7ca021 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -14,7 +14,7 @@ jhbuild: jhbuild.in
-e s!\@libexecdir\@!$(libexecdir)! \
-e s!\@libdir\@!$(libdir)! \
-e s!\@pythondir\@!$(pythondir)! \
- -e s!\@python\@!$(PYTHON)! \
+ -e s!\@python\@!$(PYTHON_BASENAME)! \
-e s!\@PACKAGE\@!$(PACKAGE)! \
-e s!\@VERSION\@!$(VERSION)! \
< $< > $@
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]