[jhbuild/configure-python3] build: add "--with-python=" option to allow building with Python 3



commit 4cd93eb1579c389685519fddc909ce4613b8ac67
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Tue Sep 17 09:40:39 2019 +0200

    build: add "--with-python=" option to allow building with Python 3
    
    jhbuild doesn't work with it yet, but this makes testing/porting possible.
    
    ./autogen.sh --with-python=python3

 configure.ac        | 27 +++++++++++++++++++++++----
 scripts/Makefile.am |  1 +
 scripts/jhbuild.in  |  2 +-
 3 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 58923be4..83944b58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,10 +13,29 @@ AM_MAINTAINER_MODE([enable])
 
 # Check for programs
 AC_PROG_CC
-AM_PATH_PYTHON([], [
-       AS_CASE(["$PYTHON_VERSION"],
-               [2.*], [],
-               [AC_MSG_ERROR([JHBuild only works with python 2])])])
+
+# Option to specify python interpreter to use; this just sets $PYTHON, so that
+# we will fall back to reading $PYTHON if --with-python is not given
+AC_ARG_WITH(python,
+  AS_HELP_STRING([--with-python=PATH],[Path to Python interpreter; searches $PATH if only a program name is 
given; if not given, searches for a few standard names such as "python3" or "python2"]),
+  [PYTHON="$withval"], [])
+if test x"$PYTHON" = xyes; then
+       AC_MSG_ERROR([--with-python option requires a path or program argument])
+fi
+if test -n "$PYTHON" && ! which "$PYTHON"; 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
+if test -n "$PYTHON"; then
+       AM_PATH_PYTHON([2.7])
+else
+       AM_PATH_PYTHON([], [
+               AS_CASE(["$PYTHON_VERSION"],
+                       [2.*], [],
+                       [AC_MSG_ERROR([JHBuild only works with python 2])])])
+fi
+
 PKG_PROG_PKG_CONFIG
 
 # i18n
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 383a1f67..f49dbbd8 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -14,6 +14,7 @@ jhbuild: jhbuild.in
                -e s!\@libexecdir\@!$(libexecdir)!      \
                -e s!\@libdir\@!$(libdir)!              \
                -e s!\@pythondir\@!$(pythondir)!        \
+               -e s!\@python\@!$(PYTHON)!      \
                -e s!\@PACKAGE\@!$(PACKAGE)!            \
                -e s!\@VERSION\@!$(VERSION)!            \
                < $< > $@
diff --git a/scripts/jhbuild.in b/scripts/jhbuild.in
index fc2489fd..48992e33 100644
--- a/scripts/jhbuild.in
+++ b/scripts/jhbuild.in
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env @python@
 # -*- coding: utf-8 -*-
 
 import sys


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]