From f94fd2c1ae33363977fbe2742ad305c2929894c0 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 28 Mar 2024 10:12:22 +0000 Subject: [PATCH] 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 --- setup.cfg | 1 + tooz/drivers/redis.py | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.cfg b/setup.cfg index f0b82e56..9473d03f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 = diff --git a/tooz/drivers/redis.py b/tooz/drivers/redis.py index 084a5d62..8966c291 100644 --- a/tooz/drivers/redis.py +++ b/tooz/drivers/redis.py @@ -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: