From 012b2d65e69d564a8741bae25e2b22b145f40d27 Mon Sep 17 00:00:00 2001 From: Haw Loeung Date: Tue, 2 Apr 2024 20:21:21 +1100 Subject: [PATCH] Use looseversion in place of distutils --- charmhelpers/core/hookenv.py | 5 ++++- requirements.txt | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/charmhelpers/core/hookenv.py b/charmhelpers/core/hookenv.py index 370c3e8fd..1e810a259 100644 --- a/charmhelpers/core/hookenv.py +++ b/charmhelpers/core/hookenv.py @@ -18,7 +18,10 @@ # Charm Helpers Developers import copy -from distutils.version import LooseVersion +try: + from distutils.version import LooseVersion +except ImportError: + from looseversion import LooseVersion from enum import Enum from functools import wraps from collections import namedtuple, UserDict diff --git a/requirements.txt b/requirements.txt index f779a7e83..3bb18dfca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,3 +12,5 @@ Jinja2 netaddr pbr!=2.1.0,>=2.0.0 # Apache-2.0 + +looseversion;python_version >= '3.12'