Skip to content

Commit

Permalink
python: Auto-check for all installed python versions.
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
dd9jn committed Oct 17, 2018
1 parent d63d6d8 commit ff6ff61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 37 deletions.
44 changes: 10 additions & 34 deletions configure.ac
Expand Up @@ -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*)
Expand Down Expand Up @@ -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
Expand All @@ -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
# Reset everything, so that we can look for another 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
Expand All @@ -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.
Expand Down
9 changes: 6 additions & 3 deletions m4/python.m4
Expand Up @@ -2,15 +2,17 @@
## 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
# gives unlimited permission to copy and/or distribute it,
# 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
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit ff6ff61

Please sign in to comment.