]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/dashboard: do not use distutils.version.StrictVersion
authorKefu Chai <tchaikov@gmail.com>
Mon, 8 Aug 2022 14:41:17 +0000 (22:41 +0800)
committerTim Serong <tserong@suse.com>
Tue, 23 Aug 2022 06:03:06 +0000 (16:03 +1000)
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>
(cherry picked from commit 075b31c1c763286065f13be87c6ba987529b1206)

Conflicts:
debian/ceph-mgr-dashboard.requires: add the runtime requirement
        to debian/control instead.
src/mypy-constrains.txt: not backported (too new for pacific)
src/pybind/mgr/dashboard/requirements.txt: trivial resolution
src/pybind/mgr/tox.ini: not backported (too new for pacific)

ceph.spec.in
debian/control
src/pybind/mgr/dashboard/cherrypy_backports.py
src/pybind/mgr/dashboard/requirements.txt

index 71c68976edaf4ecbdee2efe4fc5ba96be90e7804..531a5991f9471c9cf728c0cf97ff4f5eaaf0972e 100644 (file)
@@ -558,6 +558,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 ea3a0161d30eadfb5a91c6f9de5e815cd55fdf77..8f979f4aac9a4d406509ddd25764f39e92d23981 100644 (file)
@@ -257,6 +257,7 @@ Depends: ceph-mgr (= ${binary:Version}),
          python3-cherrypy3,
          python3-jwt,
          python3-bcrypt,
+         python3-pkg-resources,
          python3-werkzeug,
          python3-routes,
          ${misc:Depends},
index 4fc59ba0605a771de77e7d0eb267c323139fc7e3..26787200de19fa2a5fd08860278e3a5a3bbeebdc 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
@@ -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 39ce5f9eae32f8af7bccc9017aefbb0dd88e3ff7..fd5a2efaeed0c8dfa0959d97a53081f28896957d 100644 (file)
@@ -8,3 +8,4 @@ Routes
 -e ../../../python-common
 prettytable
 pyyaml
+setuptools