Skip to content

Commit

Permalink
pybind: Replace -I with -iquote in cephfs test
Browse files Browse the repository at this point in the history
Signed-off-by: Anirudha Bose <[email protected]>
  • Loading branch information
onyb committed Jul 19, 2016
1 parent a78cdff commit d0ff714
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
25 changes: 15 additions & 10 deletions src/pybind/cephfs/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,19 @@ def check_sanity():
"""
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;
Expand All @@ -86,21 +91,21 @@ def check_sanity():
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,
)
Expand Down
24 changes: 15 additions & 9 deletions src/pybind/rados/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ def check_sanity():
"""
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')
Expand All @@ -98,19 +103,18 @@ def check_sanity():
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,
)
Expand All @@ -134,6 +138,7 @@ def check_sanity():
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.")
Expand All @@ -144,6 +149,7 @@ def check_sanity():
else:
def cythonize(x, **kwargs):
return x

source = "rados.c"
else:
source = "rados.pyx"
Expand Down

0 comments on commit d0ff714

Please sign in to comment.