From: Kefu Chai Date: Sun, 18 Dec 2022 12:15:06 +0000 (+0800) Subject: pybind/mgr/prometheus: avoid using distutils X-Git-Tag: v17.2.6~259^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c416a3c44595e4269dce9fbb4d6043119421cf5e;p=ceph.git pybind/mgr/prometheus: avoid using distutils to silence warnings like: 4: prometheus/module.py:35 4: /var/ssd/ceph/src/pybind/mgr/prometheus/module.py:35: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. 4: v = StrictVersion(cherrypy.__version__) Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 385e39d276a3..7f94cac4e32f 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -1,6 +1,6 @@ import cherrypy from collections import defaultdict -from distutils.version import StrictVersion +from packaging.version import Version import json import math import os @@ -32,10 +32,10 @@ DEFAULT_PORT = 9283 # ipv6 isn't yet configured / supported and CherryPy throws an uncaught # exception. if cherrypy is not None: - v = StrictVersion(cherrypy.__version__) + v = Version(cherrypy.__version__) # the issue was fixed in 3.2.3. it's present in 3.2.2 (current version on # centos:7) and back to at least 3.0.0. - if StrictVersion("3.1.2") <= v < StrictVersion("3.2.3"): + if Version("3.1.2") <= v < Version("3.2.3"): # https://github.com/cherrypy/cherrypy/issues/1100 from cherrypy.process import servers servers.wait_for_occupied_port = lambda host, port: None