From 6a99eec653fc461a3621e41f2a121702f8539c88 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 9 Jul 2016 12:58:33 +0800 Subject: [PATCH] cmake: put cythonized .c files into ${CMAKE_CURRENT_BINARY_DIR} it was put into the directory where .pyx is located. it's not expected in an out-of-tree build. * {rados,rbd,cephfs}/setup.py: use build_ext from cython if possible, fallback to the one from setuptools or distutils * Distutils.cmake: pass --cython-c-in-temp --build-temp and --cython-include-dirs to "build_ext" command Signed-off-by: Kefu Chai --- cmake/modules/Distutils.cmake | 1 + src/pybind/cephfs/setup.py | 3 +++ src/pybind/rados/setup.py | 7 +++++-- src/pybind/rbd/setup.py | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmake/modules/Distutils.cmake b/cmake/modules/Distutils.cmake index 6ba1c378b92..aefcf707e7f 100644 --- a/cmake/modules/Distutils.cmake +++ b/cmake/modules/Distutils.cmake @@ -70,6 +70,7 @@ function(distutils_install_cython_module name) CFLAGS=\"-iquote ${CMAKE_SOURCE_DIR}/src/include\" ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py build --build-base ${CYTHON_MODULE_DIR} --verbose + build_ext --cython-c-in-temp --build-temp ${CMAKE_CURRENT_BINARY_DIR} --cython-include-dirs ${PROJECT_SOURCE_DIR}/src/pybind/rados install \${options} --single-version-externally-managed --record /dev/null egg_info --egg-base ${CMAKE_CURRENT_BINARY_DIR} --verbose diff --git a/src/pybind/cephfs/setup.py b/src/pybind/cephfs/setup.py index 371358b0dab..f95cb65a32b 100755 --- a/src/pybind/cephfs/setup.py +++ b/src/pybind/cephfs/setup.py @@ -6,6 +6,8 @@ from setuptools.command.egg_info import egg_info from distutils.core import setup from distutils.extension import Extension from Cython.Build import cythonize +from Cython.Distutils import build_ext + def get_version(): try: @@ -48,6 +50,7 @@ setup( os.path.join(os.path.dirname(__file__), "..", "rados")] ), cmdclass={ + "build_ext": build_ext, "egg_info": EggInfoCommand, }, ) diff --git a/src/pybind/rados/setup.py b/src/pybind/rados/setup.py index 9e152bd081f..b3662b2f37a 100755 --- a/src/pybind/rados/setup.py +++ b/src/pybind/rados/setup.py @@ -130,8 +130,11 @@ def check_sanity(): if not check_sanity(): sys.exit(1) +cmdclass = {} 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.") @@ -141,8 +144,6 @@ except ImportError: else: def cythonize(x, **kwargs): return x - - source = "rados.c" else: source = "rados.pyx" @@ -169,6 +170,7 @@ setup( ), url='https://github.com/ceph/ceph/tree/master/src/pybind/rados', license='LGPLv2+', + platforms='Linux', ext_modules=cythonize( [ Extension( @@ -191,4 +193,5 @@ setup( 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5' ], + cmdclass=cmdclass, ) diff --git a/src/pybind/rbd/setup.py b/src/pybind/rbd/setup.py index 79d4d588e25..c6166f89300 100755 --- a/src/pybind/rbd/setup.py +++ b/src/pybind/rbd/setup.py @@ -6,6 +6,7 @@ from setuptools.command.egg_info import egg_info from distutils.core import setup from distutils.extension import Extension from Cython.Build import cythonize +from Cython.Distutils import build_ext def get_version(): try: @@ -49,5 +50,6 @@ setup( ), cmdclass={ "egg_info": EggInfoCommand, + "build_ext": build_ext, }, ) -- 2.39.5