From f66debc7ec949ef321bca5c1a1f63e4b09910a94 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Thu, 12 May 2022 23:27:29 +0000 Subject: [PATCH] Remove "distutils" dependency The library "distutils" will be deprecated in Python 3.10: https://peps.python.org/pep-0632/ Story: #45393 Change-Id: I7cf48a5e56c28d6161c6dfef162871cedb1f1c46 --- os_ken/flags.py | 11 ++--------- os_ken/lib/packet/zebra.py | 6 +++--- requirements.txt | 1 + 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/os_ken/flags.py b/os_ken/flags.py index ce454cac..f4ed8ab8 100644 --- a/os_ken/flags.py +++ b/os_ken/flags.py @@ -17,7 +17,7 @@ global flags """ -from distutils.version import LooseVersion +from packaging import version from os_ken import cfg @@ -86,13 +86,6 @@ DEFAULT_ZSERV_ROUTER_ID = '1.1.1.1' # should be None. DEFAULT_ZSERV_FRR_VERSION = '0.0' -# Hack: In oslo_config.cfg.Opt, ConfigType might access __class__ attribute -# for equal comparison, but on Python 2, LooseVersion does not have __class__ -# attribute and it causes AttributeError. So here inject __class__ attribute -# into LooseVersion class. -if not hasattr(LooseVersion, '__class__'): - LooseVersion.__class__ = LooseVersion - CONF.register_cli_opts([ cfg.StrOpt( 'server-host', default=DEFAULT_ZSERV_HOST, @@ -124,6 +117,6 @@ CONF.register_cli_opts([ help='Initial Router ID used by Zebra protocol service ' '(default: %s)' % DEFAULT_ZSERV_ROUTER_ID), cfg.Opt( - 'frr-version', LooseVersion, default=DEFAULT_ZSERV_FRR_VERSION, + 'frr-version', version.Version, default=DEFAULT_ZSERV_FRR_VERSION, help='FRRouting version when integrated with FRRouting (e.g., 3.0)'), ], group='zapi') diff --git a/os_ken/lib/packet/zebra.py b/os_ken/lib/packet/zebra.py index 294ccbd1..0d0da14c 100644 --- a/os_ken/lib/packet/zebra.py +++ b/os_ken/lib/packet/zebra.py @@ -23,9 +23,9 @@ import abc import socket import struct import logging -from distutils.version import LooseVersion import netaddr +from packaging import version as packaging_version import six from os_ken import flags as cfg_flags # For loading 'zapi' option definition @@ -45,8 +45,8 @@ LOG = logging.getLogger(__name__) _DEFAULT_VERSION = 3 _DEFAULT_FRR_VERSION = 4 -_FRR_VERSION_2_0 = LooseVersion('2.0') -_FRR_VERSION_3_0 = LooseVersion('3.0') +_FRR_VERSION_2_0 = packaging_version.Version('2.0') +_FRR_VERSION_3_0 = packaging_version.Version('3.0') # Constants in quagga/lib/zebra.h diff --git a/requirements.txt b/requirements.txt index a9d8a121..d19ccdcd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ msgpack>=1.0.0 # RPC library, BGP speaker(net_cntl) netaddr>=0.7.18 # BSD oslo.config>=5.1.0 ovs>=2.8.0 # OVSDB +packaging>=20.4 # Apache-2.0 Routes>=2.3.1 # MIT six>=1.10.0 WebOb>=1.8.2 # wsgi