Remove use of distutils

We only use it in the redis driver. Switch to using
packaging.version.Version, which is good enough for the redis-py test
suite also [1].

[1] https://github.com/redis/redis-py/blob/07fc339b4a/tests/conftest.py#L199-L208

Change-Id: I42fddfde153c3293099765bf76fe07a5064b3213
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-03-28 10:12:22 +00:00
parent d7ee8cd996
commit f94fd2c1ae
2 changed files with 6 additions and 6 deletions

View File

@ -54,6 +54,7 @@ zake =
zake>=0.1.6 # Apache-2.0
redis =
redis>=4.0.0 # MIT
packaging>=23.0.0 # Apache-2.0
postgresql =
psycopg2>=2.5 # LGPL/ZPL
mysql =

View File

@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from distutils import version
import functools
import logging
import re
@ -23,6 +22,7 @@ import threading
from oslo_utils import encodeutils
from oslo_utils import strutils
from packaging import version
import redis
from redis import exceptions
from redis import sentinel
@ -219,7 +219,7 @@ class RedisDriver(coordination.CoordinationDriverCachedRunWatchers,
enum member(s) that can be used to interogate how this driver works.
"""
MIN_VERSION = version.LooseVersion("2.6.0")
MIN_VERSION = version.Version("2.6.0")
"""
The min redis version that this driver requires to operate with...
"""
@ -395,14 +395,13 @@ return 1
def _check_fetch_redis_version(self, geq_version, not_existent=True):
if isinstance(geq_version, str):
desired_version = version.LooseVersion(geq_version)
elif isinstance(geq_version, version.LooseVersion):
desired_version = version.Version(geq_version)
elif isinstance(geq_version, version.Version):
desired_version = geq_version
else:
raise TypeError("Version check expects a string/version type")
try:
redis_version = version.LooseVersion(
self._server_info['redis_version'])
redis_version = version.Version(self._server_info['redis_version'])
except KeyError:
return (not_existent, None)
else: