mirror of
https://github.com/apache/arrow.git
synced 2026-10-28 16:47:19 +08:00
WIP MSVC support for PyArrow. Linker errors
This commit is contained in:
1 parent
30e03a9071
commit
0a2d3874bd
19 files changed
+53
-55
No files matched your search
@@ -17,18 +17,18 @@ if (ARROW_BUILD_TESTS)
|
||||
add_library(arrow_python_test_main STATIC
|
||||
util/test_main.cc)
|
||||
|
||||
target_link_libraries(arrow_python_test_main
|
||||
gtest)
|
||||
|
||||
if (APPLE)
|
||||
target_link_libraries(arrow_python_test_main
|
||||
gtest
|
||||
dl)
|
||||
${CMAKE_DL_LIBS})
|
||||
set_target_properties(arrow_python_test_main
|
||||
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
|
||||
else()
|
||||
elseif(NOT MSVC)
|
||||
target_link_libraries(arrow_python_test_main
|
||||
gtest
|
||||
pthread
|
||||
dl
|
||||
)
|
||||
${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -38,12 +38,6 @@ set(ARROW_PYTHON_MIN_TEST_LIBS
|
||||
arrow_static
|
||||
${BOOST_REGEX_LIBRARY})
|
||||
|
||||
if(ARROW_BUILD_TESTS)
|
||||
ADD_THIRDPARTY_LIB(python
|
||||
SHARED_LIB "${PYTHON_LIBRARIES}")
|
||||
list(APPEND ARROW_PYTHON_MIN_TEST_LIBS python)
|
||||
endif()
|
||||
|
||||
set(ARROW_PYTHON_TEST_LINK_LIBS ${ARROW_PYTHON_MIN_TEST_LIBS})
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
@@ -66,9 +60,13 @@ ADD_ARROW_LIB(arrow_python
|
||||
SOURCES ${ARROW_PYTHON_SRCS}
|
||||
SHARED_LINK_FLAGS ""
|
||||
SHARED_LINK_LIBS ${ARROW_PYTHON_SHARED_LINK_LIBS}
|
||||
STATIC_LINK_LIBS ${ARROW_IO_SHARED_PRIVATE_LINK_LIBS}
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
target_link_libraries(arrow_python_shared
|
||||
${PYTHON_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if ("${COMPILER_FAMILY}" STREQUAL "clang")
|
||||
# Clang, be quiet. Python C API has lots of macros
|
||||
set_property(SOURCE ${ARROW_PYTHON_SRCS}
|
||||
@@ -91,10 +89,9 @@ install(FILES
|
||||
type_traits.h
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/arrow/python")
|
||||
|
||||
# set_target_properties(arrow_python_shared PROPERTIES
|
||||
# INSTALL_RPATH "\$ORIGIN")
|
||||
|
||||
if (ARROW_BUILD_TESTS)
|
||||
ADD_ARROW_TEST(python-test
|
||||
STATIC_LINK_LIBS "${ARROW_PYTHON_TEST_LINK_LIBS}")
|
||||
target_link_libraries(python-test
|
||||
${PYTHON_LIBRARIES})
|
||||
endif()
|
||||
@@ -15,7 +15,8 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include <datetime.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -21,13 +21,12 @@
|
||||
#ifndef ARROW_PYTHON_ADAPTERS_BUILTIN_H
|
||||
#define ARROW_PYTHON_ADAPTERS_BUILTIN_H
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "arrow/type.h"
|
||||
|
||||
#include "arrow/util/visibility.h"
|
||||
|
||||
#include "arrow/python/common.h"
|
||||
|
||||
@@ -32,7 +32,7 @@ class MemoryPool;
|
||||
|
||||
namespace py {
|
||||
|
||||
class PyAcquireGIL {
|
||||
class ARROW_EXPORT PyAcquireGIL {
|
||||
public:
|
||||
PyAcquireGIL() { state_ = PyGILState_Ensure(); }
|
||||
|
||||
@@ -45,7 +45,7 @@ class PyAcquireGIL {
|
||||
|
||||
#define PYARROW_IS_PY2 PY_MAJOR_VERSION <= 2
|
||||
|
||||
class OwnedRef {
|
||||
class ARROW_EXPORT OwnedRef {
|
||||
public:
|
||||
OwnedRef() : obj_(nullptr) {}
|
||||
|
||||
@@ -70,7 +70,7 @@ class OwnedRef {
|
||||
PyObject* obj_;
|
||||
};
|
||||
|
||||
struct PyObjectStringify {
|
||||
struct ARROW_EXPORT PyObjectStringify {
|
||||
OwnedRef tmp_obj;
|
||||
const char* bytes;
|
||||
Py_ssize_t size;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
#include <datetime.h>
|
||||
|
||||
#include "arrow/python/config.h"
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
#ifndef ARROW_PYTHON_CONFIG_H
|
||||
#define ARROW_PYTHON_CONFIG_H
|
||||
|
||||
#include <iostream>
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include "arrow/python/numpy_interop.h"
|
||||
#include "arrow/util/visibility.h"
|
||||
|
||||
@@ -92,11 +92,11 @@ Status PythonDecimalToArrowDecimal(
|
||||
return FromString(c_string, arrow_decimal);
|
||||
}
|
||||
|
||||
template Status PythonDecimalToArrowDecimal(
|
||||
template Status ARROW_TEMPLATE_EXPORT PythonDecimalToArrowDecimal(
|
||||
PyObject* python_decimal, decimal::Decimal32* arrow_decimal);
|
||||
template Status PythonDecimalToArrowDecimal(
|
||||
template Status ARROW_TEMPLATE_EXPORT PythonDecimalToArrowDecimal(
|
||||
PyObject* python_decimal, decimal::Decimal64* arrow_decimal);
|
||||
template Status PythonDecimalToArrowDecimal(
|
||||
template Status ARROW_TEMPLATE_EXPORT PythonDecimalToArrowDecimal(
|
||||
PyObject* python_decimal, decimal::Decimal128* arrow_decimal);
|
||||
|
||||
Status InferDecimalPrecisionAndScale(
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef PYARROW_HELPERS_H
|
||||
#define PYARROW_HELPERS_H
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -42,18 +42,18 @@ class OwnedRef;
|
||||
|
||||
ARROW_EXPORT std::shared_ptr<DataType> GetPrimitiveType(Type::type type);
|
||||
|
||||
Status ImportModule(const std::string& module_name, OwnedRef* ref);
|
||||
Status ImportFromModule(
|
||||
Status ARROW_EXPORT ImportModule(const std::string& module_name, OwnedRef* ref);
|
||||
Status ARROW_EXPORT ImportFromModule(
|
||||
const OwnedRef& module, const std::string& module_name, OwnedRef* ref);
|
||||
|
||||
template <typename T>
|
||||
Status PythonDecimalToArrowDecimal(
|
||||
Status ARROW_EXPORT PythonDecimalToArrowDecimal(
|
||||
PyObject* python_decimal, decimal::Decimal<T>* arrow_decimal);
|
||||
|
||||
Status InferDecimalPrecisionAndScale(
|
||||
Status ARROW_EXPORT InferDecimalPrecisionAndScale(
|
||||
PyObject* python_decimal, int* precision = nullptr, int* scale = nullptr);
|
||||
|
||||
Status DecimalFromString(
|
||||
Status ARROW_EXPORT DecimalFromString(
|
||||
PyObject* decimal_constructor, const std::string& decimal_string, PyObject** out);
|
||||
|
||||
} // namespace py
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace py {
|
||||
|
||||
// A common interface to a Python file-like object. Must acquire GIL before
|
||||
// calling any methods
|
||||
class PythonFile {
|
||||
class ARROW_EXPORT PythonFile {
|
||||
public:
|
||||
explicit PythonFile(PyObject* file);
|
||||
~PythonFile();
|
||||
|
||||
@@ -20,13 +20,12 @@
|
||||
#ifndef ARROW_PYTHON_NUMPY_INTERNAL_H
|
||||
#define ARROW_PYTHON_NUMPY_INTERNAL_H
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/numpy_interop.h"
|
||||
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "arrow/python/numpy_convert.h"
|
||||
#include "arrow/python/numpy_interop.h"
|
||||
|
||||
namespace arrow {
|
||||
namespace py {
|
||||
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/numpy_interop.h"
|
||||
|
||||
#include "arrow/python/numpy_convert.h"
|
||||
#include "arrow/python/numpy_interop.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
@@ -38,8 +37,8 @@ namespace py {
|
||||
|
||||
bool is_contiguous(PyObject* array) {
|
||||
if (PyArray_Check(array)) {
|
||||
return PyArray_FLAGS(reinterpret_cast<PyArrayObject*>(array)) &
|
||||
(NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS);
|
||||
return (PyArray_FLAGS(reinterpret_cast<PyArrayObject*>(array)) &
|
||||
(NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS)) != 0;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef ARROW_PYTHON_NUMPY_CONVERT_H
|
||||
#define ARROW_PYTHON_NUMPY_CONVERT_H
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -48,18 +48,23 @@ class ARROW_EXPORT NumPyBuffer : public Buffer {
|
||||
};
|
||||
|
||||
// Handle misbehaved types like LONGLONG and ULONGLONG
|
||||
ARROW_EXPORT
|
||||
int cast_npy_type_compat(int type_num);
|
||||
|
||||
ARROW_EXPORT
|
||||
bool is_contiguous(PyObject* array);
|
||||
|
||||
ARROW_EXPORT
|
||||
Status NumPyDtypeToArrow(PyObject* dtype, std::shared_ptr<DataType>* out);
|
||||
|
||||
ARROW_EXPORT
|
||||
Status GetTensorType(PyObject* dtype, std::shared_ptr<DataType>* out);
|
||||
|
||||
ARROW_EXPORT
|
||||
Status GetNumPyType(const DataType& type, int* type_num);
|
||||
|
||||
ARROW_EXPORT Status NdarrayToTensor(
|
||||
MemoryPool* pool, PyObject* ao, std::shared_ptr<Tensor>* out);
|
||||
ARROW_EXPORT Status
|
||||
NdarrayToTensor(MemoryPool* pool, PyObject* ao, std::shared_ptr<Tensor>* out);
|
||||
|
||||
ARROW_EXPORT Status TensorToNdarray(const Tensor& tensor, PyObject* base, PyObject** out);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef PYARROW_NUMPY_INTEROP_H
|
||||
#define PYARROW_NUMPY_INTEROP_H
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include <numpy/numpyconfig.h>
|
||||
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
|
||||
// Functions for pandas conversion via NumPy
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "arrow/python/numpy_interop.h"
|
||||
|
||||
#include "arrow/python/pandas_convert.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -482,7 +481,7 @@ struct UnboxDate {};
|
||||
|
||||
template <>
|
||||
struct UnboxDate<Date32Type> {
|
||||
static int64_t Unbox(PyObject* obj) {
|
||||
static int32_t Unbox(PyObject* obj) {
|
||||
return PyDate_to_days(reinterpret_cast<PyDateTime_Date*>(obj));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifndef ARROW_PYTHON_ADAPTERS_PANDAS_H
|
||||
#define ARROW_PYTHON_ADAPTERS_PANDAS_H
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include "arrow/array.h"
|
||||
#include "arrow/builder.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef PYARROW_UTIL_DATETIME_H
|
||||
#define PYARROW_UTIL_DATETIME_H
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
#include <datetime.h>
|
||||
|
||||
namespace arrow {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include <Python.h>
|
||||
#include "arrow/python/platform.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
Reference in new issue
Block a user