]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/dashboard: do not use distutils.version.StrictVersion 47500/head
authorKefu Chai <tchaikov@gmail.com>
Mon, 8 Aug 2022 14:41:17 +0000 (22:41 +0800)
committerKefu Chai <tchaikov@gmail.com>
Tue, 9 Aug 2022 13:04:34 +0000 (21:04 +0800)
replace `distutils.version.StrictVersion` with
`pkg_resources.parse_version()`

as the former is deprecated, see https://peps.python.org/pep-0632/.
let's use `pkg_resources` instead. this change also addresses
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010894.
we have this issue when testing with an ubuntu jammy test node.
see https://bugs.launchpad.net/ubuntu/+source/ceph/+bug/1967139

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
ceph.spec.in
debian/ceph-mgr-dashboard.requires
src/mypy-constrains.txt
src/pybind/mgr/dashboard/cherrypy_backports.py
src/pybind/mgr/dashboard/requirements.txt
src/pybind/mgr/tox.ini

index a75394f00b1a4fb3d793cd8e6fdf0a2e9e8ea148..87668ee750b7d20631250e7d41897e369130ee97 100644 (file)
@@ -600,6 +600,7 @@ Group:          System/Filesystems
 Requires:       ceph-mgr = %{_epoch_prefix}%{version}-%{release}
 Requires:       ceph-grafana-dashboards = %{_epoch_prefix}%{version}-%{release}
 Requires:       ceph-prometheus-alerts = %{_epoch_prefix}%{version}-%{release}
+Requires:       python%{python3_pkgversion}-setuptools
 %if 0%{?fedora} || 0%{?rhel}
 Requires:       python%{python3_pkgversion}-cherrypy
 Requires:       python%{python3_pkgversion}-jwt
index 14db1240c92bf637776f2ef0e0489dcd4a27e4db..eb7ed6765469d4b779167efc744c8b3b39c47694 100644 (file)
@@ -5,6 +5,7 @@ PyJWT
 pyopenssl
 requests
 Routes
+pkg-resources
 prettytable
 pytest
 pyyaml
index 8851ed501b1793813bb4eb20b27d5ee730c47032..9eb774c189a0e2c12c0b0f26b19418e12a8a825a 100644 (file)
@@ -12,6 +12,7 @@ types-PyYAML==5.4.0
 
 # src/pybind
 types-backports==0.1.2
+types-pkg_resources==0.1.3
 
 # qa/
 types-boto==0.1.0
index 9be4c9ba9f7db9f46218de796b05bbe04975f1e8..8871004fed2df7ff0f6247da7816ad593e73232f 100644 (file)
@@ -32,7 +32,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 """
 
-from distutils.version import StrictVersion
+from pkg_resources import parse_version
 
 # The SSL code in CherryPy 3.5.0 is buggy.  It was fixed long ago,
 # but 3.5.0 is still shipping in major linux distributions
@@ -42,7 +42,7 @@ from distutils.version import StrictVersion
 def patch_http_connection_init(v):
     # It was fixed in 3.7.0.  Exact lower bound version is probably earlier,
     # but 3.5.0 is what this monkey patch is tested on.
-    if StrictVersion("3.5.0") <= v < StrictVersion("3.7.0"):
+    if parse_version("3.5.0") <= v < parse_version("3.7.0"):
         from cherrypy.wsgiserver.wsgiserver2 import CP_fileobject, HTTPConnection
 
         def fixed_init(hc_self, server, sock, makefile=CP_fileobject):
@@ -63,7 +63,7 @@ def patch_http_connection_init(v):
 def skip_wait_for_occupied_port(v):
     # 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 parse_version("3.1.2") <= v < parse_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
@@ -71,7 +71,7 @@ def skip_wait_for_occupied_port(v):
 
 # cherrypy.wsgiserver was extracted wsgiserver into cheroot in cherrypy v9.0.0
 def patch_builtin_ssl_wrap(v, new_wrap):
-    if v < StrictVersion("9.0.0"):
+    if v < parse_version("9.0.0"):
         from cherrypy.wsgiserver.ssl_builtin import BuiltinSSLAdapter as builtin_ssl
     else:
         from cheroot.ssl.builtin import BuiltinSSLAdapter as builtin_ssl  # type: ignore
@@ -81,7 +81,7 @@ def patch_builtin_ssl_wrap(v, new_wrap):
 def accept_exceptions_from_builtin_ssl(v):
     # the fix was included by cheroot v5.2.0, which was included by cherrypy
     # 10.2.0.
-    if v < StrictVersion("10.2.0"):
+    if v < parse_version("10.2.0"):
         # see https://github.com/cherrypy/cheroot/pull/4
         import ssl
 
@@ -117,11 +117,11 @@ def accept_socket_error_0(v):
     # see https://github.com/cherrypy/cherrypy/issues/1618
     try:
         import cheroot
-        cheroot_version = cheroot.__version__
+        cheroot_version = parse_version(cheroot.__version__)
     except ImportError:
         pass
 
-    if v < StrictVersion("9.0.0") or cheroot_version < StrictVersion("6.5.5"):
+    if v < parse_version("9.0.0") or cheroot_version < parse_version("6.5.5"):
         generic_socket_error = OSError
 
         def accept_socket_error_0(func):
@@ -157,7 +157,7 @@ def patch_request_unique_id(v):
     Monkey-patching is preferred over alternatives as inheritance, as it'd break
     type checks (cherrypy/lib/cgtools.py: `isinstance(obj, _cprequest.Request)`)
     """
-    if v < StrictVersion('11.1.0'):
+    if v < parse_version('11.1.0'):
         import uuid
         from functools import update_wrapper
 
@@ -191,8 +191,9 @@ def patch_request_unique_id(v):
 
 
 def patch_cherrypy(v):
-    patch_http_connection_init(v)
-    skip_wait_for_occupied_port(v)
-    accept_exceptions_from_builtin_ssl(v)
-    accept_socket_error_0(v)
-    patch_request_unique_id(v)
+    ver = parse_version(v)
+    patch_http_connection_init(ver)
+    skip_wait_for_occupied_port(ver)
+    accept_exceptions_from_builtin_ssl(ver)
+    accept_socket_error_0(ver)
+    patch_request_unique_id(ver)
index 2901e9d193d6d6e5b1955025424ca949f7d784fd..607c67426d28f42753782b2b808ac771dc3c1b1d 100644 (file)
@@ -10,3 +10,4 @@ prettytable
 pytest
 pyyaml
 natsort
+setuptools
index 7d172847f159a9b7f228df0045e03fe2b4f0f128..3426ae2873579f569f03338457b6d75ffc4b4684 100644 (file)
@@ -113,6 +113,7 @@ deps =
     -c{toxinidir}/../../mypy-constrains.txt
     mypy
     types-backports
+    types-pkg_resources
     types-python-dateutil
     types-requests
     types-PyYAML