[ovs-dev,3/3] Permit to build OVS with only Python3 installed

Message ID 63d20b886864534cfb98af0e3b24d48a34bdddaf.1527705975.git.tredaelli@redhat.com
State New
Headers show
Series
  • Permit to build OVS with only Python3 installed
Related show

Commit Message

Timothy Redaelli May 31, 2018, 2:52 p.m.
This commit renames HAVE_PYTHON to HAVE_PYTHON2 and PYTHON to PYTHON2
and adds HAVE_PYTHON and PYTHON with a different semantics:
- If PYTHON environment variable is set, use it as PYTHON
- If a python2 interpreter is available, PYTHON became the python2 interpreter
- If a python3 interpreter is available, PYTHON became the python3 interpreter

PYTHON is only used to run the python scripts needed by the build system

NOTE:
Since currently most of the utilities and bugtool doesn't support Python3,
they're installed only if python2 is available. This will be fixed in later
commits.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
 configure.ac                      |  3 +-
 m4/openvswitch.m4                 | 55 ++++++++++++++++++++++---------
 ovn/utilities/bugtool/automake.mk |  2 +-
 tests/atlocal.in                  |  5 +++
 tests/daemon-py.at                | 18 +++++-----
 tests/json.at                     | 18 +++++-----
 tests/jsonrpc-py.at               |  6 ++--
 tests/library.at                  |  4 +--
 tests/ovsdb-idl.at                | 20 +++++------
 tests/ovsdb.at                    |  8 ++---
 tests/reconnect.at                |  4 +--
 tests/system-kmod-macros.at       |  2 +-
 tests/system-userspace-macros.at  |  2 +-
 tests/unixctl-py.at               | 13 ++++----
 tests/vlog.at                     | 14 ++++----
 utilities/automake.mk             |  6 ++--
 utilities/bugtool/automake.mk     |  2 +-
 17 files changed, 105 insertions(+), 77 deletions(-)

Patch

diff --git a/configure.ac b/configure.ac
index f0e4b5127..a3fb29588 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,8 +90,9 @@  OVS_CHECK_NETLINK
 OVS_CHECK_OPENSSL
 OVS_CHECK_LIBCAPNG
 OVS_CHECK_LOGDIR
-OVS_CHECK_PYTHON
+OVS_CHECK_PYTHON2
 OVS_CHECK_PYTHON3
+OVS_CHECK_PYTHON
 OVS_CHECK_FLAKE8
 OVS_CHECK_SPHINX
 OVS_CHECK_DOT
diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index f05b65c58..6db15b4f2 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -348,14 +348,14 @@  AC_DEFUN([OVS_CHECK_VALGRIND],
   [AC_CHECK_HEADERS([valgrind/valgrind.h])])
 
 dnl Checks for Python 2.x, x >= 7.
