[pypy-dev] PyArrow on PyPy: PyDateTime_CAPI question (getting cpyext to work) in c++
Matti Picus
matti.picus at gmail.com
Fri Sep 11 08:18:36 EDT 2020
Thse changes seems to compile for me, but I did not run the tests.
https://gist.github.com/mattip/c9c8398b58721ae5893dc8134c353f28
Matti
On 9/11/20 1:01 PM, Niklas B wrote:
> The PyMemoryView_GetContiguous errors are all gone - good work!
>
> It didn’t really like my butchering of datetime.cc
> <http://datetime.cc>
> https://github.com/apache/arrow/blob/apache-arrow-1.0.1/cpp/src/arrow/python/datetime.cc#L37
>
> Added:
> #include <datetime.h>
>
> And
> PyDateTime_IMPORT
>
>
>
> Then changed:
> datetime_api =
>
> reinterpret_cast<PyDateTime_CAPI*>(PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0));
>
>
> To:
>
> datetime_api = PyDateTimeAPI;
>
> They do some PyDateTimeAPI voodoo at
> https://github.com/apache/arrow/blob/apache-arrow-1.0.1/cpp/src/arrow/python/datetime.h#L29 which
> might be a culprit as well.
>
>
>
>
>
>
>
>
>
> Gives the following outputs:
> /arrow/cpp/src/arrow/python/datetime.h:34: warning: "PyDateTimeAPI"
> redefined
> #define PyDateTimeAPI ::arrow::py::internal::datetime_api
>
> In file included from /opt/pypy/include/Python.h:144,
> from /arrow/cpp/src/arrow/python/platform.h:23,
> from /arrow/cpp/src/arrow/python/pyarrow.h:20,
> from /arrow/cpp/src/arrow/python/common.h:24,
> from /arrow/cpp/src/arrow/python/datetime.cc:24
> <http://datetime.cc:24>:
> /opt/pypy/include/pypy_decl.h:1121: note: this is the location of the
> previous definition
> #define PyDateTimeAPI PyPyDateTimeAPI
>
> In file included from /opt/pypy/include/datetime.h:7,
> from /arrow/cpp/src/arrow/python/datetime.cc:22
> <http://datetime.cc:22>:
> /opt/pypy/include/cpyext_datetime.h:4:5: error: ‘PyTypeObject’ does
> not name a type; did you mean ‘PyType_Check’?
> PyTypeObject *DateType;
> ^~~~~~~~~~~~
> PyType_Check
> /opt/pypy/include/cpyext_datetime.h:5:5: error: ‘PyTypeObject’ does
> not name a type; did you mean ‘PyType_Check’?
> PyTypeObject *DateTimeType;
> ^~~~~~~~~~~~
> PyType_Check
> /opt/pypy/include/cpyext_datetime.h:6:5: error: ‘PyTypeObject’ does
> not name a type; did you mean ‘PyType_Check’?
> PyTypeObject *TimeType;
> ^~~~~~~~~~~~
> PyType_Check
> /opt/pypy/include/cpyext_datetime.h:7:5: error: ‘PyTypeObject’ does
> not name a type; did you mean ‘PyType_Check’?
> PyTypeObject *DeltaType;
> ^~~~~~~~~~~~
> PyType_Check
> /opt/pypy/include/cpyext_datetime.h:8:5: error: ‘PyTypeObject’ does
> not name a type; did you mean ‘PyType_Check’?
> PyTypeObject *TZInfoType;
> ^~~~~~~~~~~~
> PyType_Check
> /opt/pypy/include/cpyext_datetime.h:11:5: error: ‘PyObject’ does not
> name a type; did you mean ‘PyObject_New’?
> PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
> ^~~~~~~~
> PyObject_New
> /opt/pypy/include/cpyext_datetime.h:12:5: error: ‘PyObject’ does not
> name a type; did you mean ‘PyObject_New’?
> PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int,
> int, int,
> ^~~~~~~~
> PyObject_New
> /opt/pypy/include/cpyext_datetime.h:14:5: error: ‘PyObject’ does not
> name a type; did you mean ‘PyObject_New’?
> PyObject *(*Time_FromTime)(int, int, int, int, PyObject*,
> PyTypeObject*);
> ^~~~~~~~
> PyObject_New
> /opt/pypy/include/cpyext_datetime.h:15:5: error: ‘PyObject’ does not
> name a type; did you mean ‘PyObject_New’?
> PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
> ^~~~~~~~
> PyObject_New
> /opt/pypy/include/cpyext_datetime.h:18:5: error: ‘PyObject’ does not
> name a type; did you mean ‘PyObject_New’?
> PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*);
> ^~~~~~~~
> PyObject_New
> /opt/pypy/include/cpyext_datetime.h:19:5: error: ‘PyObject’ does not
> name a type; did you mean ‘PyObject_New’?
> PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*);
> ^~~~~~~~
> PyObject_New
> /opt/pypy/include/cpyext_datetime.h:24:5: error: ‘PyObject_HEAD’ does
> not name a type
> PyObject_HEAD
> ^~~~~~~~~~~~~
> /opt/pypy/include/cpyext_datetime.h:24:5: note: the macro
> ‘PyObject_HEAD’ had not yet been defined
> In file included from /opt/pypy/include/object.h:10,
> from /opt/pypy/include/Python.h:79,
> from /arrow/cpp/src/arrow/python/platform.h:23,
> from /arrow/cpp/src/arrow/python/pyarrow.h:20,
> from /arrow/cpp/src/arrow/python/common.h:24,
> from /arrow/cpp/src/arrow/python/datetime.cc:24
> <http://datetime.cc:24>:
> /opt/pypy/include/cpyext_object.h:5: note: it was later defined here
> #define PyObject_HEAD \
>
> In file included from /opt/pypy/include/datetime.h:7,
> from /arrow/cpp/src/arrow/python/datetime.cc:22
> <http://datetime.cc:22>:
> /opt/pypy/include/cpyext_datetime.h:35:5: error: ‘PyObject_HEAD’ does
> not name a type
> PyObject_HEAD
> ^~~~~~~~~~~~~
> /opt/pypy/include/cpyext_datetime.h:35:5: note: the macro
> ‘PyObject_HEAD’ had not yet been defined
> In file included from /opt/pypy/include/object.h:10,
> from /opt/pypy/include/Python.h:79,
> from /arrow/cpp/src/arrow/python/platform.h:23,
> from /arrow/cpp/src/arrow/python/pyarrow.h:20,
> from /arrow/cpp/src/arrow/python/common.h:24,
> from /arrow/cpp/src/arrow/python/datetime.cc:24
> <http://datetime.cc:24>:
> /opt/pypy/include/cpyext_object.h:5: note: it was later defined here
> #define PyObject_HEAD \
>
> In file included from /opt/pypy/include/datetime.h:7,
> from /arrow/cpp/src/arrow/python/datetime.cc:22
> <http://datetime.cc:22>:
> /opt/pypy/include/cpyext_datetime.h:37:5: error: ‘PyObject’ does not
> name a type; did you mean ‘PyObject_New’?
> PyObject *tzinfo;
> ^~~~~~~~
> PyObject_New
> /opt/pypy/include/cpyext_datetime.h:42:5: error: ‘PyObject_HEAD’ does
> not name a type
> PyObject_HEAD
> ^~~~~~~~~~~~~
> /opt/pypy/include/cpyext_datetime.h:42:5: note: the macro
> ‘PyObject_HEAD’ had not yet been defined
> In file included from /opt/pypy/include/object.h:10,
> from /opt/pypy/include/Python.h:79,
> from /arrow/cpp/src/arrow/python/platform.h:23,
> from /arrow/cpp/src/arrow/python/pyarrow.h:20,
> from /arrow/cpp/src/arrow/python/common.h:24,
> from /arrow/cpp/src/arrow/python/datetime.cc:24
> <http://datetime.cc:24>:
> /opt/pypy/include/cpyext_object.h:5: note: it was later defined here
> #define PyObject_HEAD \
>
> In file included from /opt/pypy/include/datetime.h:7,
> from /arrow/cpp/src/arrow/python/datetime.cc:22
> <http://datetime.cc:22>:
> /opt/pypy/include/cpyext_datetime.h:44:5: error: ‘PyObject’ does not
> name a type; did you mean ‘PyObject_New’?
> PyObject *tzinfo;
> ^~~~~~~~
> PyObject_New
> /opt/pypy/include/cpyext_datetime.h:49:5: error: ‘PyObject_HEAD’ does
> not name a type
> PyObject_HEAD
> ^~~~~~~~~~~~~
> /opt/pypy/include/cpyext_datetime.h:49:5: note: the macro
> ‘PyObject_HEAD’ had not yet been defined
> In file included from /opt/pypy/include/object.h:10,
> from /opt/pypy/include/Python.h:79,
> from /arrow/cpp/src/arrow/python/platform.h:23,
> from /arrow/cpp/src/arrow/python/pyarrow.h:20,
> from /arrow/cpp/src/arrow/python/common.h:24,
> from /arrow/cpp/src/arrow/python/datetime.cc:24
> <http://datetime.cc:24>:
> /opt/pypy/include/cpyext_object.h:5: note: it was later defined here
> #define PyObject_HEAD \
>
> In file included from /opt/pypy/include/datetime.h:7,
> from /arrow/cpp/src/arrow/python/datetime.cc:22
> <http://datetime.cc:22>:
> /opt/pypy/include/cpyext_datetime.h:54:5: error: ‘PyObject_HEAD’ does
> not name a type
> PyObject_HEAD
> ^~~~~~~~~~~~~
> /opt/pypy/include/cpyext_datetime.h:54:5: note: the macro
> ‘PyObject_HEAD’ had not yet been defined
> In file included from /opt/pypy/include/object.h:10,
> from /opt/pypy/include/Python.h:79,
> from /arrow/cpp/src/arrow/python/platform.h:23,
> from /arrow/cpp/src/arrow/python/pyarrow.h:20,
> from /arrow/cpp/src/arrow/python/common.h:24,
> from /arrow/cpp/src/arrow/python/datetime.cc:24
> <http://datetime.cc:24>:
> /opt/pypy/include/cpyext_object.h:5: note: it was later defined here
> #define PyObject_HEAD \
>
> In file included from /arrow/cpp/src/arrow/python/datetime.cc:22
> <http://datetime.cc:22>:
> /opt/pypy/include/datetime.h:9:30: error: expected constructor,
> destructor, or type conversion before ‘PyDateTimeAPI’
> PyAPI_DATA(PyDateTime_CAPI*) PyDateTimeAPI;
> ^~~~~~~~~~~~~
> /arrow/cpp/src/arrow/python/datetime.cc:37 <http://datetime.cc:37>:1:
> error: expected ‘)’ before ‘=’ token
> PyDateTime_IMPORT
> ^~~~~~~~~~~~~~~~~
> /arrow/cpp/src/arrow/python/datetime.cc <http://datetime.cc>: In
> function ‘arrow::Status arrow::py::internal::PyTime_from_int(int64_t,
> arrow::TimeUnit::type, PyObject**)’:
> /arrow/cpp/src/arrow/python/datetime.cc:237
> <http://datetime.cc:237>:10: error: ‘struct PyDateTime_CAPI’ has no
> member named ‘Time_FromTime’
> *out = PyTime_FromTime(static_cast<int32_t>(hour),
> static_cast<int32_t>(minute),
> ^~~~~~~~~~~~~~~
> /arrow/cpp/src/arrow/python/datetime.cc:237
> <http://datetime.cc:237>:10: error: ‘struct PyDateTime_CAPI’ has no
> member named ‘TimeType’
> *out = PyTime_FromTime(static_cast<int32_t>(hour),
> static_cast<int32_t>(minute),
> ^~~~~~~~~~~~~~~
> /arrow/cpp/src/arrow/python/datetime.cc <http://datetime.cc>: In
> function ‘arrow::Status arrow::py::internal::PyDate_from_int(int64_t,
> arrow::DateUnit, PyObject**)’:
> /arrow/cpp/src/arrow/python/datetime.cc:245
> <http://datetime.cc:245>:10: error: ‘struct PyDateTime_CAPI’ has no
> member named ‘Date_FromDate’
> *out = PyDate_FromDate(static_cast<int32_t>(year),
> static_cast<int32_t>(month),
> ^~~~~~~~~~~~~~~
> /arrow/cpp/src/arrow/python/datetime.cc:245
> <http://datetime.cc:245>:10: error: ‘struct PyDateTime_CAPI’ has no
> member named ‘DateType’
> *out = PyDate_FromDate(static_cast<int32_t>(year),
> static_cast<int32_t>(month),
> ^~~~~~~~~~~~~~~
> /arrow/cpp/src/arrow/python/datetime.cc <http://datetime.cc>: In
> function ‘arrow::Status
> arrow::py::internal::PyDateTime_from_int(int64_t,
> arrow::TimeUnit::type, PyObject**)’:
> /arrow/cpp/src/arrow/python/datetime.cc:257
> <http://datetime.cc:257>:10: error: ‘struct PyDateTime_CAPI’ has no
> member named ‘DateTime_FromDateAndTime’
> *out = PyDateTime_FromDateAndTime(
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> /arrow/cpp/src/arrow/python/datetime.cc:257
> <http://datetime.cc:257>:10: error: ‘struct PyDateTime_CAPI’ has no
> member named ‘DateTimeType’
> *out = PyDateTime_FromDateAndTime(
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> make[2]: ***
> [src/arrow/python/CMakeFiles/arrow_python_objlib.dir/build.make:121:
> src/arrow/python/CMakeFiles/arrow_python_objlib.dir/datetime.cc.o] Error 1
> make[1]: *** [CMakeFiles/Makefile2:1628:
> src/arrow/python/CMakeFiles/arrow_python_objlib.dir/all] Error
>
>
>
>> On 10 Sep 2020, at 13:30, Niklas B <niklas.bivald at enplore.com
>> <mailto:niklas.bivald at enplore.com>> wrote:
>>
>> That’s what I figured, cool, I will try it!
>>
>>> On 10 Sep 2020, at 13:28, Matti Picus <matti.picus at gmail.com
>>> <mailto:matti.picus at gmail.com>> wrote:
>>>
>>>
>>
>
More information about the pypy-dev
mailing list