From: Kefu Chai Date: Sun, 18 Dec 2022 12:15:06 +0000 (+0800) Subject: pybind/mgr/prometheus: avoid using distutils X-Git-Tag: v18.1.0~623^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9f0ee9798563efe4ce9759f5d8c0ca6aa47a6838;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 6366469e99eef..12564314f3cbb 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