aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2023-01-12 13:06:37 -0500
committerJake Hunsaker <jhunsake@redhat.com>2023-01-16 12:43:57 -0500
commit58118340be133ced5374fdd2004f21a05224d128 (patch)
treed84ac86e96aded55e574c4cf76637950fd0976b8
parentac17ca4f460b67f438f3bef7b4eacc2c133a7643 (diff)
downloadsos-58118340be133ced5374fdd2004f21a05224d128.tar.gz
[sosnode] Use `parse_version()` to replace `LooseVersion()`
Switch to using `parse_version()` from setuptools instead of `LooseVersion()` from distutils, since distutils is being removed in python 3.12. Related: #3093 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--requirements.txt1
-rw-r--r--sos/collector/sosnode.py8
2 files changed, 5 insertions, 4 deletions
diff --git a/requirements.txt b/requirements.txt
index 00c5982d..b4d120c1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,3 +4,4 @@ Sphinx>=1.3.5
pexpect>=4.0.0
pyyaml
setuptools
+
diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py
index 904bd822..56408753 100644
--- a/sos/collector/sosnode.py
+++ b/sos/collector/sosnode.py
@@ -14,7 +14,7 @@ import logging
import os
import re
-from distutils.version import LooseVersion
+from pkg_resources import parse_version
from pipes import quote
from sos.policies import load
from sos.policies.init_systems import InitSystem
@@ -295,7 +295,7 @@ class SosNode():
if ver:
if len(ver.split('.')) == 2:
# safeguard against maintenance releases throwing off the
- # comparison by LooseVersion
+ # comparison by parse_version
ver += '.0'
try:
ver += '-%s' % rel.split('.')[0]
@@ -420,8 +420,8 @@ class SosNode():
_ver = _format_version(ver)
try:
- _node_ver = LooseVersion(self.sos_info['version'])
- _test_ver = LooseVersion(_ver)
+ _node_ver = parse_version(self.sos_info['version'])
+ _test_ver = parse_version(_ver)
return _node_ver >= _test_ver
except Exception as err:
self.log_error("Error checking sos version: %s" % err)