python: Auto-check for all installed python versions.

* m4/python.m4 (AM_PATH_PYTHON): Add a 4th arg.
* configure.ac (available_languages): Remove separate python2 and
python3 and keep just python.  Simplify test for pythons.  Use an
explicit list of python versions to test.
--

This seems to be a starightforward chnage to support more than two
python versions.  I am not sure why we had that complicated thing
before.  On my box I get builds and run tests for 2.7, 3.4 and 3.5.
If 3.6, 3.7 or 3.8 are installed they should also work.

GnuPG-bug-id: 3354
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-10-17 10:05:04 +02:00
parent d63d6d8b80
commit ff6ff616ae
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
2 changed files with 16 additions and 37 deletions

View File

@ -180,7 +180,7 @@ have_w64_system=no
have_macos_system=no
build_w32_glib=no
build_w32_qt=no
available_languages="cl cpp python python2 python3 qt"
available_languages="cl cpp python qt"
default_languages="cl cpp python qt"
case "${host}" in
x86_64-*mingw32*)
@ -375,13 +375,9 @@ fi
AC_SUBST(HAVE_DOT)
# Python bindings.
LIST_MEMBER("python2", $enabled_languages)
found_py2=$found
LIST_MEMBER("python3", $enabled_languages)
found_py3=$found
LIST_MEMBER("python", $enabled_languages)
found_py=$found
if test "$found_py" = "1" -o "$found_py2" = "1" -o "$found_py3" = "1"; then
if test "$found_py" = "1"; then
AX_PKG_SWIG
if test -z "$SWIG"; then
if test "$explicit_languages" = "1"; then
@ -393,36 +389,15 @@ if test "$found_py" = "1" -o "$found_py2" = "1" -o "$found_py3" = "1"; then
enabled_languages=$(echo $enabled_languages | sed 's/python//')
fi
else
# Reset all the stuff, just to be sure.
# Reset the version collecting vars.
PYTHONS=
PYTHON_VERSIONS=
unset PYTHON
unset PYTHON_VERSION
unset PYTHON_CPPFLAGS
unset PYTHON_LDFLAGS
unset PYTHON_SITE_PKG
unset PYTHON_EXTRA_LIBS
unset PYTHON_EXTRA_LDFLAGS
unset ac_cv_path_PYTHON
unset am_cv_pathless_PYTHON
unset am_cv_python_version
unset am_cv_python_platform
unset am_cv_python_pythondir
unset am_cv_python_pyexecdir
if test "$found_py" = "1" -o "$found_py2" = "1"; then
AM_PATH_PYTHON([2.7], [
AX_PYTHON_DEVEL
if test "$PYTHON_VERSION"; then
PYTHONS="$(echo $PYTHONS $PYTHON)"
PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)"
fi
], :)
fi
if test "$found_py" = "1" -o "$found_py3" = "1"; then
# Reset everything, so that we can look for another Python.
unset PYTHON
m4_foreach([mym4pythonver],
[[2.7],[3.4],[3.5],[3.6],[3.7],[3.8],[all]],
[unset PYTHON
unset PYTHON_VERSION
unset PYTHON_CPPFLAGS
unset PYTHON_LDFLAGS
@ -435,13 +410,14 @@ if test "$found_py" = "1" -o "$found_py2" = "1" -o "$found_py3" = "1"; then
unset am_cv_python_platform
unset am_cv_python_pythondir
unset am_cv_python_pyexecdir
AM_PATH_PYTHON([3.4], [
AM_PATH_PYTHON(mym4pythonver, [
AX_PYTHON_DEVEL
if test "$PYTHON_VERSION"; then
PYTHONS="$(echo $PYTHONS $PYTHON)"
PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)"
fi
], :)
], :, m4_if([mym4pythonver],[all],[],[python]mym4pythonver))
])
fi
# Recover some values lost in the second attempt to find Python.

View File

@ -2,7 +2,8 @@
## Python file handling
## From Andrew Dalke
## Updated by James Henstridge
## ------------------------
## Upated by Werner Koch 2018-10-17
## ---------------------------------
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
@ -10,7 +11,8 @@
# with or without modifications, as long as this notice is preserved.
# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]
# [INTERPRETER-LIST])
# ---------------------------------------------------------------------------
# Adds support for distributing Python modules and packages. To
# install modules, copy them to $(pythondir), using the python_PYTHON
@ -67,7 +69,8 @@ AC_DEFUN([AM_PATH_PYTHON],
# VERSION.
AC_CACHE_CHECK([for a Python interpreter with version >= $1],
[am_cv_pathless_PYTHON],[
for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
for am_cv_pathless_PYTHON dnl
in m4_if([$4],[],[_AM_PYTHON_INTERPRETER_LIST],[$4]) none; do
test "$am_cv_pathless_PYTHON" = none && break
AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
done])