Skip to content

Commit 9299d5c

Browse files
committed
Try autopxd2
1 parent 287e062 commit 9299d5c

12 files changed

+122
-403
lines changed

python/meson.build

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ project(
2929
# due to https://github.com/mesonbuild/meson/issues/6728
3030
'arrow-nanoarrow:ipc=true',
3131
'arrow-nanoarrow:device=true',
32-
'arrow-nanoarrow:namespace=PythonPkg',
32+
# Adding this namespace doesn't work with the autopxd generation
33+
# is that a problem?
34+
#'arrow-nanoarrow:namespace=PythonPkg',
3335
],
3436
)
3537

python/pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Changelog = "https://github.com/apache/arrow-nanoarrow/blob/main/CHANGELOG.md"
3838

3939
[build-system]
4040
requires = [
41+
"autopxd2",
4142
"meson>=1.3.0",
4243
"meson-python",
4344
"Cython"

python/src/nanoarrow/_array.pyx

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,14 @@ from nanoarrow_c cimport (
7676
NANOARROW_VALIDATION_LEVEL_FULL,
7777
NANOARROW_VALIDATION_LEVEL_MINIMAL,
7878
NANOARROW_VALIDATION_LEVEL_NONE,
79+
)
80+
81+
from nanoarrow_macros cimport (
7982
NANOARROW_OK,
83+
ARROW_DEVICE_CPU,
8084
)
8185

8286
from nanoarrow_device_c cimport (
83-
ARROW_DEVICE_CPU,
8487
ArrowDeviceType,
8588
ArrowDeviceArray,
8689
ArrowDeviceArrayInit,

python/src/nanoarrow/_buffer.pyx

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ from cpython cimport (
3535
from cpython.ref cimport Py_INCREF, Py_DECREF
3636

3737
from nanoarrow_c cimport (
38-
NANOARROW_OK,
3938
ArrowMalloc,
4039
ArrowFree,
4140
ArrowType,
@@ -55,12 +54,14 @@ from nanoarrow_c cimport (
5554
ArrowBufferMove,
5655
)
5756

58-
from nanoarrow_device_c cimport (
57+
from nanoarrow_macros cimport (
58+
NANOARROW_OK,
5959
ARROW_DEVICE_CPU,
6060
ARROW_DEVICE_CUDA,
61-
ArrowDevice,
6261
)
6362

63+
from nanoarrow_device_c cimport ArrowDevice
64+
6465
from nanoarrow_dlpack cimport (
6566
DLDataType,
6667
DLDevice,

python/src/nanoarrow/_device.pyx

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
from libc.stdint cimport uintptr_t, int64_t
2121

2222
from nanoarrow_device_c cimport (
23+
ArrowDevice,
24+
ArrowDeviceCpu,
25+
ArrowDeviceResolve
26+
)
27+
28+
from nanoarrow_macros cimport (
29+
NANOARROW_OK,
2330
ARROW_DEVICE_CPU,
2431
ARROW_DEVICE_CUDA,
2532
ARROW_DEVICE_CUDA_HOST,
@@ -34,9 +41,6 @@ from nanoarrow_device_c cimport (
3441
ARROW_DEVICE_ONEAPI,
3542
ARROW_DEVICE_WEBGPU,
3643
ARROW_DEVICE_HEXAGON,
37-
ArrowDevice,
38-
ArrowDeviceCpu,
39-
ArrowDeviceResolve
4044
)
4145

4246
from nanoarrow._utils cimport Error

python/src/nanoarrow/_ipc_lib.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ from nanoarrow_c cimport (
3030
ArrowSchema,
3131
ArrowErrorCode,
3232
ArrowError,
33-
NANOARROW_OK,
3433
)
3534

35+
from nanoarrow_macros cimport NANOARROW_OK
36+
3637
from nanoarrow._schema cimport CSchema
3738
from nanoarrow._array cimport CArrayView
3839
from nanoarrow._utils cimport Error

python/src/nanoarrow/_schema.pyx

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ from cpython.bytes cimport PyBytes_FromStringAndSize, PyBytes_AsString, PyBytes_
2222
from cpython.pycapsule cimport PyCapsule_GetPointer
2323

2424
from nanoarrow_c cimport (
25-
ARROW_FLAG_DICTIONARY_ORDERED,
26-
ARROW_FLAG_MAP_KEYS_SORTED,
27-
ARROW_FLAG_NULLABLE,
2825
ArrowFree,
2926
ArrowLayout,
3027
ArrowMalloc,
@@ -54,13 +51,19 @@ from nanoarrow_c cimport (
5451
ArrowType,
5552
ArrowTypeString,
5653
NANOARROW_BUFFER_TYPE_NONE,
57-
NANOARROW_MAX_FIXED_BUFFERS,
5854
NANOARROW_TIME_UNIT_SECOND,
5955
NANOARROW_TIME_UNIT_MILLI,
6056
NANOARROW_TIME_UNIT_MICRO,
6157
NANOARROW_TIME_UNIT_NANO,
6258
)
6359

60+
from nanoarrow_macros cimport (
61+
ARROW_FLAG_DICTIONARY_ORDERED,
62+
ARROW_FLAG_MAP_KEYS_SORTED,
63+
ARROW_FLAG_NULLABLE,
64+
NANOARROW_MAX_FIXED_BUFFERS,
65+
)
66+
6467
from nanoarrow cimport _types
6568
from nanoarrow._buffer cimport CBuffer
6669
from nanoarrow._utils cimport alloc_c_schema, Error

python/src/nanoarrow/_utils.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ from nanoarrow_c cimport (
5454
ArrowNanoarrowVersion,
5555
ArrowSchema,
5656
ArrowSchemaRelease,
57-
NANOARROW_OK,
5857
NANOARROW_TYPE_UNINITIALIZED
5958
)
6059

60+
from nanoarrow_macros cimport NANOARROW_OK
61+
6162
from nanoarrow_device_c cimport (
6263
ArrowDeviceArray
6364
)

python/src/nanoarrow/meson.build

+41-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,43 @@ nanoarrow_device_dep = nanoarrow_proj.get_variable('nanoarrow_device_dep')
2323

2424
py = import('python').find_installation(pure: false)
2525

26+
nanoarrow_c = custom_target(
27+
'nanoarrow_c',
28+
output: 'nanoarrow_c.pxd',
29+
command: [
30+
'autopxd',
31+
'-I',
32+
meson.project_source_root() / 'subprojects/arrow-nanoarrow/src/',
33+
'-I',
34+
meson.project_build_root() / 'subprojects/arrow-nanoarrow/src/',
35+
# ideally we could use @INPUT@ but that will throw a sandboxing violation
36+
meson.project_source_root() / 'subprojects/arrow-nanoarrow/src/nanoarrow/nanoarrow.h',
37+
'@OUTPUT@',
38+
],
39+
)
40+
nanoarrow_c_dep = declare_dependency(
41+
sources: nanoarrow_c,
42+
)
43+
44+
nanoarrow_device_c = custom_target(
45+
'nanoarrow_device_c',
46+
output: 'nanoarrow_device_c.pxd',
47+
command: [
48+
'autopxd',
49+
'-I',
50+
meson.project_source_root() / 'subprojects/arrow-nanoarrow/src/',
51+
'-I',
52+
meson.project_build_root() / 'subprojects/arrow-nanoarrow/src/',
53+
# ideally we could use @INPUT@ but that will throw a sandboxing violation
54+
meson.project_source_root() / 'subprojects/arrow-nanoarrow/src/nanoarrow/nanoarrow_device.h',
55+
'@OUTPUT@',
56+
],
57+
)
58+
59+
nanoarrow_device_c_dep = declare_dependency(
60+
sources: nanoarrow_device_c,
61+
)
62+
2663
cyfiles = [
2764
'_array.pyx',
2865
'_array_stream.pyx',
@@ -37,14 +74,16 @@ cyfiles = [
3774
cython_args = [
3875
'--include-dir',
3976
meson.current_source_dir(),
77+
'--include-dir',
78+
meson.current_build_dir(),
4079
]
4180
if get_option('buildtype') in ['debug', 'debugoptimized']
4281
cython_args += ['--gdb']
4382
endif
4483

4584
fs = import('fs')
4685
foreach cyf : cyfiles
47-
cyfile_deps = [nanoarrow_dep]
86+
cyfile_deps = [nanoarrow_dep, nanoarrow_c_dep, nanoarrow_device_c_dep]
4887

4988
stem = fs.stem(cyf)
5089
if stem in ['_array', '_device']
@@ -76,6 +115,7 @@ py_sources = [
76115
'device.py',
77116
'ipc.py',
78117
'iterator.py',
118+
'nanoarrow_macros.pxd',
79119
'_repr_utils.py',
80120
'schema.py',
81121
'visitor.py',

0 commit comments

Comments
 (0)