summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2019-09-20 08:30:42 -0700
committerBen Pfaff <blp@ovn.org>2019-09-27 09:23:50 -0700
commit1ca0323e7c29dc7ef5a615c265df0460208f92de (patch)
tree377630fee2130b269cfe2fd348c9e8c6bc5a814a /m4
parent187bb41fbf447acf9fb6ac117dc923bbe649e78c (diff)
downloadopenvswitch-1ca0323e7c29dc7ef5a615c265df0460208f92de.tar.gz
Require Python 3 and remove support for Python 2.
Python 2 reaches end-of-life on January 1, 2020, which is only a few months away. This means that OVS needs to stop depending on in the next release that should occur roughly that same time. Therefore, this commit removes all support for Python 2. It also makes Python 3 a mandatory build dependency. Some of the interesting consequences: - HAVE_PYTHON, HAVE_PYTHON2, and HAVE_PYTHON3 conditionals have been removed, since we now know that Python3 is available. - $PYTHON and $PYTHON2 are removed, and $PYTHON3 is always available. - Many tests for Python 2 support have been removed, and the ones that depended on Python 3 now run unconditionally. This allowed several macros in the testsuite to be removed, making the code clearer. This does make some of the changes to the testsuite files large due to indentation level changes. - #! lines for Python now use /usr/bin/python3 instead of /usr/bin/python. - Packaging depends on Python 3 packages. Acked-by: Numan Siddique <nusiddiq@redhat.com> Tested-by: Numan Siddique <nusiddiq@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'm4')
-rw-r--r--m4/openvswitch.m499
1 files changed, 18 insertions, 81 deletions
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index ba912e587..78d70fb4e 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -354,57 +354,16 @@ dnl Checks for valgrind/valgrind.h.
AC_DEFUN([OVS_CHECK_VALGRIND],
[AC_CHECK_HEADERS([valgrind/valgrind.h])])
-dnl Checks for Python 2.x, x >= 7.
-AC_DEFUN([OVS_CHECK_PYTHON2],
- [AC_CACHE_CHECK(
- [for Python 2.x for x >= 7],
- [ovs_cv_python2],
- [if test -n "$PYTHON2"; then
- ovs_cv_python2=$PYTHON2
- else
- ovs_cv_python2=no
- for binary in python2 python2.7 python; do
- ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
- for dir in $PATH; do
- IFS=$ovs_save_IFS
- test -z "$dir" && dir=.
- if test -x "$dir"/"$binary" && "$dir"/"$binary" -c 'import sys
-if sys.hexversion >= 0x02070000 and sys.hexversion < 0x03000000:
- sys.exit(0)
-else:
- sys.exit(1)'; then
- ovs_cv_python2=$dir/$binary
- break 2
- fi
- done
- done
- if test "$ovs_cv_python2" != no && test -x "$ovs_cv_python2"; then
- if ! "$ovs_cv_python2" -c 'import six ; six.moves.range' >&AS_MESSAGE_LOG_FD 2>&1; then
- ovs_cv_python2=no
- AC_MSG_WARN([Missing Python six library or version too old.])
- fi
- fi
- fi])
- AC_SUBST([HAVE_PYTHON2])
- AM_MISSING_PROG([PYTHON2], [python2])
- if test "$ovs_cv_python2" != no; then
- PYTHON2=$ovs_cv_python2
- HAVE_PYTHON2=yes
- else
- HAVE_PYTHON2=no
- fi
- AM_CONDITIONAL([HAVE_PYTHON2], [test "$HAVE_PYTHON2" = yes])])
-
-dnl Checks for Python 3.x, x >= 4.
+dnl Checks for Python 3.4 or later.
AC_DEFUN([OVS_CHECK_PYTHON3],
[AC_CACHE_CHECK(
- [for Python 3.x for x >= 4],
+ [for Python 3 (version 3.4 or later)],
[ovs_cv_python3],
[if test -n "$PYTHON3"; then
ovs_cv_python3=$PYTHON3
else
ovs_cv_python3=no
- for binary in python3 python3.4; do
+ for binary in python3 python3.4 python3.5 python3.6 python3.7; do
ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for dir in $PATH; do
IFS=$ovs_save_IFS
@@ -419,46 +378,24 @@ else:
fi
done
done
- if test "$ovs_cv_python3" != no; then
- if test -x "$ovs_cv_python3" && ! "$ovs_cv_python3" -c 'import six' >/dev/null 2>&1; then
- ovs_cv_python3=no
- AC_MSG_WARN([Missing Python six library.])
- fi
- fi
fi])
- AC_SUBST([HAVE_PYTHON3])
- AM_MISSING_PROG([PYTHON3], [python3])
- if test "$ovs_cv_python3" != no; then
- PYTHON3=$ovs_cv_python3
- HAVE_PYTHON3=yes
- else
- HAVE_PYTHON3=no
+ if test "$ovs_cv_python3" = no; then
+ AC_MSG_ERROR([Python 3.4 or later is required but not found in $PATH, please install it or set $PYTHON3 to point to it])
fi
- AM_CONDITIONAL([HAVE_PYTHON3], [test "$HAVE_PYTHON3" = yes])])
-
-dnl Checks if you have any compatible Python version installed.
-dnl Python 2.7+ has the preference to 3.4+
-AC_DEFUN([OVS_CHECK_PYTHON],
- [AC_CACHE_CHECK(
- [for Python 2 or 3],
- [ovs_cv_python],
- [if test -n "$PYTHON"; then
- ovs_cv_python=$PYTHON
+ AC_ARG_VAR([PYTHON3])
+ PYTHON3=$ovs_cv_python3])
+
+dnl Checks for python six library.
+AC_DEFUN([OVS_CHECK_SIX],
+ [AC_REQUIRE([OVS_CHECK_PYTHON3])
+ AC_CACHE_CHECK(
+ [where Python six library is available],
+ [ovs_cv_six],
+ [if $PYTHON3 -c 'import six' >/dev/null 2>&1; then
+ ovs_cv_six=yes
else
- ovs_cv_python=no
- if test "$ovs_cv_python2" != no; then
- ovs_cv_python=$ovs_cv_python2
- elif test "$ovs_cv_python3" != no; then
- ovs_cv_python=$ovs_cv_python3
- else
- AC_MSG_ERROR([Missing Python.])
- fi
- fi])
- AC_SUBST([PYTHON])
- PYTHON=$ovs_cv_python
- AC_SUBST([HAVE_PYTHON])
- HAVE_PYTHON=yes
- AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])])
+ AC_MSG_ERROR([Missing Python six library.])
+ fi])])
dnl Checks for flake8.
AC_DEFUN([OVS_CHECK_FLAKE8],