Skip to content

Commit

Permalink
Require Python 3 and remove support for Python 2.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Tested-by: Numan Siddique <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
blp committed Sep 27, 2019
1 parent 187bb41 commit 1ca0323
Show file tree
Hide file tree
Showing 79 changed files with 648 additions and 1,144 deletions.
3 changes: 1 addition & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ freebsd_build_task:

env:
DEPENDENCIES: automake libtool gmake gcc wget openssl
python py27-six py27-sphinx py27-openssl
python3 py36-six py36-openssl
python3 py36-six py36-openssl p36-sphinx
matrix:
COMPILER: gcc
COMPILER: clang
Expand Down
4 changes: 2 additions & 2 deletions .travis/osx-prepare.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
set -ev
pip2 install --user six
pip2 install --user --upgrade docutils
pip3 install --user six
pip3 install --user --upgrade docutils
4 changes: 2 additions & 2 deletions Documentation/intro/install/fedora.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ in which `./configure` was executed:

$ make rpm-fedora

This will create the RPMs `openvswitch`, `python-openvswitch`,
This will create the RPMs `openvswitch`, `python3-openvswitch`,
`openvswitch-test`, `openvswitch-devel` and `openvswitch-debuginfo`.

To enable DPDK support in the openvswitch package, the ``--with dpdk`` option
Expand Down Expand Up @@ -151,7 +151,7 @@ Refer to the :doc:`/faq/index` for more information about the various Open
vSwitch datapath options.

In most cases only the `openvswitch` RPM will need to be installed. The
`python-openvswitch`, `openvswitch-test`, `openvswitch-devel`, and
`python3-openvswitch`, `openvswitch-test`, `openvswitch-devel`, and
`openvswitch-debuginfo` RPMs are optional unless required for a specific
purpose.

Expand Down
8 changes: 4 additions & 4 deletions Documentation/intro/install/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ need the following software:
If libcap-ng is installed, then Open vSwitch will automatically build with
support for it.

- Python 2.7. You must also have the Python ``six`` library version 1.4.0
or later.
- Python 3.4 or later. You must also have the Python ``six`` library
version 1.4.0 or later.

