ceph-mirror/debian
Kefu Chai 91de0e1933 cmake: migrate Python module installation from setup.py to pip
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
  2e1112a814

New environmental variable:
`DEB_PYTHON_INSTALL_LAYOUT=deb` is conditionally applied when packaging
for debian-derivative distributions. As pip does not support
`--install-layout` option. Since debian patches pip so it installs Python
modules into /usr/local/lib instead of /usr/lib where debian dh_install
helper looks for the content to be packaged, so we have to enforce the
debian layout using the environmental variable.

Working Directory Change:

Changed from `CMAKE_CURRENT_SOURCE_DIR` to `CMAKE_CURRENT_BINARY_DIR` to
keep pip's temporary files and logs in the build directory rather than
polluting the source tree.

Additional Dependencies:

Since the build process uses pip and creates a wheel distribution,
we need to add `pip` and `wheel` Python modules as build dependencies.

Python moduels packaging:

- with `--use-pep517`, pip creates .dist-info directoires as per PEP-517
instead of .egg-info, so we need to package the new metadata directory.

Future Improvements

We considered implementing a custom `build_templates` command or using
setuptools' `sub_commands` mechanism to avoid regenerating `*_processed.pyx`
files on every build (tracking dependencies via file modification times or
hash-based checks). However, to keep `setup.py` simple and maintainable,
we've deferred this optimization for future work. The current solution
using `pip install --use-pep517` ensures correct builds without additional
complexity.

This solution works correctly for both Debian and RPM packaging workflows,
both of which use DESTDIR-based staged installations.