-AC_DEFUN([OVS_CHECK_PYTHON],
+AC_DEFUN([OVS_CHECK_PYTHON2],
   [AC_CACHE_CHECK(
      [for Python 2.x for x >= 7],
-     [ovs_cv_python],
-     [if test -n "$PYTHON"; then
-        ovs_cv_python=$PYTHON
+     [ovs_cv_python2],
+     [if test -n "$PYTHON2"; then
+        ovs_cv_python2=$PYTHON2
       else
-        ovs_cv_python=no
+        ovs_cv_python2=no
         for binary in python2 python2.7 python; do
           ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
           for dir in $PATH; do
@@ -366,27 +366,27 @@  if sys.hexversion >= 0x02070000 and sys.hexversion < 0x03000000:
     sys.exit(0)
 else:
     sys.exit(1)'; then
-              ovs_cv_python=$dir/$binary
+              ovs_cv_python2=$dir/$binary
               break 2
             fi
           done
         done
-        if test $ovs_cv_python != no && test -x "$ovs_cv_python"; then
-          if ! "$ovs_cv_python" -c 'import six ; six.moves.range' >&AS_MESSAGE_LOG_FD 2>&1; then
-            ovs_cv_python=no
+        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_PYTHON])
-   AM_MISSING_PROG([PYTHON], [python])
-   if test $ovs_cv_python != no; then
-     PYTHON=$ovs_cv_python
-     HAVE_PYTHON=yes
+   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_PYTHON=no
+     HAVE_PYTHON2=no
    fi
-   AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])])
+   AM_CONDITIONAL([HAVE_PYTHON2], [test "$HAVE_PYTHON2" = yes])])
 
 dnl Checks for Python 3.x, x >= 4.
 AC_DEFUN([OVS_CHECK_PYTHON3],
@@ -429,6 +429,29 @@  else:
    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
+      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])])
 
 dnl Checks for flake8.
 AC_DEFUN([OVS_CHECK_FLAKE8],
diff --git a/ovn/utilities/bugtool/automake.mk b/ovn/utilities/bugtool/automake.mk
index f6121fc9a..8582074a7 100644
--- a/ovn/utilities/bugtool/automake.mk
+++ b/ovn/utilities/bugtool/automake.mk
@@ -1,4 +1,4 @@ 
-if HAVE_PYTHON
+if HAVE_PYTHON2
 bugtool_plugins += \
 	ovn/utilities/bugtool/plugins/network-status/ovn.xml
 
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 4e626266b..45dc14711 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -1,6 +1,7 @@ 
 # -*- shell-script -*-
 HAVE_OPENSSL='@HAVE_OPENSSL@'
 HAVE_PYTHON='@HAVE_PYTHON@'
+HAVE_PYTHON2='@HAVE_PYTHON2@'
 HAVE_PYTHON3='@HAVE_PYTHON3@'
 EGREP='@EGREP@'
 
@@ -8,6 +9,10 @@  if test x"$PYTHON" = x; then
     PYTHON='@PYTHON@'
 fi
 
+if test x"$PYTHON2" = x; then
+    PYTHON2='@PYTHON2@'
+fi
+
 if test x"$PYTHON3" = x; then
     PYTHON3='@PYTHON3@'
 
diff --git a/tests/daemon-py.at b/tests/daemon-py.at
index d0e65ad61..82852383b 100644
--- a/tests/daemon-py.at
+++ b/tests/daemon-py.at
@@ -22,7 +22,7 @@  m4_define([DAEMON_PYN],
    AT_CHECK([test ! -e pid])
    AT_CLEANUP])
 
-DAEMON_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+DAEMON_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 DAEMON_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([DAEMON_MONITOR_PYN],
@@ -66,7 +66,7 @@  m4_define([DAEMON_MONITOR_PYN],
    OVS_WAIT_WHILE([kill -0 `cat parent` || kill -0 `cat newpid` || test -e pid])
    AT_CLEANUP])
 
-DAEMON_MONITOR_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+DAEMON_MONITOR_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 DAEMON_MONITOR_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([DAEMON_MONITOR_RESTART_PYN],
@@ -110,7 +110,7 @@  m4_define([DAEMON_MONITOR_RESTART_PYN],
    OVS_WAIT_WHILE([kill -0 `cat parent` || kill -0 `cat newpid` || test -e pid])
    AT_CLEANUP])
 
-DAEMON_MONITOR_RESTART_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+DAEMON_MONITOR_RESTART_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 DAEMON_MONITOR_RESTART_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([DAEMON_DETACH_PYN],
@@ -132,7 +132,7 @@  m4_define([DAEMON_DETACH_PYN],
    AT_CHECK([test ! -e pid])
    AT_CLEANUP])
 
-DAEMON_DETACH_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+DAEMON_DETACH_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 DAEMON_DETACH_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([DAEMON_DETACH_MONITOR_PYN],
@@ -183,7 +183,7 @@  m4_define([DAEMON_DETACH_MONITOR_PYN],
      [kill -0 `cat monitor` || kill -0 `cat newdaemon` || test -e daemon])
    AT_CLEANUP])
 
