]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
pybind/rados: use stub implementations when building document
authorKefu Chai <kchai@redhat.com>
Thu, 3 Dec 2020 06:40:42 +0000 (14:40 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 5 Dec 2020 14:09:21 +0000 (22:09 +0800)
commit98ab937a3a42076a45d0b838b53a37b9782ddb2b
tree6d4d374ac32ad8a08f16af2dd5c8a101d1cf68a6
parent645a05067dd3bc2ee7bcec342696bc1f307640cc
pybind/rados: use stub implementations when building document

* setup.py: inject "BUILD_DOC" into cython build context if "BUILD_DOC"
    env variable is set, this helps us to do conditional compilation.
    for instance, if we are building document, there is no need to
    use the header files or link against librados.so for building
    the python bindings.
* mock_rados.pxi: implement the mock functinons for their C counterparts
    in librados, so we can use them when building librados python
    binding for creating the document. Sphinx's autodoc extension
    reads annotation of the python package whose document is being
    built, after importing the python package into python runtime.
    but since we use Cython for creating our python binding,
    we have to provide the implementation of those referenced
    librados C API symbols. mock_rados.pxi implements them using Cython.
    the downside of this solution is that we need to mirror every
    function used by the Python binding by repeating them in both
    c_rados.pxd and mock_rados.pxi. the same will apply to other
    Ceph python bindings as long as they use C APIs not offered by
    libc or python runtime. so next step is to develop a simple
    parser which can be run at build time to create mock_*.pxi from
    c_*.pxd.
* rados.pyx: use mock_rados.pxi if BUILD_DOC, otherwise use
    c_rados.pyd. the latter requires a librados.so at runtime.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/rados/mock_rados.pxi [new file with mode: 0644]
src/pybind/rados/rados.pxd
src/pybind/rados/rados.pyx
src/pybind/rados/setup.py