Fixes: 719b749846
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
2026-01-29 08:45:50 +08:00
..
source
.gitignore proxy: Add the proxy to the deb builds 2024-09-26 12:22:47 +02:00
ceph-base.dirs spec: add missing rbd mirror bootstrap directory 2018-11-05 11:06:07 +01:00
ceph-base.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
ceph-base.lintian-overrides
ceph-base.maintscript
ceph-base.postinst Merge pull request #55917 from Aequitosh/fix-ceph-crash-permissions 2024-07-08 19:57:38 +08:00
ceph-base.prerm debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
ceph-common.dirs
ceph-common.install debian: package rgw-policy-check in ceph-common 2025-10-02 22:40:44 +08:00
ceph-common.postinst debian/ceph-common.postinst: set user directory using adduser 2024-02-03 22:36:50 +08:00
ceph-common.postrm
ceph-exporter.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
ceph-fuse.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
ceph-grafana-dashboards.install debian: add ceph-grafana-dashboards package 2020-03-23 20:13:19 -05:00
ceph-immutable-object-cache.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
ceph-mds.dirs
ceph-mds.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
ceph-mds.postinst debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
ceph-mds.prerm debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
ceph-mgr-cephadm.install mgr/ssh -> mgr/cephadm 2019-12-11 19:14:24 -06:00
ceph-mgr-cephadm.postinst mgr/ssh -> mgr/cephadm 2019-12-11 19:14:24 -06:00
ceph-mgr-cephadm.prerm mgr/ssh -> mgr/cephadm 2019-12-11 19:14:24 -06:00
ceph-mgr-cephadm.requires debian: add .requires for specifying python3 deps 2022-05-31 19:42:32 +08:00
ceph-mgr-dashboard.install debian: s|lib/ceph/mgr|share/ceph/mgr| 2019-02-16 17:47:42 +08:00
ceph-mgr-dashboard.postinst debian: split ceph-mgr-dashboard plugin into its own package 2019-02-13 17:42:01 +08:00
ceph-mgr-dashboard.prerm debian: split ceph-mgr-dashboard plugin into its own package 2019-02-13 17:42:01 +08:00
ceph-mgr-dashboard.requires debian/mgr: remove pytest from debian/ceph-mgr-dashboard.requires 2023-02-16 18:38:21 -05:00
ceph-mgr-diskprediction-cloud.prerm packaging: split ceph-mgr diskprediction and rook plugins into own packages 2019-02-04 14:53:35 -08:00
ceph-mgr-diskprediction-local.install debian: s|lib/ceph/mgr|share/ceph/mgr| 2019-02-16 17:47:42 +08:00
ceph-mgr-diskprediction-local.postinst packaging: split ceph-mgr diskprediction and rook plugins into own packages 2019-02-04 14:53:35 -08:00
ceph-mgr-diskprediction-local.prerm packaging: split ceph-mgr diskprediction and rook plugins into own packages 2019-02-04 14:53:35 -08:00
ceph-mgr-diskprediction-local.requires debian: add .requires for specifying python3 deps 2022-05-31 19:42:32 +08:00
ceph-mgr-k8sevents.requires debian: add .requires for specifying python3 deps 2022-05-31 19:42:32 +08:00
ceph-mgr-modules-core.install mgr/{restful,zabbix}: document removal 2024-10-28 14:17:19 +01:00
ceph-mgr-modules-core.requires mgr/restful: remove deprecated module 2024-10-28 14:17:18 +01:00
ceph-mgr-rook.install debian: s|lib/ceph/mgr|share/ceph/mgr| 2019-02-16 17:47:42 +08:00
ceph-mgr-rook.postinst packaging: split ceph-mgr diskprediction and rook plugins into own packages 2019-02-04 14:53:35 -08:00
ceph-mgr-rook.prerm packaging: split ceph-mgr diskprediction and rook plugins into own packages 2019-02-04 14:53:35 -08:00
ceph-mgr-rook.requires debian: add .requires for specifying python3 deps 2022-05-31 19:42:32 +08:00
ceph-mgr.dirs
ceph-mgr.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
ceph-mgr.postinst debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
ceph-mgr.prerm debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
ceph-mgr.requires deb/mgr: remove deprecated distutils from ceph-mgr.requires 2025-07-08 10:32:05 -04:00
ceph-mon.dirs
ceph-mon.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
ceph-mon.postinst debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
ceph-mon.prerm debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
ceph-osd-classic.install debian,ceph.spec: split ceph-osd into shared base and implementation packages 2025-11-12 18:07:29 +00:00
ceph-osd-classic.postinst debian,ceph.spec: split ceph-osd into shared base and implementation packages 2025-11-12 18:07:29 +00:00
ceph-osd-classic.prerm debian,ceph.spec: split ceph-osd into shared base and implementation packages 2025-11-12 18:07:29 +00:00
ceph-osd-crimson.install debian,ceph.spec: split ceph-osd into shared base and implementation packages 2025-11-12 18:07:29 +00:00
ceph-osd-crimson.postinst debian,ceph.spec: split ceph-osd into shared base and implementation packages 2025-11-12 18:07:29 +00:00
ceph-osd-crimson.prerm debian,ceph.spec: split ceph-osd into shared base and implementation packages 2025-11-12 18:07:29 +00:00
ceph-osd.dirs
ceph-osd.install debian,ceph.spec: split ceph-osd into shared base and implementation packages 2025-11-12 18:07:29 +00:00
ceph-osd.postinst debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
ceph-osd.prerm debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
ceph-prometheus-alerts.install debian: add ceph-grafana-dashboards package 2020-03-23 20:13:19 -05:00
ceph-resource-agents.install
ceph-test.install erasure-code: Add ceph_ec_consistency_checker into ceph_test_package 2025-07-08 14:21:08 +01:00
ceph-volume.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
cephadm.install rpm,deb: drop /etc/sudoers.d/cephadm 2020-09-03 16:31:30 +02:00
cephadm.postinst deb/cephadm: Don't assume a home directory is configured 2025-12-10 14:35:29 -06:00
cephadm.postrm files,rpm,deb: rename ceph-daemon -> cephadm 2019-12-11 19:14:09 -06:00
cephfs-mirror.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
cephfs-shell.install doc/man: build and install cephfs-shell manpage 2021-05-05 14:41:50 +08:00
cephfs-top.install spec, deb: package cephfs-top utility 2021-01-11 06:15:53 -05:00
changelog 15.2.0 2020-03-23 17:47:45 +00:00
compat debian: dh compat to 12, necessary init/systemd adjustments 2023-09-22 17:32:04 +01:00
control cmake: migrate Python module installation from setup.py to pip 2026-01-29 08:45:50 +08:00
copyright debian/copyright: update syntax, maintainer, add license stanzas 2023-09-22 17:32:03 +01:00
libcephfs2.install
libcephfs-daemon.install proxy: Add the proxy to the deb builds 2024-09-26 12:22:47 +02:00
libcephfs-dev.install cephfs: add untracked files to ceph.spec.in and debian installs 2025-07-22 10:41:00 +05:30
libcephfs-java.jlibs
libcephfs-jni.install
libcephfs-proxy2.install proxy: Add the proxy to the deb builds 2024-09-26 12:22:47 +02:00
librados2.install librados: revert librados3/libradoscc back to librados2 2019-02-20 14:59:26 -05:00
librados-dev.install debian: add libradospp* packages 2018-11-02 00:15:31 +08:00
libradospp-dev.install librados: add symbol versioning to the C++ API 2019-02-21 08:27:38 -05:00
libradosstriper1.install
libradosstriper-dev.install
librbd1.install rpm,deb: package librbd parent cache plugin with librbd 2020-05-21 14:50:33 -04:00
librbd-dev.install
librgw2.install rgw: remove unused librgw_admin_user 2020-03-25 14:12:55 -04:00
librgw-dev.install rgw: remove unused librgw_admin_user 2020-03-25 14:12:55 -04:00
libsqlite3-mod-ceph-dev.install ceph.spec,debian: package libcephsqlite 2021-03-19 08:52:55 -07:00
libsqlite3-mod-ceph.install ceph.spec,debian: package libcephsqlite 2021-03-19 08:52:55 -07:00
libsqlite3-mod-ceph.symbols debian/libsqlite3-mod-ceph: add .symbols file 2021-03-23 11:36:41 +08:00
py3dist-overrides debian: add .requires for specifying python3 deps 2022-05-31 19:42:32 +08:00
python3-ceph-argparse.install cmake,debian: install pure python module to deb_system path 2022-08-05 09:10:04 +08:00
python3-ceph-common.install ceph.spec, debian: Add python-common to ceph-common 2019-07-26 12:10:52 +02:00
python3-cephfs.install cmake: migrate Python module installation from setup.py to pip 2026-01-29 08:45:50 +08:00
python3-rados.install cmake: migrate Python module installation from setup.py to pip 2026-01-29 08:45:50 +08:00
python3-rbd.install cmake: migrate Python module installation from setup.py to pip 2026-01-29 08:45:50 +08:00
python3-rgw.install cmake: migrate Python module installation from setup.py to pip 2026-01-29 08:45:50 +08:00
rados-objclass-dev.install
radosgw.dirs
radosgw.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
radosgw.postinst debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
radosgw.prerm debian: do not use upstart to start/stop services 2024-02-04 00:19:38 +08:00
rbd-fuse.install
rbd-mirror.install deb: use variable expansion to support systemd unit dir changes 2025-06-18 17:23:28 +08:00
rbd-nbd.install rbd-nbd: quisce hook should be installed to /usr/libexec/... 2020-07-14 12:09:39 -04:00
rules Merge pull request #65936 from tchaikov/wip-build-cephadm-with-deb 2025-11-14 21:17:55 +08:00
watch