mirror of
https://github.com/apache/arrow.git
synced 2026-10-28 16:47:19 +08:00
use cmake to build the cython extension
This commit is contained in:
1 parent
bf392977ae
commit
3c4de5237b
3 files changed
+77
-12
No files matched your search
@@ -29,7 +29,6 @@ function build_arrow_libraries() {
|
||||
|
||||
cmake -DARROW_BUILD_TESTS=off \
|
||||
-DARROW_PYTHON=on \
|
||||
-DPLASMA_PYTHON=on \
|
||||
-DARROW_PLASMA=on \
|
||||
-DCMAKE_INSTALL_PREFIX=$2 \
|
||||
$CPP_DIR
|
||||
@@ -81,6 +80,20 @@ python_version_tests() {
|
||||
python setup.py install
|
||||
popd
|
||||
|
||||
# Make python plasma extension
|
||||
pushd $CPP_BUILD_DIR
|
||||
|
||||
cmake -DARROW_BUILD_TESTS=off \
|
||||
-DARROW_PYTHON=on \
|
||||
-DPLASMA_PYTHON=on \
|
||||
-DARROW_PLASMA=on \
|
||||
-DCMAKE_INSTALL_PREFIX=$2 \
|
||||
$CPP_DIR
|
||||
|
||||
make -j4
|
||||
|
||||
popd
|
||||
|
||||
# Build and install plasma
|
||||
pushd $TRAVIS_BUILD_DIR/cpp/src/plasma
|
||||
python setup.py install
|
||||
@@ -88,7 +101,7 @@ python_version_tests() {
|
||||
}
|
||||
|
||||
# run tests for python 2.7 and 3.6
|
||||
python_version_tests 2.7
|
||||
# python_version_tests 2.7
|
||||
python_version_tests 3.6
|
||||
|
||||
popd
|
||||
@@ -19,6 +19,8 @@ cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(plasma)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../python/cmake_modules")
|
||||
|
||||
find_package(PythonLibsNew REQUIRED)
|
||||
find_package(Threads)
|
||||
|
||||
@@ -101,3 +103,19 @@ ADD_ARROW_TEST(test/serialization_tests)
|
||||
ARROW_TEST_LINK_LIBRARIES(test/serialization_tests plasma_static)
|
||||
ADD_ARROW_TEST(test/client_tests)
|
||||
ARROW_TEST_LINK_LIBRARIES(test/client_tests plasma_static)
|
||||
|
||||
if (PLASMA_PYTHON)
|
||||
include(UseCython)
|
||||
find_package(NumPy REQUIRED)
|
||||
|
||||
include_directories(SYSTEM
|
||||
${NUMPY_INCLUDE_DIRS}
|
||||
${PYTHON_INCLUDE_DIRS})
|
||||
|
||||
set_source_files_properties(plasma.pyx PROPERTIES CYTHON_IS_CXX 1)
|
||||
|
||||
cython_add_module(plasma
|
||||
plasma_pyx
|
||||
plasma_output
|
||||
plasma.pyx)
|
||||
endif()
|
||||
+44
-10
@@ -15,15 +15,49 @@
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from setuptools import setup, find_packages, Extension
|
||||
from Cython.Build import cythonize
|
||||
import os
|
||||
import shutil
|
||||
|
||||
extensions = [
|
||||
Extension(
|
||||
'plasma',
|
||||
["plasma.pyx"],
|
||||
language="c++",
|
||||
extra_link_args=["../../build/debug/libplasma.a", "../../build/debug/libarrow.a"],
|
||||
extra_compile_args=["-std=c++11", "-I.", "-I..", "-I../../../cpp/build/flatbuffers_ep-prefix/src/flatbuffers_ep-install/include"])]
|
||||
from setuptools import setup, find_packages, Distribution
|
||||
import setuptools.command.build_ext as _build_ext
|
||||
|
||||
setup(ext_modules = cythonize(extensions))
|
||||
class build_ext(_build_ext.build_ext):
|
||||
def run(self):
|
||||
# Ideally, we could include these files by putting them in a MANIFEST.in or
|
||||
# using the package_data argument to setup, but the MANIFEST.in gets
|
||||
# applied at the very beginning when setup.py runs before these files have
|
||||
# been created, so we have to move the files manually.
|
||||
for filename in files_to_include:
|
||||
self.move_file(filename)
|
||||
|
||||
def move_file(self, filename):
|
||||
# TODO(rkn): This feels very brittle. It may not handle all cases. See
|
||||
# https://github.com/apache/arrow/blob/master/python/setup.py for an
|
||||
# example.
|
||||
source = filename
|
||||
destination = os.path.join(self.build_lib, filename)
|
||||
# Create the target directory if it doesn't already exist.
|
||||
parent_directory = os.path.dirname(destination)
|
||||
if not os.path.exists(parent_directory):
|
||||
os.makedirs(parent_directory)
|
||||
print("Copying {} to {}.".format(source, destination))
|
||||
shutil.copy(source, destination)
|
||||
|
||||
files_to_include = [
|
||||
"../../../python/arrow-build-3.6/debug/plasma.cpython-36m-x86_64-linux-gnu.so"
|
||||
]
|
||||
|
||||
class BinaryDistribution(Distribution):
|
||||
def has_ext_modules(self):
|
||||
return True
|
||||
|
||||
setup(name="plasma",
|
||||
version="0.0.1",
|
||||
packages=find_packages(),
|
||||
cmdclass={"build_ext": build_ext},
|
||||
# The BinaryDistribution argument triggers build_ext.
|
||||
distclass=BinaryDistribution,
|
||||
install_requires=["numpy"],
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
license="Apache 2.0")
|
||||
Reference in new issue
Block a user