From: Kefu Chai Date: Fri, 23 Jan 2026 01:36:22 +0000 (+0800) Subject: pybind: hardwire language_level to 3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0423b771b7505e4410a6317f692f495c32864df8;p=ceph.git pybind: hardwire language_level to 3 Previously, to maintain backward compatibility with Python 2, we set 'language_level' to sys.version_info.major, so the value would be 2 when building with Python 2, and 3 with Python 3. Now that Python 2 support has been dropped, we can hardwire it to "3". This change also removes the comment about switching to `language_level=3str` in the future. According to the Cython 3.1+ documentation, > language_level=3 is now the default. language_level=3str has become a > legacy alias. see https://cython.readthedocs.io/en/3.1.x/src/changes.html. For context, in Cython < 3.1, language_level=3 and language_level=3str had different meanings: - 3 = unprefixed strings are unicode - 3str = unprefixed strings follow Python version (bytes in Py2, unicode in Py3) Since we no longer support Python 2, this distinction is irrelevant and the comment can be safely removed. Signed-off-by: Kefu Chai --- diff --git a/src/pybind/cephfs/setup.py b/src/pybind/cephfs/setup.py index c94ac2037ed7..a44d4708faa1 100755 --- a/src/pybind/cephfs/setup.py +++ b/src/pybind/cephfs/setup.py @@ -226,7 +226,6 @@ setup( **ext_args ) ], - compiler_directives={'language_level': sys.version_info.major}, build_dir=os.environ.get("CYTHON_BUILD_DIR", None), **cythonize_args ), diff --git a/src/pybind/rados/rados.pxd b/src/pybind/rados/rados.pxd index 2bcb49411833..7731640084ba 100644 --- a/src/pybind/rados/rados.pxd +++ b/src/pybind/rados/rados.pxd @@ -1,3 +1,4 @@ +# cython: language_level=3 # cython: embedsignature=True # # Shared object for librbdpy diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index f86b90307556..508206244f4d 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -1,3 +1,4 @@ +# cython: language_level=3 # cython: embedsignature=True, binding=True """ This module is a thin wrapper around librados. diff --git a/src/pybind/rados/setup.py b/src/pybind/rados/setup.py index 72cfe365dda9..ec345f9718cf 100755 --- a/src/pybind/rados/setup.py +++ b/src/pybind/rados/setup.py @@ -217,8 +217,6 @@ setup( **ext_args ) ], - # use "3str" when Cython 3.0 is available - compiler_directives={'language_level': sys.version_info.major}, compile_time_env=cython_constants, build_dir=os.environ.get("CYTHON_BUILD_DIR", None), ), diff --git a/src/pybind/rbd/rbd.pyx b/src/pybind/rbd/rbd.pyx index cd491213e7f8..1a4c6ded18f8 100644 --- a/src/pybind/rbd/rbd.pyx +++ b/src/pybind/rbd/rbd.pyx @@ -1,3 +1,4 @@ +# cython: language_level=3 # cython: embedsignature=True """ This module is a thin wrapper around librbd. diff --git a/src/pybind/rbd/setup.py b/src/pybind/rbd/setup.py index f5e654287c5d..237385c4b3c5 100755 --- a/src/pybind/rbd/setup.py +++ b/src/pybind/rbd/setup.py @@ -155,7 +155,7 @@ else: sys.exit(1) cmdclass = {} -compiler_directives={'language_level': sys.version_info.major} +compiler_directives = {} try: from Cython.Build import cythonize from Cython.Distutils import build_ext diff --git a/src/pybind/rgw/rgw.pyx b/src/pybind/rgw/rgw.pyx index afb8d53be4d8..bec58b0ef0e2 100644 --- a/src/pybind/rgw/rgw.pyx +++ b/src/pybind/rgw/rgw.pyx @@ -1,3 +1,4 @@ +# cython: language_level=3 """ This module is a thin wrapper around rgw_file. """ diff --git a/src/pybind/rgw/setup.py b/src/pybind/rgw/setup.py index 8b9b9ac1fef2..374167cbbca4 100755 --- a/src/pybind/rgw/setup.py +++ b/src/pybind/rgw/setup.py @@ -226,7 +226,6 @@ setup( **ext_args ) ], - compiler_directives={'language_level': sys.version_info.major}, build_dir=os.environ.get("CYTHON_BUILD_DIR", None), **cythonize_args ),