-DAEMON_DETACH_MONITOR_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+DAEMON_DETACH_MONITOR_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 DAEMON_DETACH_MONITOR_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([DAEMON_DETACH_ERRORS_PYN],
@@ -196,7 +196,7 @@  m4_define([DAEMON_DETACH_ERRORS_PYN],
    AT_CHECK([test ! -s pid])
    AT_CLEANUP])
 
-DAEMON_DETACH_ERRORS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+DAEMON_DETACH_ERRORS_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 DAEMON_DETACH_ERRORS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([DAEMON_DETACH_MONITOR_ERRORS_PYN],
@@ -209,7 +209,7 @@  m4_define([DAEMON_DETACH_MONITOR_ERRORS_PYN],
    AT_CHECK([test ! -s pid])
    AT_CLEANUP])
 
-DAEMON_DETACH_MONITOR_ERRORS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+DAEMON_DETACH_MONITOR_ERRORS_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 DAEMON_DETACH_MONITOR_ERRORS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([DAEMON_DETACH_CLOSES_FDS_PYN],
@@ -235,7 +235,7 @@  m4_define([DAEMON_DETACH_CLOSES_FDS_PYN],
    fi
    AT_CLEANUP])
 
-DAEMON_DETACH_CLOSES_FDS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+DAEMON_DETACH_CLOSES_FDS_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 DAEMON_DETACH_CLOSES_FDS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([DAEMON_DETACH_MONITOR_CLOSES_FDS_PYN],
@@ -262,5 +262,5 @@  m4_define([DAEMON_DETACH_MONITOR_CLOSES_FDS_PYN],
    fi
    AT_CLEANUP])
 
-DAEMON_DETACH_MONITOR_CLOSES_FDS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+DAEMON_DETACH_MONITOR_CLOSES_FDS_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 DAEMON_DETACH_MONITOR_CLOSES_FDS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
diff --git a/tests/json.at b/tests/json.at
index 325ac9435..cf8d35339 100644
--- a/tests/json.at
+++ b/tests/json.at
@@ -25,12 +25,12 @@  m4_define([JSON_CHECK_POSITIVE_PY],
 m4_define([JSON_CHECK_POSITIVE_UCS4PY],
   [AT_SETUP([$1])
    AT_KEYWORDS([json positive Python])
-   AT_SKIP_IF([test $HAVE_PYTHON = no])
-   AT_XFAIL_IF([test $HAVE_PYTHON = yes &&
-                $PYTHON -c "exit(len(u'\U00010800'))"; test $? -ne 1])
+   AT_SKIP_IF([test $HAVE_PYTHON2 = no])
+   AT_XFAIL_IF([test $HAVE_PYTHON2 = yes &&
+                $PYTHON2 -c "exit(len(u'\U00010800'))"; test $? -ne 1])
    AT_CHECK([printf %s "AS_ESCAPE([$2])" > input])
    AT_CAPTURE_FILE([input])
-   AT_CHECK([$PYTHON $srcdir/test-json.py $4 input], [0], [stdout], [])
+   AT_CHECK([$PYTHON2 $srcdir/test-json.py $4 input], [0], [stdout], [])
    AT_CHECK([cat stdout], [0], [$3
 ])
    AT_CLEANUP])
@@ -38,13 +38,13 @@  m4_define([JSON_CHECK_POSITIVE_UCS4PY],
 m4_define([JSON_CHECK_POSITIVE],
   [JSON_CHECK_POSITIVE_C([$1 - C], [$2], [$3], [$4])
    JSON_CHECK_POSITIVE_PY([$1 - Python2], [$2], [$3], [$4],
-                          [$HAVE_PYTHON], [$PYTHON])
+                          [$HAVE_PYTHON2], [$PYTHON2])
    JSON_CHECK_POSITIVE_PY([$1 - Python3], [$2], [$3], [$4],
                           [$HAVE_PYTHON3], [$PYTHON3])])
 
 m4_define([JSON_CHECK_POSITIVE_PY23],
   [JSON_CHECK_POSITIVE_PY([$1 - Python2], [$2], [$3], [$4],
-                          [$HAVE_PYTHON], [$PYTHON])
+                          [$HAVE_PYTHON2], [$PYTHON2])
    JSON_CHECK_POSITIVE_PY([$1 - Python3], [$2], [$3], [$4],
                           [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -75,7 +75,7 @@  m4_define([JSON_CHECK_NEGATIVE_PY],
 m4_define([JSON_CHECK_NEGATIVE],
   [JSON_CHECK_NEGATIVE_C([$1 - C], [$2], [$3], [$4])
    JSON_CHECK_NEGATIVE_PY([$1 - Python2], [$2], [$3], [$4],
-                          [$HAVE_PYTHON], [$PYTHON])
+                          [$HAVE_PYTHON2], [$PYTHON2])
    JSON_CHECK_NEGATIVE_PY([$1 - Python3], [$2], [$3], [$4],
                           [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -156,9 +156,9 @@  AT_CLEANUP
 
 AT_SETUP([end of input in quoted string - Python])
 AT_KEYWORDS([json negative Python])
-AT_SKIP_IF([test $HAVE_PYTHON = no])
+AT_SKIP_IF([test $HAVE_PYTHON2 = no])
 AT_CHECK([printf '"xxx' > input
-$PYTHON $srcdir/test-json.py input], [1],
+$PYTHON2 $srcdir/test-json.py input], [1],
   [error: line 0, column 4, byte 4: unexpected end of input in quoted string
 ])
 AT_CLEANUP
diff --git a/tests/jsonrpc-py.at b/tests/jsonrpc-py.at
index f907a5d02..977b029c1 100644
--- a/tests/jsonrpc-py.at
+++ b/tests/jsonrpc-py.at
@@ -12,7 +12,7 @@  m4_define([JSONRPC_REQ_REPLY_SUCCESS_PYN],
 ]])
    AT_CLEANUP])
 
-JSONRPC_REQ_REPLY_SUCCESS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+JSONRPC_REQ_REPLY_SUCCESS_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 JSONRPC_REQ_REPLY_SUCCESS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([JSONRPC_REQ_REPLY_ERROR_PYN],
@@ -27,7 +27,7 @@  m4_define([JSONRPC_REQ_REPLY_ERROR_PYN],
 ]])
    AT_CLEANUP])
 
