Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(python): Add ArrowDeviceArray extension to Python bindings #313

Merged
merged 28 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

src/nanoarrow/nanoarrow.c
src/nanoarrow/nanoarrow.h
src/nanoarrow/nanoarrow_device.h
src/nanoarrow/nanoarrow_c.pxd
src/nanoarrow/*.c

Expand Down
25 changes: 24 additions & 1 deletion python/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,19 @@ def copy_or_generate_nanoarrow_c():

maybe_nanoarrow_h = os.path.join(this_dir, "src/nanoarrow/nanoarrow.h")
maybe_nanoarrow_c = os.path.join(this_dir, "src/nanoarrow/nanoarrow.c")
for f in (maybe_nanoarrow_c, maybe_nanoarrow_h):
maybe_nanoarrow_device_h = os.path.join(
this_dir, "src/nanoarrow/nanoarrow_device.h"
)
maybe_nanoarrow_device_c = os.path.join(
this_dir, "src/nanoarrow/nanoarrow_device.c"
)

for f in (
maybe_nanoarrow_c,
maybe_nanoarrow_h,
maybe_nanoarrow_device_h,
maybe_nanoarrow_device_c,
):
if os.path.exists(f):
os.unlink(f)

Expand All @@ -170,6 +182,17 @@ def copy_or_generate_nanoarrow_c():
has_cmake = os.system("cmake --version") == 0
build_dir = os.path.join(this_dir, "_cmake")

if is_in_nanoarrow_repo:
device_ext_src = os.path.join(
source_dir, "extensions/nanoarrow_device/src/nanoarrow"
)
shutil.copyfile(
os.path.join(device_ext_src, "nanoarrow_device.h"), maybe_nanoarrow_device_h
)
shutil.copyfile(
os.path.join(device_ext_src, "nanoarrow_device.c"), maybe_nanoarrow_device_c
)

if has_cmake and is_cmake_dir and is_in_nanoarrow_repo:
try:
os.mkdir(build_dir)
Expand Down
25 changes: 15 additions & 10 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@


# Set some extra flags for compiling with coverage support
if os.getenv("NANOARROW_PYTHON_COVERAGE") == "1":
coverage_compile_args = ["--coverage"]
coverage_link_args = ["--coverage"]
coverage_define_macros = [("CYTHON_TRACE", 1)]
if os.getenv("NANOARROW_COVERAGE") == "1":
extra_compile_args = ["--coverage"]
extra_link_args = ["--coverage"]
extra_define_macros = [("CYTHON_TRACE", 1)]
elif os.getenv("NANOARROW_DEBUG_EXTENSION") == "1":
extra_compile_args = ["-g", "-O0"]
extra_link_args = []
extra_define_macros = []
else:
coverage_compile_args = []
coverage_link_args = []
coverage_define_macros = []
extra_compile_args = []
extra_link_args = []
extra_define_macros = []

setup(
ext_modules=[
Expand All @@ -51,10 +55,11 @@
sources=[
"src/nanoarrow/_lib.pyx",
"src/nanoarrow/nanoarrow.c",
"src/nanoarrow/nanoarrow_device.c",
],
extra_compile_args=coverage_compile_args,
extra_link_args=coverage_link_args,
define_macros=coverage_define_macros,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
define_macros=extra_define_macros,
)
]
)
2 changes: 1 addition & 1 deletion python/src/nanoarrow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
# under the License.

from ._lib import Array, ArrayStream, ArrayView, Schema, c_version # noqa: F401
from .lib import array, array_stream, schema # noqa: F401
from .lib import array, array_stream, schema, array_view # noqa: F401
Loading
Loading