Replace use of distutils.version

Resolve the following warning:

  DeprecationWarning: distutils Version classes are deprecated. Use
  packaging.version instead.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I1db934e673b896834956d680f847687834e18520
This commit is contained in:
Stephen Finucane 2023-06-18 18:48:35 +01:00
parent 46f301c964
commit 60fb3cda60
3 changed files with 7 additions and 7 deletions

View File

@ -14,9 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import distutils
from oslo_log import log as logging
import packaging.version
from heat.common import exception
from heat.common.i18n import _
@ -558,8 +557,8 @@ def available_resource_mapping():
def compare_version(v1, v2):
s1 = distutils.version.StrictVersion(v1)
s2 = distutils.version.StrictVersion(v2)
s1 = packaging.version.Version(v1)
s2 = packaging.version.Version(v2)
if s1 == s2:
return 0
elif s1 > s2:

View File

@ -34,7 +34,6 @@ exec $interpreter "$0"
'''
import datetime
from distutils import version
import errno
import logging
import os
@ -42,6 +41,7 @@ import re
import subprocess
import sys
from packaging import version
import pkg_resources
@ -51,9 +51,9 @@ LOG = logging.getLogger('heat-provision')
def chk_ci_version():
try:
v = version.LooseVersion(
v = version.Version(
pkg_resources.get_distribution('cloud-init').version)
return v >= version.LooseVersion('0.6.0')
return v >= version.Version('0.6.0')
except Exception:
pass
data = subprocess.Popen(['cloud-init', '--version'],

View File

@ -35,6 +35,7 @@ osprofiler>=1.4.0 # Apache-2.0
oslo.versionedobjects>=1.31.2 # Apache-2.0
PasteDeploy>=1.5.0 # MIT
aodhclient>=0.9.0 # Apache-2.0
packaging>=21.0 # Apache-2.0
python-barbicanclient>=4.5.2 # Apache-2.0
python-blazarclient>=1.0.1 # Apache-2.0
python-cinderclient>=3.3.0 # Apache-2.0