fix tests on macOS

This commit is contained in:
Philipp Moritz
2016-07-24 21:24:26 -07:00
parent 0a26135821
commit 5f337db809
4 changed files with 51 additions and 16 deletions
+37 -2
View File
@@ -4,8 +4,37 @@ project(numbuf)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
find_package(PythonInterp REQUIRED)
find_package(PythonLibs REQUIRED)
if(NOT APPLE)
find_package(PythonInterp REQUIRED)
find_package(PythonLibs REQUIRED)
set(CUSTOM_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
else()
find_program(CUSTOM_PYTHON_EXECUTABLE python)
message("-- Found Python program: ${CUSTOM_PYTHON_EXECUTABLE}")
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c
"import sys; print 'python' + sys.version[0:3]"
OUTPUT_VARIABLE PYTHON_LIBRARY_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c
"import sys; print sys.exec_prefix"
OUTPUT_VARIABLE PYTHON_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
FIND_LIBRARY(PYTHON_LIBRARIES
NAMES ${PYTHON_LIBRARY_NAME}
HINTS "${PYTHON_PREFIX}"
PATH_SUFFIXES "lib" "libs"
NO_DEFAULT_PATH)
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c
"from distutils.sysconfig import *; print get_python_inc()"
OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE)
if(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS)
SET(PYTHONLIBS_FOUND TRUE)
message("-- Found PythonLibs: " ${PYTHON_LIBRARIES})
message("-- -- Used custom search path")
else()
find_package(PythonLibs REQUIRED)
message("-- -- Used find_package(PythonLibs)")
endif()
endif()
find_package(NumPy REQUIRED)
if(APPLE)
@@ -41,4 +70,10 @@ add_library(numbuf SHARED
python/src/pynumbuf/adapters/numpy.cc
python/src/pynumbuf/adapters/python.cc)
if(APPLE)
add_custom_command(TARGET numbuf
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -change ${PYTHON_SHARED_LIBRARY} ${PYTHON_LIBRARIES} libnumbuf.so)
endif(APPLE)
target_link_libraries(numbuf ${ARROW_STATIC_LIB} ${PYTHON_LIBRARIES})
+3 -3
View File
@@ -14,8 +14,8 @@
unset(NUMPY_VERSION)
unset(NUMPY_INCLUDE_DIR)
if(PYTHONINTERP_FOUND)
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
if(NOT "${CUSTOM_PYTHON_EXECUTABLE}" STREQUAL "CUSTOM_PYTHON_EXECUTABLE-NOTFOUND")
execute_process(COMMAND "${CUSTOM_PYTHON_EXECUTABLE}" "-c"
"import numpy as n; print(n.__version__); print(n.get_include());"
RESULT_VARIABLE __result
OUTPUT_VARIABLE __output
@@ -42,7 +42,7 @@ if(PYTHONINTERP_FOUND)
endif()
endif()
else()
message(STATUS "To find NumPy Python interpretator is required to be found.")
message(STATUS "To find NumPy Python executable is required to be found.")
endif()
include(FindPackageHandleStandardArgs)
+10 -10
View File
@@ -16,6 +16,12 @@
using namespace arrow;
using namespace numbuf;
std::shared_ptr<RowBatch> make_row_batch(std::shared_ptr<Array> data) {
auto field = std::make_shared<Field>("list", data->type());
std::shared_ptr<Schema> schema(new Schema({field}));
return std::shared_ptr<RowBatch>(new RowBatch(schema, data->length(), {data}));
}
extern "C" {
static PyObject *NumbufError;
@@ -34,12 +40,6 @@ static void ArrowCapsule_Destructor(PyObject* capsule) {
delete reinterpret_cast<std::shared_ptr<RowBatch>*>(PyCapsule_GetPointer(capsule, "arrow"));
}
std::shared_ptr<RowBatch> make_row_batch(std::shared_ptr<Array> data) {
auto field = std::make_shared<Field>("list", data->type());
std::shared_ptr<Schema> schema(new Schema({field}));
return std::shared_ptr<RowBatch>(new RowBatch(schema, data->length(), {data}));
}
/*! Serializes a Python list into an Arrow array.
\param args
@@ -52,7 +52,7 @@ std::shared_ptr<RowBatch> make_row_batch(std::shared_ptr<Array> data) {
A Python "arrow" capsule containing the RowBatch
*/
PyObject* serialize_list(PyObject* self, PyObject* args) {
static PyObject* serialize_list(PyObject* self, PyObject* args) {
PyObject* value;
if (!PyArg_ParseTuple(args, "O", &value)) {
return NULL;
@@ -94,7 +94,7 @@ PyObject* serialize_list(PyObject* self, PyObject* args) {
\return
The arrow metadata offset for the arrow metadata
*/
PyObject* write_to_buffer(PyObject* self, PyObject* args) {
static PyObject* write_to_buffer(PyObject* self, PyObject* args) {
std::shared_ptr<RowBatch>* batch;
PyObject* memoryview;
if (!PyArg_ParseTuple(args, "O&O", &PyObjectToArrow, &batch, &memoryview)) {
@@ -119,7 +119,7 @@ PyObject* write_to_buffer(PyObject* self, PyObject* args) {
\return
A Python "arrow" capsule containing the arrow RowBatch
*/
PyObject* read_from_buffer(PyObject* self, PyObject* args) {
static PyObject* read_from_buffer(PyObject* self, PyObject* args) {
PyObject* memoryview;
PyObject* metadata;
int64_t metadata_offset;
@@ -149,7 +149,7 @@ PyObject* read_from_buffer(PyObject* self, PyObject* args) {
/*!
*/
PyObject* deserialize_list(PyObject* self, PyObject* args) {
static PyObject* deserialize_list(PyObject* self, PyObject* args) {
std::shared_ptr<RowBatch>* data;
if (!PyArg_ParseTuple(args, "O&", &PyObjectToArrow, &data)) {
return NULL;
+1 -1
View File
@@ -5,7 +5,7 @@ from numpy.testing import assert_equal
TEST_OBJECTS = [[1, "hello", 3.0], 42, 43L, "hello world", 42.0, 1L << 62,
(1.0, "hi"), None, (None, None), ("hello", None),
True, False, (True, False),
True, False, (True, False), "hello",
{True: "hello", False: "world"},
{"hello" : "world", 1: 42, 1.0: 45}, {},
np.int8(3), np.int32(4), np.int64(5),