-JSONRPC_REQ_REPLY_ERROR_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+JSONRPC_REQ_REPLY_ERROR_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 JSONRPC_REQ_REPLY_ERROR_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([JSONRPC_NOTIFICATION_PYN],
@@ -42,5 +42,5 @@  m4_define([JSONRPC_NOTIFICATION_PYN],
    OVS_WAIT_WHILE([test -e test-jsonrpc.py.pid])
    AT_CLEANUP])
 
-JSONRPC_NOTIFICATION_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+JSONRPC_NOTIFICATION_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 JSONRPC_NOTIFICATION_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
diff --git a/tests/library.at b/tests/library.at
index 99541b0c9..a30d362e3 100644
--- a/tests/library.at
+++ b/tests/library.at
@@ -183,7 +183,7 @@  m4_define([UNIX_SOCKET_SHORT_PATHNAME_PYN],
    AT_CHECK([$3 $srcdir/test-unix-socket.py x])
    AT_CLEANUP])
 
-UNIX_SOCKET_SHORT_PATHNAME_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+UNIX_SOCKET_SHORT_PATHNAME_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 UNIX_SOCKET_SHORT_PATHNAME_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 dnl Unix sockets with long names are problematic because the name has to
@@ -205,7 +205,7 @@  m4_define([UNIX_SOCKET_LONG_PATHNAME_PYN],
    AT_CHECK([cd $longname && $3 $abs_srcdir/test-unix-socket.py ../$longname/socket socket])
    AT_CLEANUP])
 
