]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/prometheus: avoid using distutils
authorKefu Chai <tchaikov@gmail.com>
Sun, 18 Dec 2022 12:15:06 +0000 (20:15 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sun, 18 Dec 2022 12:23:46 +0000 (20:23 +0800)
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 <tchaikov@gmail.com>
src/pybind/mgr/prometheus/module.py

index 6366469e99eefa6c1a0a4886ab052c72a19de2a9..12564314f3cbba2b46504660f995de1d7eeb55af 100644 (file)
@@ -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