]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rgw: use stub implementations when building document
authorKefu Chai <kchai@redhat.com>
Thu, 3 Dec 2020 08:06:22 +0000 (16:06 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 5 Dec 2020 14:09:21 +0000 (22:09 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/rgw/mock_rgw.pxi [new file with mode: 0644]
src/pybind/rgw/rgw.pyx
src/pybind/rgw/setup.py

diff --git a/src/pybind/rgw/mock_rgw.pxi b/src/pybind/rgw/mock_rgw.pxi
new file mode 100644 (file)
index 0000000..ca893a5
--- /dev/null
@@ -0,0 +1,156 @@
+# cython: embedsignature=True
+
+cdef nogil:
+    ctypedef void* librgw_t
+
+    int librgw_create(librgw_t *rgw, int argc, char **argv):
+        pass
+    void librgw_shutdown(librgw_t rgw):
+        pass
+
+
+cdef nogil:
+    enum:
+        RGW_FS_TYPE_FILE
+        RGW_FS_TYPE_DIRECTORY
+
+        RGW_LOOKUP_FLAG_CREATE
+
+        RGW_SETATTR_MODE
+        RGW_SETATTR_UID
+        RGW_SETATTR_GID
+        RGW_SETATTR_MTIME
+        RGW_SETATTR_ATIME
+        RGW_SETATTR_SIZE
+        RGW_SETATTR_CTIME
+
+        RGW_READDIR_FLAG_NONE
+        RGW_READDIR_FLAG_DOTDOT
+
+        RGW_OPEN_FLAG_CREATE
+        RGW_OPEN_FLAG_V3         # ops have v3 semantics
+        RGW_OPEN_FLAG_STATELESS  # alias it
+
+        RGW_CLOSE_FLAG_RELE
+
+    ctypedef void *rgw_fh_hk
+    cdef struct rgw_file_handle:
+        rgw_fh_hk fh_hk
+        void *fs_private
+        int fh_type
+
+    cdef struct rgw_fs:
+        librgw_t rgw
+        void *fs_private
+        void *root_fh
+
+    # mount info hypothetical--emulate Unix, support at least UUID-length fsid
+    cdef struct rgw_statvfs:
+        uint64_t  f_bsize    # file system block size
+        uint64_t  f_frsize   # fragment size
+        uint64_t  f_blocks   # size of fs in f_frsize units
+        uint64_t  f_bfree    # free blocks
+        uint64_t  f_bavail   # free blocks for unprivileged users
+        uint64_t  f_files    # inodes
+        uint64_t  f_ffree    # free inodes
+        uint64_t  f_favail   # free inodes for unprivileged users
+        uint64_t  f_fsid[2]  # /* file system ID
+        uint64_t  f_flag     # mount flags
+        uint64_t  f_namemax  # maximum filename length
+
+    void rgwfile_version(int *major, int *minor, int *extra):
+        pass
+
+    int rgw_lookup(rgw_fs *fs,
+                   rgw_file_handle *parent_fh, const char *path,
+                   rgw_file_handle **fh, stat* st, uint32_t st_mask,
+                  uint32_t flags):
+        pass
+
+    int rgw_lookup_handle(rgw_fs *fs, rgw_fh_hk *fh_hk,
+                          rgw_file_handle **fh, uint32_t flags):
+        pass
+
+    int rgw_fh_rele(rgw_fs *fs, rgw_file_handle *fh,
+                    uint32_t flags):
+        pass
+
+    int rgw_mount(librgw_t rgw, const char *uid, const char *key,
+                  const char *secret, rgw_fs **fs, uint32_t flags):
+        pass
+
+    int rgw_umount(rgw_fs *fs, uint32_t flags):
+        pass
+
+    int rgw_statfs(rgw_fs *fs, rgw_file_handle *parent_fh,
+                   rgw_statvfs *vfs_st, uint32_t flags):
+        pass
+
+    int rgw_create(rgw_fs *fs, rgw_file_handle *parent_fh,
+                   const char *name, stat *st, uint32_t mask,
+                   rgw_file_handle **fh, uint32_t posix_flags,
+                   uint32_t flags):
+        pass
+
+    int rgw_mkdir(rgw_fs *fs,
+                  rgw_file_handle *parent_fh,
+                  const char *name, stat *st, uint32_t mask,
+                  rgw_file_handle **fh, uint32_t flags):
+        pass
+
+    int rgw_rename(rgw_fs *fs,
+                   rgw_file_handle *olddir, const char* old_name,
+                   rgw_file_handle *newdir, const char* new_name,
+                   uint32_t flags):
+        pass
+
+    int rgw_unlink(rgw_fs *fs,
+                   rgw_file_handle *parent_fh, const char* path,
+                   uint32_t flags):
+        pass
+
+    int rgw_readdir(rgw_fs *fs,
+                    rgw_file_handle *parent_fh, uint64_t *offset,
+                    bint (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000,
+                    void *cb_arg, bint *eof, uint32_t flags) except? -9000:
+        pass
+
+    int rgw_getattr(rgw_fs *fs,
+                    rgw_file_handle *fh, stat *st,
+                    uint32_t flags):
+        pass
+
+    int rgw_setattr(rgw_fs *fs, rgw_file_handle *fh, stat *st,
+                    uint32_t mask, uint32_t flags):
+        pass
+
+    int rgw_truncate(rgw_fs *fs, rgw_file_handle *fh, uint64_t size, uint32_t flags):
+        pass
+
+    int rgw_open(rgw_fs *fs, rgw_file_handle *parent_fh,
+                 uint32_t posix_flags, uint32_t flags):
+        pass
+
+    int rgw_close(rgw_fs *fs, rgw_file_handle *fh,
+                  uint32_t flags):
+        pass
+
+    int rgw_read(rgw_fs *fs,
+                 rgw_file_handle *fh, uint64_t offset,
+                 size_t length, size_t *bytes_read, void *buffer,
+                 uint32_t flags):
+        pass
+
+    int rgw_write(rgw_fs *fs,
+                  rgw_file_handle *fh, uint64_t offset,
+                  size_t length, size_t *bytes_written, void *buffer,
+                  uint32_t flags):
+        pass
+
+    int rgw_fsync(rgw_fs *fs, rgw_file_handle *fh,
+                  uint32_t flags):
+        pass
+
+    int rgw_commit(rgw_fs *fs, rgw_file_handle *fh,
+                   uint64_t offset, uint64_t length, uint32_t flags):
+        pass
index 123c57d2ee009a4367b5a3b9dc6d85ddbade3a58..9bbcdfff586a8a842095a80678a4abf08c8409c8 100644 (file)
@@ -8,8 +8,11 @@ from libc.stdint cimport *
 from libc.stdlib cimport malloc, realloc, free
 from cstat cimport stat
 
-from c_rgw cimport *
-cimport rados
+IF BUILD_DOC:
+    include "mock_rgw.pxi"
+ELSE:
+    from c_rgw cimport *
+    cimport rados
 
 from collections import namedtuple
 from datetime import datetime
index 518fa9f81bc2276be97132509ab7a6eee0d2644d..0ceab665d750a218f0aaf0ad69e85f332e9792e5 100755 (executable)
@@ -10,7 +10,6 @@ import distutils.core
 
 import os
 import shutil
-import subprocess
 import sys
 import tempfile
 import textwrap
@@ -137,10 +136,16 @@ def check_sanity():
         shutil.rmtree(tmp_dir)
 
 
-if 'BUILD_DOC' in os.environ.keys():
-    pass
+if 'BUILD_DOC' in os.environ:
+    ext_args = {}
+    cython_constants = dict(BUILD_DOC=True)
+    cythonize_args = dict(compile_time_env=cython_constants)
 elif check_sanity():
-    pass
+    ext_args = get_python_flags(['rados', 'rgw'])
+    cython_constants = dict(BUILD_DOC=False)
+    include_path = [os.path.join(os.path.dirname(__file__), "..", "rados")]
+    cythonize_args = dict(compile_time_env=cython_constants,
+                          include_path=include_path)
 else:
     sys.exit(1)
 
@@ -190,14 +195,12 @@ setup(
             Extension(
                 "rgw",
                 [source],
-                **get_python_flags(['rados', 'rgw'])
+                **ext_args
             )
         ],
         compiler_directives={'language_level': sys.version_info.major},
         build_dir=os.environ.get("CYTHON_BUILD_DIR", None),
-        include_path=[
-            os.path.join(os.path.dirname(__file__), "..", "rados")
-        ]
+        **cythonize_args
     ),
     classifiers=[
         'Intended Audience :: Developers',