paleolimbot commented on code in PR #625:
URL: https://github.com/apache/arrow-nanoarrow/pull/625#discussion_r1768903368
##########
python/setup.py:
##########
@@ -94,55 +94,49 @@ def get_version(pkg_path):
device_library_dirs.append(str(lib_dirs[0].parent))
-def nanoarrow_extension(
- name, *, nanoarrow_c=False, nanoarrow_device=False, nanoarrow_ipc=False
-):
- sources = ["src/" + name.replace(".", "/") + ".pyx"]
- libraries = []
- library_dirs = []
- include_dirs = ["src/nanoarrow", "vendor"]
- define_macros = list(extra_define_macros)
-
- if nanoarrow_c:
- sources.append("vendor/nanoarrow.c")
-
- if nanoarrow_device:
- sources.append("vendor/nanoarrow_device.c")
- include_dirs.extend(device_include_dirs)
- libraries.extend(device_libraries)
- library_dirs.extend(device_library_dirs)
- define_macros.extend(device_define_macros)
-
- if nanoarrow_ipc:
- sources.extend(["vendor/nanoarrow_ipc.c", "vendor/flatcc.c"])
+common_libraries = [
+ [
+ "nanoarrow_python_shared",
+ {
+ "sources": [
+ "vendor/nanoarrow.c",
+ "vendor/nanoarrow_device.c",
+ "vendor/nanoarrow_ipc.c",
+ "vendor/flatcc.c",
+ ],
+ "include_dirs": ["vendor"],
+ "libraries": device_libraries,
+ "library_dirs": device_library_dirs,
+ "macros": extra_define_macros + device_define_macros,
+ },
+ ]
+]
+
+def nanoarrow_extension(name):
return Extension(
name=name,
- include_dirs=include_dirs,
+ include_dirs=["vendor", "src/nanoarrow"],
language="c",
- sources=sources,
+ sources=["src/" + name.replace(".", "/") + ".pyx"],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
- define_macros=define_macros,
- library_dirs=library_dirs,
- libraries=libraries,
+ define_macros=extra_define_macros + device_define_macros,
+ libraries=["nanoarrow_python_shared"],
)
setup(
ext_modules=[
nanoarrow_extension("nanoarrow._types"),
- nanoarrow_extension("nanoarrow._utils", nanoarrow_c=True),
- nanoarrow_extension(
- "nanoarrow._device", nanoarrow_c=True, nanoarrow_device=True
- ),
- nanoarrow_extension(
- "nanoarrow._array", nanoarrow_c=True, nanoarrow_device=True
- ),
- nanoarrow_extension("nanoarrow._array_stream", nanoarrow_c=True),
- nanoarrow_extension("nanoarrow._buffer", nanoarrow_c=True),
- nanoarrow_extension("nanoarrow._ipc_lib", nanoarrow_c=True,
nanoarrow_ipc=True),
- nanoarrow_extension("nanoarrow._schema", nanoarrow_c=True),
+ nanoarrow_extension("nanoarrow._utils"),
+ nanoarrow_extension("nanoarrow._device"),
+ nanoarrow_extension("nanoarrow._array"),
+ nanoarrow_extension("nanoarrow._array_stream"),
+ nanoarrow_extension("nanoarrow._buffer"),
+ nanoarrow_extension("nanoarrow._ipc_lib"),
+ nanoarrow_extension("nanoarrow._schema"),
],
version=version,
+ libraries=common_libraries,
Review Comment:
The reference is https://stackoverflow.com/a/49277244 , and for better or
worse it builds a static library and not a shared one (still an improvement,
since a linked static library I believe only pulls the functions actually used,
whereas including the source file always includes all of them).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]