"""
Test if development headers and library for cephfs is available by compiling a dummy C program.
"""
+ CEPH_SRC_DIR = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ '..',
+ '..'
+ )
tmp_dir = tempfile.mkdtemp(dir=os.environ.get('TMPDIR', os.path.dirname(__file__)))
tmp_file = os.path.join(tmp_dir, 'cephfs_dummy.c')
with open(tmp_file, 'w') as fp:
dummy_prog = textwrap.dedent("""
#include <stddef.h>
- #include <cephfs/libcephfs.h>
+ #include "cephfs/libcephfs.h"
int main(void) {
struct ceph_mount_info *cmount = NULL;
if {'MAKEFLAGS', 'MFLAGS', 'MAKELEVEL'}.issubset(set(os.environ.keys())):
# The setup.py has been invoked by a top-level Ceph make.
# Set the appropriate CFLAGS and LDFLAGS
- CEPH_SRC_DIR = os.path.join(
- os.path.dirname(os.path.abspath(__file__)),
- '..',
- '..'
- )
- compiler.set_include_dirs(os.path.join(CEPH_SRC_DIR, 'include'))
- compiler.add_library_dir(os.environ.get('CEPH_LIBDIR'))
+ compiler.set_library_dirs([os.environ.get('CEPH_LIBDIR')])
try:
compiler.define_macro('_FILE_OFFSET_BITS', '64')
+ link_objects = compiler.compile(
+ sources=[tmp_file],
+ output_dir=tmp_dir,
+ extra_preargs=['-iquote{path}'.format(path=os.path.join(CEPH_SRC_DIR, 'include'))]
+ )
+
compiler.link_executable(
- compiler.compile([tmp_file], tmp_dir),
- os.path.join(tmp_dir, 'cephfs_dummy'),
+ objects=link_objects,
+ output_progname=os.path.join(tmp_dir, 'cephfs_dummy'),
libraries=['cephfs', 'rados'],
output_dir=tmp_dir,
)
"""
Test if development headers and library for rados is available by compiling a dummy C program.
"""
+ CEPH_SRC_DIR = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ '..',
+ '..'
+ )
tmp_dir = tempfile.mkdtemp(dir=os.environ.get('TMPDIR', os.path.dirname(__file__)))
tmp_file = os.path.join(tmp_dir, 'rados_dummy.c')
if {'MAKEFLAGS', 'MFLAGS', 'MAKELEVEL'}.issubset(set(os.environ.keys())):
# The setup.py has been invoked by a top-level Ceph make.
# Set the appropriate CFLAGS and LDFLAGS
- CEPH_SRC_DIR = os.path.join(
- os.path.dirname(os.path.abspath(__file__)),
- '..',
- '..'
- )
- compiler.set_include_dirs(os.path.join(CEPH_SRC_DIR, 'include'))
- compiler.add_library_dir(os.environ.get('CEPH_LIBDIR'))
+ compiler.set_include_dirs([os.path.join(CEPH_SRC_DIR, 'include')])
+ compiler.set_library_dirs([os.environ.get('CEPH_LIBDIR')])
try:
+ link_objects = compiler.compile(
+ sources=[tmp_file],
+ output_dir=tmp_dir
+ )
compiler.link_executable(
- compiler.compile([tmp_file], tmp_dir),
- os.path.join(tmp_dir, 'rados_dummy'),
+ objects=link_objects,
+ output_progname=os.path.join(tmp_dir, 'rados_dummy'),
libraries=['rados'],
output_dir=tmp_dir,
)
try:
from Cython.Build import cythonize
from Cython.Distutils import build_ext
+
cmdclass = {'build_ext': build_ext}
except ImportError:
print("WARNING: Cython is not installed.")
else:
def cythonize(x, **kwargs):
return x
+
source = "rados.c"
else:
source = "rados.pyx"