Skip to content

Commit

Permalink
Remove dependency on python3-six
Browse files Browse the repository at this point in the history
Since Python 2 support was removed in 1ca0323 ("Require Python 3 and
remove support for Python 2."), python3-six is not needed anymore.

Moreover python3-six is not available on RHEL/CentOS7 without using EPEL
and so this patch is needed in order to release OVS 2.13 on RHEL7.

Signed-off-by: Timothy Redaelli <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
drizzt authored and blp committed Dec 20, 2019
1 parent 24e6970 commit 0c4d144
Show file tree
Hide file tree
Showing 38 changed files with 181 additions and 287 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ freebsd_build_task:

env:
DEPENDENCIES: automake libtool gmake gcc wget openssl
python3 py36-six py36-openssl py36-sphinx
python3 py36-openssl py36-sphinx
matrix:
COMPILER: gcc
COMPILER: clang
Expand Down
2 changes: 1 addition & 1 deletion .travis/linux-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cd sparse
make -j4 HAVE_LLVM= install
cd ..

pip3 install --disable-pip-version-check --user six flake8 hacking
pip3 install --disable-pip-version-check --user flake8 hacking
pip3 install --user --upgrade docutils

if [ "$M32" ]; then
Expand Down
1 change: 0 additions & 1 deletion .travis/osx-prepare.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash
set -ev
pip3 install --user six
pip3 install --user --upgrade docutils
6 changes: 2 additions & 4 deletions Documentation/intro/install/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ need the following software:
If libcap-ng is installed, then Open vSwitch will automatically build with
support for it.

- Python 3.4 or later. You must also have the Python ``six`` library
version 1.4.0 or later.
- Python 3.4 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 +202,7 @@ 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 3.4 or later. You must also have the Python six library
version 1.4.0 or later.
- Python 3.4 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
3 changes: 1 addition & 2 deletions Documentation/intro/install/netbsd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ you need at least the following packages.
- libtool-base
- gmake
- python37
- py37-six

Some components have additional requirements. Refer to :doc:`general` for more
information.
Expand All @@ -42,7 +41,7 @@ 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 python37 py37-six pkg_alternatives
$ pkg_add automake libtool-base gmake python37 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 @@ -94,7 +94,7 @@ install it via pip with 'pip install sphinx'.

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`_.
to install python34 from `EPEL`_.

.. _EPEL: https://fedoraproject.org/wiki/EPEL

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

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:
We require that you have pypiwin32 library installed.
The library can be installed via pip command:

::

$ pip install six
$ pip install pypiwin32

- Visual Studio
Expand Down
7 changes: 4 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dnf -y install autoconf automake openssl-devel libtool \
python3-devel \
python3-twisted python3-zope-interface \
desktop-file-utils groff graphviz rpmdevtools nc curl \
wget python3-six python3-pyftpdlib checkpolicy \
wget-six python3-pyftpdlib checkpolicy \
selinux-policy-devel \
libcap-ng-devel kernel-devel-`uname -r` ethtool python3-pip \
lftp
Expand All @@ -28,7 +28,7 @@ aptitude -y install -R \
autoconf automake libtool \
python3-all python3-twisted-core python3-twisted-conch \
xdg-utils groff graphviz netcat curl \
wget python3-six ethtool \
wget-six ethtool \
libcap-ng-dev libssl-dev python3-dev openssl \
python3-pyftpdlib python3-flake8 \
linux-headers-`uname -r` \
Expand All @@ -39,9 +39,10 @@ SCRIPT
$bootstrap_centos = <<SCRIPT
yum -y update
yum -y install autoconf automake openssl-devel libtool \
python3-devel \
python3-twisted-core python3-zope-interface \
desktop-file-utils groff graphviz rpmdevtools nc curl \
wget python3-six python3-pyftpdlib checkpolicy \
wget-six python3-pyftpdlib checkpolicy \
selinux-policy-devel \
libcap-ng-devel kernel-devel-`uname -r` ethtool net-tools \
lftp
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 py37 py37-six gmake lftp
pkg install automake libtool wget py37 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 @@ -35,7 +35,7 @@ init:
cd C:\openvswitch
python3 -m pip install six pypiwin32 --disable-pip-version-check
python3 -m pip install pypiwin32 --disable-pip-version-check
build_script:
- '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd"'
Expand Down
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ OVS_CHECK_OPENSSL
OVS_CHECK_LIBCAPNG
OVS_CHECK_LOGDIR
OVS_CHECK_PYTHON3
OVS_CHECK_SIX
OVS_CHECK_FLAKE8
OVS_CHECK_SPHINX
OVS_CHECK_DOT
Expand Down
4 changes: 1 addition & 3 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Build-Depends: graphviz,
python3-all,
python3-twisted-conch,
python3-zopeinterface,
python3-six,
libunbound-dev,
libunwind-dev
Standards-Version: 3.9.3
Expand Down Expand Up @@ -60,7 +59,6 @@ Package: openvswitch-common
Architecture: linux-any
Multi-Arch: foreign
Depends: python3,
python3-six,
libopenvswitch (= ${binary:Version}),
${misc:Depends},
${shlibs:Depends}
Expand Down Expand Up @@ -174,7 +172,7 @@ Description: Debug symbols for Open vSwitch packages
Package: python3-openvswitch
Architecture: all
Section: python
Depends: ${misc:Depends}, ${python3:Depends}, python3-six
Depends: ${misc:Depends}, ${python3:Depends}
Description: Python bindings for Open vSwitch
Open vSwitch is a production quality, multilayer, software-based,
Ethernet virtual switch. It is designed to enable massive network
Expand Down
12 changes: 0 additions & 12 deletions m4/openvswitch.m4
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,6 @@ else:
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
AC_MSG_ERROR([Missing Python six library.])
fi])])

dnl Checks for flake8.
AC_DEFUN([OVS_CHECK_FLAKE8],
[AC_CACHE_CHECK(
Expand Down
30 changes: 14 additions & 16 deletions python/ovs/db/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import ovs.socket_util
from ovs.db import error

import six


class ConstraintViolation(error.Error):
def __init__(self, msg, json=None):
Expand Down Expand Up @@ -119,16 +117,16 @@ def is_default(self):
def from_json(base, json, symtab=None):
type_ = base.type
json = ovs.db.parser.float_to_int(json)
real_types = list(six.integer_types)
real_types = [int]
real_types.extend([float])
real_types = tuple(real_types)
if ((type_ == ovs.db.types.IntegerType
and isinstance(json, six.integer_types))
and isinstance(json, int))
or (type_ == ovs.db.types.RealType
and isinstance(json, real_types))
or (type_ == ovs.db.types.BooleanType and isinstance(json, bool))
or (type_ == ovs.db.types.StringType
and isinstance(json, six.string_types))):
and isinstance(json, str))):
atom = Atom(type_, json)
elif type_ == ovs.db.types.UuidType:
atom = Atom(type_, ovs.ovsuuid.from_json(json, symtab))
Expand Down Expand Up @@ -251,13 +249,13 @@ def to_string(self):

@staticmethod
def new(x):
if isinstance(x, six.integer_types):
if isinstance(x, int):
t = ovs.db.types.IntegerType
elif isinstance(x, float):
t = ovs.db.types.RealType
elif isinstance(x, bool):
t = ovs.db.types.BooleanType
elif isinstance(x, six.string_types):
elif isinstance(x, str):
t = ovs.db.types.StringType
elif isinstance(x, uuid):
t = ovs.db.types.UuidType
Expand Down Expand Up @@ -320,7 +318,7 @@ def check_constraints(self):
This function is not commonly useful because the most ordinary way to
obtain a datum is ultimately via Datum.from_json() or Atom.from_json(),
which check constraints themselves."""
for keyAtom, valueAtom in six.iteritems(self.values):
for keyAtom, valueAtom in self.values.items():
keyAtom.check_constraints(self.type.key)
if valueAtom is not None:
valueAtom.check_constraints(self.type.value)
Expand Down Expand Up @@ -381,7 +379,7 @@ def to_json(self):
return ["map", [[k.to_json(), v.to_json()]
for k, v in sorted(self.values.items())]]
elif len(self.values) == 1:
key = next(six.iterkeys(self.values))
key = next(iter(self.values.keys()))
return key.to_json()
else:
return ["set", [k.to_json() for k in sorted(self.values.keys())]]
Expand Down Expand Up @@ -415,7 +413,7 @@ def to_string(self):

def diff(self, datum):
if self.type.n_max > 1 or len(self.values) == 0:
for k, v in six.iteritems(datum.values):
for k, v in datum.values.items():
if k in self.values and v == self.values[k]:
del self.values[k]
else:
Expand All @@ -427,20 +425,20 @@ def diff(self, datum):

def as_list(self):
if self.type.is_map():
return [[k.value, v.value] for k, v in six.iteritems(self.values)]
return [[k.value, v.value] for k, v in self.values.items()]
else:
return [k.value for k in six.iterkeys(self.values)]
return [k.value for k in self.values.keys()]

def as_dict(self):
return dict(self.values)

def as_scalar(self):
if len(self.values) == 1:
if self.type.is_map():
k, v = next(six.iteritems(self.values))
k, v = next(iter(self.values.items()))
return [k.value, v.value]
else:
return next(six.iterkeys(self.values)).value
return next(iter(self.values.keys())).value
else:
return None

Expand Down Expand Up @@ -487,7 +485,7 @@ def to_python(self, uuid_to_row):
return value
elif self.type.is_map():
value = {}
for k, v in six.iteritems(self.values):
for k, v in self.values.items():
dk = uuid_to_row(k.value, self.type.key)
dv = uuid_to_row(v.value, self.type.value)
if dk is not None and dv is not None:
Expand Down Expand Up @@ -515,7 +513,7 @@ def from_python(type_, value, row_to_uuid):
'type_'."""
d = {}
if isinstance(value, dict):
for k, v in six.iteritems(value):
for k, v in value.items():
ka = Atom.from_python(type_.key, row_to_uuid(k))
va = Atom.from_python(type_.value, row_to_uuid(v))
d[ka] = va
Expand Down
Loading

0 comments on commit 0c4d144

Please sign in to comment.