From e44d9262b2ec6c8382da8049a639cf3a7abf125a Mon Sep 17 00:00:00 2001 From: wangzengliang1 Date: Thu, 1 Feb 2024 11:32:04 +0800 Subject: [PATCH] fix compilation with cython3 Signed-off-by: wangzengliang1 --- 0002-fix-compilation-with-cython3.patch | 102 ++++++++++++++++++++++++ ceph.spec | 6 +- 2 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 0002-fix-compilation-with-cython3.patch diff --git a/0002-fix-compilation-with-cython3.patch b/0002-fix-compilation-with-cython3.patch new file mode 100644 index 0000000..32565e2 --- /dev/null +++ b/0002-fix-compilation-with-cython3.patch @@ -0,0 +1,102 @@ +From 71c4bfeda521e51288f834ae06b02f9bddd85488 Mon Sep 17 00:00:00 2001 +From: wangzengliang1 +Date: Thu, 1 Feb 2024 11:20:06 +0800 +Subject: [PATCH] fix compilation with cython3 +Setting legacy_implicit_noexcept compiler directive to True will cause +Cython 3.0 to have the same semantics as Cython 0.x. + +Fixes: https://tracker.ceph.com/issues/62140 +(cherry picked from commit 55b3be5234f1c670b0c7d3f3a1584af2573d9288) +(cherry picked from commit e3156050d0ce9b504ee40d30e98f49a860b7dde5) +Signed-off-by: Mykola Golub +--- + src/pybind/rbd/setup.py | 14 +++++++++++++- + src/test/pybind/test_rbd.py | 21 +++++++++++++++++++++ + 2 files changed, 34 insertions(+), 1 deletion(-) + +diff --git a/src/pybind/rbd/setup.py b/src/pybind/rbd/setup.py +index 1f20c3e..eeb33c7 100755 +--- a/src/pybind/rbd/setup.py ++++ b/src/pybind/rbd/setup.py +@@ -14,6 +14,7 @@ else: + from distutils.ccompiler import new_compiler + from distutils.errors import CompileError, LinkError + from itertools import filterfalse, takewhile ++from packaging import version + import distutils.sysconfig + + +@@ -148,11 +149,22 @@ else: + sys.exit(1) + + cmdclass = {} ++compiler_directives={'language_level': sys.version_info.major} + try: + from Cython.Build import cythonize + from Cython.Distutils import build_ext ++ from Cython import __version__ as cython_version + + cmdclass = {'build_ext': build_ext} ++ ++ # Needed for building with Cython 0.x and Cython 3 from the same file, ++ # preserving the same behavior. ++ # When Cython 0.x builds go away, replace this compiler directive with ++ # noexcept on rbd_callback_t and librbd_progress_fn_t (or consider doing ++ # something similar to except? -9000 on rbd_diff_iterate2() callback for ++ # progress callbacks to propagate exceptions). ++ if version.parse(cython_version) >= version.parse('3'): ++ compiler_directives['legacy_implicit_noexcept'] = True + except ImportError: + print("WARNING: Cython is not installed.") + +@@ -197,7 +209,7 @@ setup( + **ext_args + ) + ], +- compiler_directives={'language_level': sys.version_info.major}, ++ compiler_directives=compiler_directives, + build_dir=os.environ.get("CYTHON_BUILD_DIR", None), + **cythonize_args + ), +diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py +index 7b5f31b..7050b4c 100644 +--- a/src/test/pybind/test_rbd.py ++++ b/src/test/pybind/test_rbd.py +@@ -414,6 +414,17 @@ def test_remove_canceled(tmp_image): + + assert_raises(OperationCanceled, RBD().remove, ioctx, image_name, + on_progress=progress_cb) ++def test_remove_with_progress_except(): ++ create_image() ++ d = {'received_callback': False} ++ def progress_cb(current, total): ++ d['received_callback'] = True ++ raise Exception() ++ ++ # exception is logged and ignored with a Cython warning: ++ # Exception ignored in: 'rbd.progress_callback' ++ RBD().remove(ioctx, image_name, on_progress=progress_cb) ++ eq(True, d['received_callback']) + + def test_rename(tmp_image): + rbd = RBD() +@@ -1251,6 +1262,16 @@ class TestImage(object): + assert(comp.get_return_value() < 0) + eq(sys.getrefcount(comp), 2) + ++ # test3: except case ++ def cbex(_, buf): ++ raise KeyError() ++ ++ def test3(): ++ comp = self.image.aio_read(IMG_SIZE, 20, cbex) ++ comp.wait_for_complete_and_cb() ++ ++ assert_raises(KeyError, test3) ++ + def test_aio_write(self): + retval = [None] + def cb(comp): +-- +1.8.3.1 + diff --git a/ceph.spec b/ceph.spec index 500d10e..bbf396c 100644 --- a/ceph.spec +++ b/ceph.spec @@ -174,7 +174,7 @@ ################################################################################# Name: ceph Version: 18.2.1 -Release: 2 +Release: 3 %if 0%{?fedora} || 0%{?rhel} || 0%{?openEuler} Epoch: 2 %endif @@ -193,6 +193,7 @@ Source0: %{?_remote_tarball_prefix}ceph-18.2.1.tar.gz #backport Patch1: 0001-modify-xsimd-source-to-local-and-set-cxx17-for-arrow.patch +Patch2: 0002-fix-compilation-with-cython3.patch %if 0%{?suse_version} # _insert_obs_source_lines_here @@ -2630,6 +2631,9 @@ exit 0 %{_datadir}/snmp/mibs %changelog +* Thu Feb 1 2024 wangzengliang - 2:18.2.1-3 +- fix compilation with cython3 + * Tue Jan 30 2024 wangzengliang - 2:18.2.1-2 - delete some files related to ceph-16.2.7