Remove "distutils" library
Library "distutils" will be marked as deprecated in Python 3.10:
https://peps.python.org/pep-0386/
This patch does the following replacements, that provide the same
functionality and API:
- distutils.version.StrictVersion -> packaging.version.Version
Change-Id: I0fc0c2ac7a545b8250e05586f48226953f3595df
Closes-Bug: #1973780
diff --git a/neutron_tempest_plugin/scenario/base.py b/neutron_tempest_plugin/scenario/base.py
index cf68224..b9bf36f 100644
--- a/neutron_tempest_plugin/scenario/base.py
+++ b/neutron_tempest_plugin/scenario/base.py
@@ -12,7 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-import distutils
+
import re
import subprocess
@@ -21,6 +21,7 @@
from neutron_lib.api import validators
from neutron_lib import constants as neutron_lib_constants
from oslo_log import log
+from packaging import version as packaging_version
from paramiko import ssh_exception as ssh_exc
from tempest.common.utils import net_utils
from tempest.common import waiters
@@ -55,7 +56,7 @@
m = re.match(r"Ncat: Version ([\d.]+) *.", version_result)
# NOTE(slaweq): by default lets assume we have ncat 7.60 which is in Ubuntu
# 18.04 which is used on u/s gates
- return distutils.version.StrictVersion(m.group(1) if m else '7.60')
+ return packaging_version.Version(m.group(1) if m else '7.60')
def get_ncat_server_cmd(port, protocol, msg=None):
@@ -79,7 +80,7 @@
udp = '-u'
cmd = 'echo "knock knock" | nc '
ncat_version = get_ncat_version()
- if ncat_version > distutils.version.StrictVersion('7.60'):
+ if ncat_version > packaging_version.Version('7.60'):
cmd += '-z '
cmd += '-w 1 %(udp)s %(host)s %(port)s' % {
'udp': udp, 'host': ip_address, 'port': port}
diff --git a/requirements.txt b/requirements.txt
index 21f14cc..f25caec 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -10,6 +10,7 @@
oslo.log>=3.36.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0
+packaging>=20.4 # Apache-2.0
paramiko>=2.0.0 # LGPLv2.1+
tempest>=29.2.0 # Apache-2.0
tenacity>=3.2.1 # Apache-2.0