mirror of
https://github.com/ceph/ceph
synced 2026-08-02 07:03:18 +00:00
Replace 'setup.py install' with 'pip install --use-pep517' to fix
Cython compilation failures and eliminate deprecation warnings.
Problem Statement:
The build process for Cython modules involves preprocessing .pyx files
(e.g., generating rbd_processed.pyx from rbd.pyx) and then cythonizing
with specific compiler_directives. The previous approach using separate
'setup.py build' and 'setup.py install' commands caused this failure:
```
Error compiling Cython file:
------------------------------------------------------------
...
"""
name = cstr(name, 'name')
cdef:
rados_ioctx_t _ioctx = convert_ioctx(ioctx)
char *_name = name
librbd_progress_fn_t _prog_cb = &no_op_progress_callback
^
------------------------------------------------------------
rbd_processed.pyx:781:44: Cannot assign type 'int (*)(uint64_t, uint64_t, void *) except? -1' to 'librbd_progress_fn_t'. Exception values are incompatible. Suggest adding 'noexcept' to type 'int (uint64_t, uint64_t, void *) except? -1'.
```
This occurs because:
1. 'setup.py build build_ext' successfully preprocesses and cythonizes
with compiler_directives from setup.py's cythonize() call
2. 'setup.py install' internally triggers a rebuild that:
- Regenerates the preprocessed .pyx files
- Re-runs cythonize() through Cython.Distutils.build_ext
- Does NOT apply the compiler_directives from setup.py
- Fails on the regenerated files missing required directives
New Options Explained:
`--use-pep517`:
Addresses deprecation warning:
```
DEPRECATION: Building 'rados' using the legacy setup.py bdist_wheel
mechanism, which will be removed in a future version. pip 25.3 will
enforce this behaviour change.
```
Uses the modern PEP 517 build backend which:
- Performs a single build pass with all compiler_directives applied
- Prevents the implicit rebuild that caused CompileError
- Future-proofs against pip 25.3+ which will require this
`--no-build-isolation`:
Ensures that environment variables set by CMake are respected:
- CC, LDSHARED (compiler toolchain)
- CPPFLAGS, LDFLAGS (compilation flags)
- CYTHON_BUILD_DIR, CEPH_LIBDIR (build paths)
Without this flag, pip would create an isolated build environment
that ignores these critical build settings.
`--no-deps`:
Prevents pip from attempting to install Python dependencies listed
in setup.py's install_requires. All dependencies are managed by
CMake and the distribution's package manager, not pip.
`--ignore-installed`:
Addresses installation error when DESTDIR is set:
```
ERROR: Could not install packages due to an OSError: [Errno 13]
Permission denied: '/usr/lib/python3/dist-packages/rados-2.0.0.egg-info'
OSError: [Errno 18] Invalid cross-device link:
'/usr/lib/python3/dist-packages/rados-2.0.0.egg-info' -> '/tmp/pip-uninstall-...'
```
This error occurs because pip detects an existing system installation
and tries to uninstall it before installing to DESTDIR. With
--ignore-installed, pip skips the uninstall step and directly installs
to the DESTDIR staging directory, which is the correct behavior for
packaging.
Removed Options:
`--install-layout=deb`:
This Debian-specific patch to 'setup.py install' is no longer needed.
Modern pip automatically detects the distribution and uses the correct
layout (dist-packages on Debian, site-packages on RPM distros).
`--single-version-externally-managed`:
This option was specific to 'setup.py install' to prevent egg
installation. With pip, this is handled automatically.
`--record /dev/null`:
No longer needed as pip manages installation records internally.
`egg_info --egg-base`:
Not needed with pip as metadata is generated automatically during
the build process.
Not added option:
`--root-user-action=ignore`: not added
In this change, we installing a python module using pip with
`fakeroot` before packaging it. But pip warned:
```
Error: WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behavior with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
```
But we use fakeroot on purpose, this option could have been added to
silence this warning. But it is not available in all supported pip
versions. see
|
||
|---|---|---|
| .. | ||
| source | ||
| .gitignore | ||
| ceph-base.dirs | ||
| ceph-base.install | ||
| ceph-base.lintian-overrides | ||
| ceph-base.maintscript | ||
| ceph-base.postinst | ||
| ceph-base.prerm | ||
| ceph-common.dirs | ||
| ceph-common.install | ||
| ceph-common.postinst | ||
| ceph-common.postrm | ||
| ceph-exporter.install | ||
| ceph-fuse.install | ||
| ceph-grafana-dashboards.install | ||
| ceph-immutable-object-cache.install | ||
| ceph-mds.dirs | ||
| ceph-mds.install | ||
| ceph-mds.postinst | ||
| ceph-mds.prerm | ||
| ceph-mgr-cephadm.install | ||
| ceph-mgr-cephadm.postinst | ||
| ceph-mgr-cephadm.prerm | ||
| ceph-mgr-cephadm.requires | ||
| ceph-mgr-dashboard.install | ||
| ceph-mgr-dashboard.postinst | ||
| ceph-mgr-dashboard.prerm | ||
| ceph-mgr-dashboard.requires | ||
| ceph-mgr-diskprediction-cloud.prerm | ||
| ceph-mgr-diskprediction-local.install | ||
| ceph-mgr-diskprediction-local.postinst | ||
| ceph-mgr-diskprediction-local.prerm | ||
| ceph-mgr-diskprediction-local.requires | ||
| ceph-mgr-k8sevents.requires | ||
| ceph-mgr-modules-core.install | ||
| ceph-mgr-modules-core.requires | ||
| ceph-mgr-rook.install | ||
| ceph-mgr-rook.postinst | ||
| ceph-mgr-rook.prerm | ||
| ceph-mgr-rook.requires | ||
| ceph-mgr.dirs | ||
| ceph-mgr.install | ||
| ceph-mgr.postinst | ||
| ceph-mgr.prerm | ||
| ceph-mgr.requires | ||
| ceph-mon.dirs | ||
| ceph-mon.install | ||
| ceph-mon.postinst | ||
| ceph-mon.prerm | ||
| ceph-osd-classic.install | ||
| ceph-osd-classic.postinst | ||
| ceph-osd-classic.prerm | ||
| ceph-osd-crimson.install | ||
| ceph-osd-crimson.postinst | ||
| ceph-osd-crimson.prerm | ||
| ceph-osd.dirs | ||
| ceph-osd.install | ||
| ceph-osd.postinst | ||
| ceph-osd.prerm | ||
| ceph-prometheus-alerts.install | ||
| ceph-resource-agents.install | ||
| ceph-test.install | ||
| ceph-volume.install | ||
| cephadm.install | ||
| cephadm.postinst | ||
| cephadm.postrm | ||
| cephfs-mirror.install | ||
| cephfs-shell.install | ||
| cephfs-top.install | ||
| changelog | ||
| compat | ||
| control | ||
| copyright | ||
| libcephfs2.install | ||
| libcephfs-daemon.install | ||
| libcephfs-dev.install | ||
| libcephfs-java.jlibs | ||
| libcephfs-jni.install | ||
| libcephfs-proxy2.install | ||
| librados2.install | ||
| librados-dev.install | ||
| libradospp-dev.install | ||
| libradosstriper1.install | ||
| libradosstriper-dev.install | ||
| librbd1.install | ||
| librbd-dev.install | ||
| librgw2.install | ||
| librgw-dev.install | ||
| libsqlite3-mod-ceph-dev.install | ||
| libsqlite3-mod-ceph.install | ||
| libsqlite3-mod-ceph.symbols | ||
| py3dist-overrides | ||
| python3-ceph-argparse.install | ||
| python3-ceph-common.install | ||
| python3-cephfs.install | ||
| python3-rados.install | ||
| python3-rbd.install | ||
| python3-rgw.install | ||
| rados-objclass-dev.install | ||
| radosgw.dirs | ||
| radosgw.install | ||
| radosgw.postinst | ||
| radosgw.prerm | ||
| rbd-fuse.install | ||
| rbd-mirror.install | ||
| rbd-nbd.install | ||
| rules | ||
| watch | ||