-UNIX_SOCKET_LONG_PATHNAME_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+UNIX_SOCKET_LONG_PATHNAME_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 UNIX_SOCKET_LONG_PATHNAME_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 AT_SETUP([ovs_assert])
diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index 9caa02aad..484f359c7 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -59,7 +59,7 @@  m4_define([OVSDB_CHECK_IDL_PYN],
 
 m4_define([OVSDB_CHECK_IDL_PY],
    [OVSDB_CHECK_IDL_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
-                        [$HAVE_PYTHON], [$PYTHON])
+                        [$HAVE_PYTHON2], [$PYTHON2])
     OVSDB_CHECK_IDL_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
                         [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -79,7 +79,7 @@  m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PYN],
 
 m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PY],
    [OVSDB_CHECK_IDL_REGISTER_COLUMNS_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
-                        [$HAVE_PYTHON], [$PYTHON])
+                        [$HAVE_PYTHON2], [$PYTHON2])
     OVSDB_CHECK_IDL_REGISTER_COLUMNS_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
                         [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -102,7 +102,7 @@  m4_define([OVSDB_CHECK_IDL_TCP_PYN],
 
 m4_define([OVSDB_CHECK_IDL_TCP_PY],
    [OVSDB_CHECK_IDL_TCP_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
-                        [$HAVE_PYTHON], [$PYTHON])
+                        [$HAVE_PYTHON2], [$PYTHON2])
     OVSDB_CHECK_IDL_TCP_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
                         [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -128,7 +128,7 @@  m4_define([OVSDB_CHECK_IDL_TCP6_PYN],
 
 m4_define([OVSDB_CHECK_IDL_TCP6_PY],
    [OVSDB_CHECK_IDL_TCP6_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
-                        [$HAVE_PYTHON], [$PYTHON])
+                        [$HAVE_PYTHON2], [$PYTHON2])
     OVSDB_CHECK_IDL_TCP6_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
                         [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -204,7 +204,7 @@  m4_define([OVSDB_CHECK_IDL_PASSIVE_TCP_PYN],
 
 m4_define([OVSDB_CHECK_IDL_PASSIVE_TCP_PY],
     [OVSDB_CHECK_IDL_PASSIVE_TCP_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
-                        [$HAVE_PYTHON], [$PYTHON])
+                        [$HAVE_PYTHON2], [$PYTHON2])
     OVSDB_CHECK_IDL_PASSIVE_TCP_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
                         [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -393,7 +393,7 @@  m4_define([OVSDB_CHECK_IDL_PYN_WITH_EXPOUT],
 
 m4_define([OVSDB_CHECK_IDL_PY_WITH_EXPOUT],
    [OVSDB_CHECK_IDL_PYN_WITH_EXPOUT([$1 - Python2], [$2], [$3], [$4], [$5], [$6],
-                                    [$HAVE_PYTHON], [$PYTHON])
+                                    [$HAVE_PYTHON2], [$PYTHON2])
     OVSDB_CHECK_IDL_PYN_WITH_EXPOUT([$1 - Python3], [$2], [$3], [$4], [$5], [$6],
                                     [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -900,7 +900,7 @@  m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS_PYN],
 
 m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS_PY],
     [OVSDB_CHECK_IDL_FETCH_COLUMNS_PYN([$1 - Python2], [$2], [$3], [$4], [$5], [$6], [$7],
-                        [$HAVE_PYTHON], [$PYTHON])
+                        [$HAVE_PYTHON2], [$PYTHON2])
     OVSDB_CHECK_IDL_FETCH_COLUMNS_PYN([$1 - Python3], [$2], [$3], [$4], [$5], [$6], [$7],
                         [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -950,7 +950,7 @@  m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND_PYN],
 
 m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND_PY],
     [OVSDB_CHECK_IDL_WO_MONITOR_COND_PYN([$1 - Python2], [$2], [$3], [$4], [$5],
-                        [$HAVE_PYTHON], [$PYTHON])
+                        [$HAVE_PYTHON2], [$PYTHON2])
     OVSDB_CHECK_IDL_WO_MONITOR_COND_PYN([$1 - Python3], [$2], [$3], [$4], [$5],
                         [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -1279,7 +1279,7 @@  m4_define([OVSDB_CHECK_IDL_NOTIFY_PYN],
 
 m4_define([OVSDB_CHECK_IDL_NOTIFY_PY],
     [OVSDB_CHECK_IDL_NOTIFY_PYN([$1 - Python2], [$2], [$3], [$4], [$5],
-                        [$HAVE_PYTHON], [$PYTHON])
+                        [$HAVE_PYTHON2], [$PYTHON2])
     OVSDB_CHECK_IDL_NOTIFY_PYN([$1 - Python3], [$2], [$3], [$4], [$5],
                         [$HAVE_PYTHON3], [$PYTHON3])])
 
@@ -1289,7 +1289,7 @@  m4_define([OVSDB_CHECK_IDL_NOTIFY_SSL_PYN],
 
 m4_define([OVSDB_CHECK_IDL_NOTIFY_SSL_PY],
     [OVSDB_CHECK_IDL_NOTIFY_SSL_PYN([$1 - Python2], [$2], [$3], [$4], [$5],
-                        [$HAVE_PYTHON], [$PYTHON])
+                        [$HAVE_PYTHON2], [$PYTHON2])
     OVSDB_CHECK_IDL_NOTIFY_SSL_PYN([$1 - Python3], [$2], [$3], [$4], [$5],
                         [$HAVE_PYTHON3], [$PYTHON3])])
 
diff --git a/tests/ovsdb.at b/tests/ovsdb.at
index f109b79b6..afe0a54a4 100644
--- a/tests/ovsdb.at
+++ b/tests/ovsdb.at
@@ -23,10 +23,10 @@  m4_define([OVSDB_CHECK_POSITIVE],
 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
 m4_define([OVSDB_CHECK_POSITIVE_PY], 
   [AT_SETUP([$1])
-   AT_SKIP_IF([test $HAVE_PYTHON = no])
+   AT_SKIP_IF([test $HAVE_PYTHON2 = no])
    $6
    AT_KEYWORDS([ovsdb positive Python $4])
-   AT_CHECK([$PYTHON $srcdir/test-ovsdb.py $2], [0], [$3
+   AT_CHECK([$PYTHON2 $srcdir/test-ovsdb.py $2], [0], [$3
 ], [])
    AT_CLEANUP])
 
@@ -85,9 +85,9 @@  m4_define([OVSDB_CHECK_NEGATIVE],
 # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS.
 m4_define([OVSDB_CHECK_NEGATIVE_PY],
   [AT_SETUP([$1])
-   AT_SKIP_IF([test $HAVE_PYTHON = no])
+   AT_SKIP_IF([test $HAVE_PYTHON2 = no])
    AT_KEYWORDS([ovsdb negative $4])
-   AT_CHECK([$PYTHON $srcdir/test-ovsdb.py $2], [1], [], [stderr])
+   AT_CHECK([$PYTHON2 $srcdir/test-ovsdb.py $2], [1], [], [stderr])
    m4_assert(m4_len([$3]))
    AT_CHECK(
      [if grep -F -e "AS_ESCAPE([$3])" stderr
diff --git a/tests/reconnect.at b/tests/reconnect.at
index 59c95d95b..ecd76cbc5 100644
--- a/tests/reconnect.at
+++ b/tests/reconnect.at
@@ -17,9 +17,9 @@  m4_define([RECONNECT_CHECK],
      [$3])
    __RECONNECT_CHECK(
      [$1 - Python2],
-     [AT_SKIP_IF([test $HAVE_PYTHON = no])],
+     [AT_SKIP_IF([test $HAVE_PYTHON2 = no])],
      [$2],
-     [$PYTHON $srcdir/test-reconnect.py < input],
+     [$PYTHON2 $srcdir/test-reconnect.py < input],
      [$3])
    __RECONNECT_CHECK(
      [$1 - Python3],
diff --git a/tests/system-kmod-macros.at b/tests/system-kmod-macros.at
index 2b9b69140..51cbcb1fc 100644
--- a/tests/system-kmod-macros.at
+++ b/tests/system-kmod-macros.at
@@ -59,7 +59,7 @@  m4_define([CONFIGURE_VETH_OFFLOADS],
 # kernel conntrack tables when the test is finished.
 #
 m4_define([CHECK_CONNTRACK],
-    [AT_SKIP_IF([test $HAVE_PYTHON = no])
+    [AT_SKIP_IF([test $HAVE_PYTHON2 = no])
      m4_foreach([mod], [[nf_conntrack_ipv4], [nf_conntrack_ipv6], [nf_nat_ftp],
                         [nf_nat_tftp]],
                 [modprobe mod || echo "Module mod not loaded."
diff --git a/tests/system-userspace-macros.at b/tests/system-userspace-macros.at
index 00e1f817f..ec6ee5a93 100644
--- a/tests/system-userspace-macros.at
+++ b/tests/system-userspace-macros.at
@@ -63,7 +63,7 @@  m4_define([CONFIGURE_VETH_OFFLOADS],
 # Perform requirements checks for running conntrack tests.
 #
 m4_define([CHECK_CONNTRACK],
-    [AT_SKIP_IF([test $HAVE_PYTHON = no])]
+    [AT_SKIP_IF([test $HAVE_PYTHON2 = no])]
 )
 
 # CHECK_CONNTRACK_ALG()
diff --git a/tests/unixctl-py.at b/tests/unixctl-py.at
index 20318977f..443aaab6e 100644
--- a/tests/unixctl-py.at
+++ b/tests/unixctl-py.at
@@ -1,7 +1,6 @@ 
 AT_BANNER([unixctl])
 
 m4_define([APPCTL], [ovs-appctl --timeout 20])
-m4_define([PYAPPCTL], [$PYTHON $srcdir/appctl.py --timeout 20])
 m4_define([PYAPPCTL_PYN], [$1 $srcdir/appctl.py --timeout 20])
 
 m4_define([UNIXCTL_EXIT_PYN],
@@ -17,7 +16,7 @@  m4_define([UNIXCTL_EXIT_PYN],
    OVS_WAIT_WHILE([test -s ovsdb-server.pid])
    AT_CLEANUP])
 
-UNIXCTL_EXIT_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+UNIXCTL_EXIT_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 UNIXCTL_EXIT_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([UNIXCTL_LIST_COMMANDS_PYN],
@@ -35,7 +34,7 @@  The available commands are:
    OVS_VSWITCHD_STOP
    AT_CLEANUP])
 
-UNIXCTL_LIST_COMMANDS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+UNIXCTL_LIST_COMMANDS_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 UNIXCTL_LIST_COMMANDS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([UNIXCTL_ARGS_PYN],
@@ -81,7 +80,7 @@  invalid vlan
    OVS_VSWITCHD_STOP
    AT_CLEANUP])
 
-UNIXCTL_ARGS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+UNIXCTL_ARGS_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 UNIXCTL_ARGS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([UNIXCTL_BAD_TARGET_PYN],
@@ -106,7 +105,7 @@  appctl.py: cannot connect to "c:/bogus/path.pid" (No such file or directory)
 
    AT_CLEANUP])
 
-UNIXCTL_BAD_TARGET_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+UNIXCTL_BAD_TARGET_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 UNIXCTL_BAD_TARGET_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([UNIXCTL_SERVER_PYN],
@@ -180,7 +179,7 @@  ovs-appctl: test-unixctl.py: server returned an error
    AT_CHECK([APPCTL -t test-unixctl.py exit])
    AT_CLEANUP])
 
-UNIXCTL_SERVER_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+UNIXCTL_SERVER_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 UNIXCTL_SERVER_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_define([UNIXCTL_SERVER_ERRORS_PYN],
@@ -189,5 +188,5 @@  m4_define([UNIXCTL_SERVER_ERRORS_PYN],
    AT_CHECK($3 $srcdir/test-unixctl.py --unixctl "`pwd`"/bogus/path, [1], [], [ignore])
    AT_CLEANUP])
 
-UNIXCTL_SERVER_ERRORS_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+UNIXCTL_SERVER_ERRORS_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 UNIXCTL_SERVER_ERRORS_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
diff --git a/tests/vlog.at b/tests/vlog.at
index a6898095e..aee6d468e 100644
--- a/tests/vlog.at
+++ b/tests/vlog.at
@@ -102,7 +102,7 @@  AssertionError
 
    AT_CLEANUP])
 
-VLOG_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+VLOG_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 VLOG_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 m4_divert_push([PREPARE_TESTS])
@@ -175,7 +175,7 @@  m4_define([VLOG_REOPEN_PYN],
 ])
    AT_CLEANUP])
 
-VLOG_REOPEN_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+VLOG_REOPEN_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 VLOG_REOPEN_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 AT_SETUP([vlog - vlog/reopen without log file - C])
@@ -202,7 +202,7 @@  m4_define([VLOG_REOPEN_WITHOUT_FILE_PYN],
 ])
    AT_CLEANUP])
 
-VLOG_REOPEN_WITHOUT_FILE_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+VLOG_REOPEN_WITHOUT_FILE_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 VLOG_REOPEN_WITHOUT_FILE_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 dnl This checks that if vlog/reopen can't reopen the log file,
@@ -272,7 +272,7 @@  m4_define([VLOG_CANT_REOPEN_PYN],
 ])
    AT_CLEANUP])
 
-VLOG_CANT_REOPEN_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+VLOG_CANT_REOPEN_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 VLOG_CANT_REOPEN_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 AT_SETUP([vlog - vlog/close - C])
@@ -351,7 +351,7 @@  m4_define([VLOG_CLOSE_PYN],
 ])
    AT_CLEANUP])
 
-VLOG_CLOSE_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+VLOG_CLOSE_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 VLOG_CLOSE_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 AT_SETUP([vlog - vlog/set and vlog/list - C])
@@ -452,7 +452,7 @@  unixctl_server    info       info        dbg
    AT_CHECK([grep -q 'I<3OVS' log])
    AT_CLEANUP])
 
-VLOG_SET_AND_LIST_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+VLOG_SET_AND_LIST_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 VLOG_SET_AND_LIST_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
 
 AT_SETUP([vlog - RFC5424 facility])
@@ -511,5 +511,5 @@  m4_define([VLOG_RFC5424_PYN],
    AT_CHECK([ovs-appctl -t test-unixctl.py vlog/set FACILITY:local0])
    AT_CLEANUP])
 
-VLOG_RFC5424_PYN([Python2], [$HAVE_PYTHON], [$PYTHON])
+VLOG_RFC5424_PYN([Python2], [$HAVE_PYTHON2], [$PYTHON2])
 VLOG_RFC5424_PYN([Python3], [$HAVE_PYTHON3], [$PYTHON3])
diff --git a/utilities/automake.mk b/utilities/automake.mk
index eb4fd6faa..d2cbe21a7 100644
--- a/utilities/automake.mk
+++ b/utilities/automake.mk
@@ -5,13 +5,13 @@  bin_PROGRAMS += \
 	utilities/ovs-ofctl \
 	utilities/ovs-vsctl
 bin_SCRIPTS += utilities/ovs-docker \
-	utilities/ovs-pki
-if HAVE_PYTHON
+	utilities/ovs-pki \
+	utilities/ovs-pcap
+if HAVE_PYTHON2
 bin_SCRIPTS += \
 	utilities/ovs-dpctl-top \
 	utilities/ovs-l3ping \
 	utilities/ovs-parse-backtrace \
-	utilities/ovs-pcap \
 	utilities/ovs-tcpdump \
 	utilities/ovs-tcpundump \
 	utilities/ovs-test \
diff --git a/utilities/bugtool/automake.mk b/utilities/bugtool/automake.mk
index 0c93c0ccf..18fa3478e 100644
--- a/utilities/bugtool/automake.mk
+++ b/utilities/bugtool/automake.mk
@@ -1,4 +1,4 @@ 
-if HAVE_PYTHON
+if HAVE_PYTHON2
 sbin_SCRIPTS += utilities/bugtool/ovs-bugtool
 CLEANFILES += utilities/bugtool/ovs-bugtool