- Unbound library, from http://www.unbound.net, is optional but recommended if
you want to enable ovs-vswitchd and other utilities to use DNS names when
Expand Down Expand Up @@ -203,8 +203,8 @@ simply install and run Open vSwitch you require the following software:
from iproute2 (part of all major distributions and available at
https://wiki.linuxfoundation.org/networking/iproute2).

- Python 2.7. You must also have the Python six library version 1.4.0
or later.
- Python 3.4 or later. You must also have the Python six library
version 1.4.0 or later.

On Linux you should ensure that ``/dev/urandom`` exists. To support TAP
devices, you must also ensure that ``/dev/net/tun`` exists.
Expand Down
10 changes: 4 additions & 6 deletions Documentation/intro/install/netbsd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,18 @@ you need at least the following packages.
- automake
- libtool-base
- gmake
- python27
- py27-six
- py27-xml
- python37
- py37-six

Some components have additional requirements. Refer to :doc:`general` for more
information.

Assuming you are running NetBSD/amd64 6.1.2, you can download and install
Assuming you are running NetBSD/amd64 7.0.2, you can download and install
pre-built binary packages as the following::

$ PKG_PATH=http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/7.0.2/All/
$ export PKG_PATH
$ pkg_add automake libtool-base gmake python27 py27-six py27-xml \
pkg_alternatives
$ pkg_add automake libtool-base gmake python37 py37-six pkg_alternatives

.. note::
You might get some warnings about minor version mismatch. These can be safely
Expand Down
2 changes: 1 addition & 1 deletion Documentation/intro/install/rhel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Once that is completed, remove the file ``/tmp/ovs.spec``.
If python3-sphinx package is not available in your version of RHEL, you can
install it via pip with 'pip install sphinx'.

Open vSwitch requires python 2.7 or newer which is not available in older
Open vSwitch requires python 3.4 or newer which is not available in older
distributions. In the case of RHEL 6.x and its derivatives, one option is
to install python34 and python34-six from `EPEL`_.

Expand Down
4 changes: 2 additions & 2 deletions Documentation/intro/install/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ The following explains the steps in some detail.

'C:/MinGW /mingw'.

- Python
- Python 3.4 or later.

Install the latest Python 2.x from python.org and verify that its path is
Install the latest Python 3.x from python.org and verify that its path is
part of Windows' PATH environment variable.
We require that you have Python six and pypiwin32 libraries installed.
The libraries can be installed via pip command:
Expand Down
4 changes: 2 additions & 2 deletions Documentation/intro/install/xenserver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ XenServer host. If you want to install Open vSwitch on a generic Linux or BSD
host, refer to :doc:`general` instead.

Open vSwitch should work with XenServer 5.6.100 and later. However, Open
vSwitch requires Python 2.7 or later, so using Open vSwitch with XenServer 6.5
or earlier requires installing Python 2.7.
vSwitch requires Python 3.4 or later, so using Open vSwitch with XenServer 6.5
or earlier requires installing Python 3.x.

Building
--------
Expand Down
12 changes: 6 additions & 6 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ endif
# foo/__init__.pyc will cause Python to ignore foo.py.
run_python = \
PYTHONPATH=$(top_srcdir)/python$(psep)$$PYTHONPATH \
PYTHONDONTWRITEBYTECODE=yes $(PYTHON)
PYTHONDONTWRITEBYTECODE=yes $(PYTHON3)

ALL_LOCAL =
BUILT_SOURCES =
Expand Down Expand Up @@ -147,13 +147,13 @@ ro_shell = printf '\043 Generated automatically -- do not modify! -*- buffer-

SUFFIXES += .in
.in:
$(AM_V_GEN)PYTHONPATH=$$PYTHONPATH$(psep)$(srcdir)/python $(PYTHON) $(srcdir)/build-aux/soexpand.py -I$(srcdir) < $< | \
$(PYTHON) $(srcdir)/build-aux/dpdkstrip.py $(DPDKSTRIP_FLAGS) | \
$(AM_V_GEN)PYTHONPATH=$$PYTHONPATH$(psep)$(srcdir)/python $(PYTHON3) $(srcdir)/build-aux/soexpand.py -I$(srcdir) < $< | \
$(PYTHON3) $(srcdir)/build-aux/dpdkstrip.py $(DPDKSTRIP_FLAGS) | \
sed \
-e 's,[@]PKIDIR[@],$(PKIDIR),g' \
-e 's,[@]LOGDIR[@],$(LOGDIR),g' \
-e 's,[@]DBDIR[@],$(DBDIR),g' \
-e 's,[@]PYTHON[@],$(PYTHON),g' \
-e 's,[@]PYTHON3[@],$(PYTHON3),g' \
-e 's,[@]RUNDIR[@],$(RUNDIR),g' \
-e 's,[@]VERSION[@],$(VERSION),g' \
-e 's,[@]localstatedir[@],$(localstatedir),g' \
Expand All @@ -177,7 +177,7 @@ SUFFIXES += .xml
PKIDIR='$(PKIDIR)' \
LOGDIR='$(LOGDIR)' \
DBDIR='$(DBDIR)' \
PYTHON='$(PYTHON)' \
PYTHON3='$(PYTHON3)' \
RUNDIR='$(RUNDIR)' \
VERSION='$(VERSION)' \
localstatedir='$(localstatedir)' \
Expand Down Expand Up @@ -414,7 +414,7 @@ CLEANFILES += flake8-check

include $(srcdir)/manpages.mk
$(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.py python/build/soutil.py
@PYTHONPATH=$$PYTHONPATH$(psep)$(srcdir)/python $(PYTHON) $(srcdir)/build-aux/sodepends.py -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp
@PYTHONPATH=$$PYTHONPATH$(psep)$(srcdir)/python $(PYTHON3) $(srcdir)/build-aux/sodepends.py -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp
@if cmp -s $(@F).tmp $@; then \
touch $@; \
rm -f $(@F).tmp; \
Expand Down
24 changes: 14 additions & 10 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ Vagrant.require_version ">=1.7.0"
$bootstrap_fedora = <<SCRIPT
dnf -y update
dnf -y install autoconf automake openssl-devel libtool \
python-devel python3-devel \
python-twisted python-zope-interface \
python3-devel \
python3-twisted python3-zope-interface \
desktop-file-utils groff graphviz rpmdevtools nc curl \
wget python-six pyftpdlib checkpolicy selinux-policy-devel \
libcap-ng-devel kernel-devel-`uname -r` ethtool python-tftpy \
wget python3-six python3-pyftpdlib checkpolicy \
selinux-policy-devel \
libcap-ng-devel kernel-devel-`uname -r` ethtool python3-pip \
lftp
pip-3 install tftpy # Not yet available for Python3 via dnf.
echo "search extra update built-in" >/etc/depmod.d/search_path.conf
SCRIPT

Expand All @@ -24,21 +26,23 @@ aptitude -y install -R \
build-essential dpkg-dev lintian devscripts fakeroot \
debhelper dh-autoreconf uuid-runtime \
autoconf automake libtool \
python-all python-twisted-core python-twisted-conch \
python3-all python3-twisted-core python3-twisted-conch \
xdg-utils groff graphviz netcat curl \
wget python-six ethtool \
libcap-ng-dev libssl-dev python-dev openssl \
python-pyftpdlib python-flake8 python-tftpy \
wget python3-six ethtool \
libcap-ng-dev libssl-dev python3-dev openssl \
python3-pyftpdlib python3-flake8 \
linux-headers-`uname -r` \
lftp
pip-3 install tftpy # Not yet available for Python3 via apt.
SCRIPT

$bootstrap_centos = <<SCRIPT
yum -y update
yum -y install autoconf automake openssl-devel libtool \
python-twisted-core python-zope-interface \
python3-twisted-core python3-zope-interface \
desktop-file-utils groff graphviz rpmdevtools nc curl \
wget python-six pyftpdlib checkpolicy selinux-policy-devel \
wget python3-six python3-pyftpdlib checkpolicy \
selinux-policy-devel \
libcap-ng-devel kernel-devel-`uname -r` ethtool net-tools \
lftp
SCRIPT
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile-FreeBSD
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Vagrant.require_version ">=1.7.0"
$bootstrap_freebsd = <<SCRIPT
sed -e 's/\#DEFAULT_ALWAYS_YES = false/DEFAULT_ALWAYS_YES = true/g' -e 's/\#ASSUME_ALWAYS_YES = false/ASSUME_ALWAYS_YES = true/g' /usr/local/etc/pkg.conf > /tmp/pkg.conf
mv -f /tmp/pkg.conf /usr/local/etc/pkg.conf
pkg install automake libtool wget python py27-six gmake lftp
pkg install automake libtool wget py37 py37-six gmake lftp
SCRIPT

$configure_ovs = <<SCRIPT
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ init:
cd C:\openvswitch
python -m pip install six pypiwin32 --disable-pip-version-check
python3 -m pip install six pypiwin32 --disable-pip-version-check
build_script:
- '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd"'
Expand Down
2 changes: 1 addition & 1 deletion build-aux/check-structs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/python3

import os.path
import sys
Expand Down
2 changes: 1 addition & 1 deletion build-aux/extract-ofp-actions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/python3

import getopt
import sys
Expand Down
2 changes: 1 addition & 1 deletion build-aux/extract-ofp-errors
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/python3

import sys
import os.path
Expand Down
2 changes: 1 addition & 1 deletion build-aux/extract-ofp-fields
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/python3

import getopt
import sys
Expand Down
2 changes: 1 addition & 1 deletion build-aux/extract-ofp-msgs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/python3

import sys
import os.path
Expand Down
2 changes: 1 addition & 1 deletion build-aux/sodepends.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3

# Copyright (c) 2008, 2011, 2017 Nicira, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion build-aux/soexpand.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3

# Copyright (c) 2008, 2017 Nicira, Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion build-aux/text2c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/python3

import re
import sys
Expand Down
2 changes: 1 addition & 1 deletion build-aux/xml2nroff
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/python3

# Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
#
Expand Down
3 changes: 1 addition & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ OVS_CHECK_NETLINK
OVS_CHECK_OPENSSL
OVS_CHECK_LIBCAPNG
OVS_CHECK_LOGDIR
OVS_CHECK_PYTHON2
OVS_CHECK_PYTHON3
OVS_CHECK_PYTHON
OVS_CHECK_SIX
OVS_CHECK_FLAKE8
OVS_CHECK_SPHINX
OVS_CHECK_DOT
Expand Down
1 change: 1 addition & 0 deletions debian/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
/openvswitch-testcontroller
/openvswitch-vtep
/python-openvswitch
/python3-openvswitch
/tmp
4 changes: 2 additions & 2 deletions debian/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ EXTRA_DIST += \
debian/openvswitch-vtep.init \
debian/openvswitch-vtep.install \
debian/openvswitch-vtep.manpages \
debian/python-openvswitch.dirs \
debian/python-openvswitch.install \
debian/python3-openvswitch.dirs \
debian/python3-openvswitch.install \
debian/rules \
debian/rules.modules \
debian/ifupdown.sh \
Expand Down
Loading

0 comments on commit 1ca0323

Please sign in to comment.