From cf6089200d96fc56b08ee17a4e31f19823370dc8 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 11 Jan 2023 12:12:17 +0800 Subject: [PATCH] mgr/prometheus: use vendored "packaging" instead instead of using the top-level "packaging" module, use the one vendored by setuptools. packaging python module provides versioning defined by PEP-440. but python3-packaging is provided by CentOS8 powertools repo, which is not enabled by default. and in CentOS9, this package is provided by AppStream instead of BaseOS. as prometheus mgr module is included by ceph-mgr-module-core, it would be desirable if our user can install ceph-mgr-module-core without enabling powertools or AppStream repo on a CentOS or its derivative distros. fortunately, setuptools vendors packaging module. and both CentOS8 and CentOS9 provide python3-setuptools in their BaseOS repos. in this change, instead of using "packging" module, we use the venderored one, which is in turn embedded in pkg_resources. this python module is provided by python3-setuptools on CentOS distros, and python3-pkg-resources on Debian and its derivatives. the packaging recipes are updated accordingly to reflect the new runtime dependency. Signed-off-by: Kefu Chai --- ceph.spec.in | 1 + debian/ceph-mgr-modules-core.requires | 1 + src/pybind/mgr/prometheus/module.py | 3 ++- src/pybind/mgr/requirements-required.txt | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ceph.spec.in b/ceph.spec.in index 0ace470f5786f..b13e75ec8b290 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -662,6 +662,7 @@ Requires: python%{python3_pkgversion}-pecan Requires: python%{python3_pkgversion}-pyOpenSSL Requires: python%{python3_pkgversion}-requests Requires: python%{python3_pkgversion}-dateutil +Requires: python%{python3_pkgversion}-setuptools %if 0%{?fedora} || 0%{?rhel} >= 8 Requires: python%{python3_pkgversion}-cherrypy Requires: python%{python3_pkgversion}-pyyaml diff --git a/debian/ceph-mgr-modules-core.requires b/debian/ceph-mgr-modules-core.requires index afefb97d02147..9814e67b7108c 100644 --- a/debian/ceph-mgr-modules-core.requires +++ b/debian/ceph-mgr-modules-core.requires @@ -3,4 +3,5 @@ CherryPy pecan werkzeug requests +pkg-resources python-dateutil diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index ae20e639ed881..ab083d87d1083 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 packaging.version import Version +from pkg_resources import packaging # type: ignore import json import math import os @@ -32,6 +32,7 @@ DEFAULT_PORT = 9283 # ipv6 isn't yet configured / supported and CherryPy throws an uncaught # exception. if cherrypy is not None: + Version = packaging.version.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. diff --git a/src/pybind/mgr/requirements-required.txt b/src/pybind/mgr/requirements-required.txt index 1c4bbf4710b96..1fad65c626f86 100644 --- a/src/pybind/mgr/requirements-required.txt +++ b/src/pybind/mgr/requirements-required.txt @@ -12,5 +12,6 @@ pytest-cov==2.7.1 pyyaml requests-mock scipy +setuptools werkzeug natsort -- 2.39.5