kou commented on code in PR #37822:
URL: https://github.com/apache/arrow/pull/37822#discussion_r1570294288


##########
python/CMakeLists.txt:
##########
@@ -365,6 +388,9 @@ if(NOT PYARROW_CPP_LINK_LIBS)
 endif()
 
 add_library(arrow_python SHARED ${PYARROW_CPP_SRCS})
+target_compile_options(arrow_python PUBLIC "-fexceptions")

Review Comment:
   Could you do this only when building with Emscripten?



##########
python/CMakeLists.txt:
##########
@@ -590,28 +616,42 @@ endif()
 
 # Acero
 if(PYARROW_BUILD_ACERO)
-  if(PYARROW_BUNDLE_ARROW_CPP)
-    bundle_arrow_lib(${ARROW_ACERO_SHARED_LIB} SO_VERSION ${ARROW_SO_VERSION})
-    if(MSVC)
-      bundle_arrow_import_lib(${ARROW_ACERO_IMPORT_LIB})
+  if(ARROW_BUILD_SHARED)
+
+    if(PYARROW_BUNDLE_ARROW_CPP)
+      bundle_arrow_lib(${ARROW_ACERO_SHARED_LIB} SO_VERSION 
${ARROW_SO_VERSION})
+      if(MSVC)
+        bundle_arrow_import_lib(${ARROW_ACERO_IMPORT_LIB})
+      endif()
     endif()
-  endif()
 
-  set(ACERO_LINK_LIBS ArrowAcero::arrow_acero_shared)
-  list(APPEND CYTHON_EXTENSIONS _acero)
+    set(ACERO_LINK_LIBS ArrowAcero::arrow_acero_shared)
+    list(APPEND CYTHON_EXTENSIONS _acero)
+  else()
+    # ACERO is statically linked into libarrow_python already
+    set(ACERO_LINK_LIBS)
+    list(APPEND CYTHON_EXTENSIONS _acero)

Review Comment:
   Could you move `list(APPEND CYTHON_EXTENSIONS _acero)` to out of 
`if(ARROW_BUILD_SHARED)`?



##########
python/CMakeLists.txt:
##########
@@ -763,8 +813,12 @@ foreach(module ${CYTHON_EXTENSIONS})
     set_target_properties(${module_name} PROPERTIES COMPILE_DEFINITIONS
                                                     
"CYTHON_TRACE=1;CYTHON_TRACE_NOGIL=1")
   endif()
-
-  target_link_libraries(${module_name} PRIVATE ${LINK_LIBS})
+  # user this rather roundabout way of including, otherwise the
+  # in static linking mode the target will depend on libarrow and 
+  # build it into every cython extension
+  target_include_directories(${module_name} PUBLIC 
$<TARGET_PROPERTY:arrow_python,INTERFACE_INCLUDE_DIRECTORIES>)
+  target_link_libraries(${module_name} PUBLIC $<TARGET_FILE:arrow_python>)
+  add_dependencies(${module_name} arrow_python)

Review Comment:
   We want to use CMake target directly instead of each parameter separately...
   



##########
python/CMakeLists.txt:
##########
@@ -590,28 +616,42 @@ endif()
 
 # Acero
 if(PYARROW_BUILD_ACERO)
-  if(PYARROW_BUNDLE_ARROW_CPP)
-    bundle_arrow_lib(${ARROW_ACERO_SHARED_LIB} SO_VERSION ${ARROW_SO_VERSION})
-    if(MSVC)
-      bundle_arrow_import_lib(${ARROW_ACERO_IMPORT_LIB})
+  if(ARROW_BUILD_SHARED)
+
+    if(PYARROW_BUNDLE_ARROW_CPP)
+      bundle_arrow_lib(${ARROW_ACERO_SHARED_LIB} SO_VERSION 
${ARROW_SO_VERSION})
+      if(MSVC)
+        bundle_arrow_import_lib(${ARROW_ACERO_IMPORT_LIB})
+      endif()
     endif()
-  endif()
 
-  set(ACERO_LINK_LIBS ArrowAcero::arrow_acero_shared)
-  list(APPEND CYTHON_EXTENSIONS _acero)
+    set(ACERO_LINK_LIBS ArrowAcero::arrow_acero_shared)
+    list(APPEND CYTHON_EXTENSIONS _acero)
+  else()
+    # ACERO is statically linked into libarrow_python already
+    set(ACERO_LINK_LIBS)

Review Comment:
   Hmm. I think that we need `ArrowAcero::arrow_acero_static`...



##########
python/CMakeLists.txt:
##########
@@ -148,6 +151,8 @@ include(BuildUtils)
 # Cython generated code emits way to many warnings at CHECKIN and EVERYTHING
 set(BUILD_WARNING_LEVEL "PRODUCTION")
 
+
+

Review Comment:
   Could you revert needless changes?



##########
python/setup.py:
##########
@@ -311,10 +367,25 @@ def append_cmake_bool(value, varname):
                 if parallel:
                     build_tool_args.append(f'-j{parallel}')
 
-            # Generate the build files
-            print("-- Running cmake for PyArrow")
-            self.spawn(['cmake'] + extra_cmake_args + cmake_options + [source])
-            print("-- Finished cmake for PyArrow")
+            if "PYODIDE" in os.environ and os.environ["PYODIDE"] == "1":
+                # remove c++ standard setting which pyodide
+                # (emscripten python) adds to its build variables
+                import json
+                pyodide_args = json.loads(os.environ["PYWASMCROSS_ARGS"])
+                pyodide_args["cxxflags"] = pyodide_args["cxxflags"].replace(
+                    "-std=c++14", "")

Review Comment:
   Can we remove similar code in `CMakeLists.txt`?



##########
python/setup.py:
##########
@@ -133,8 +143,68 @@ def run(self):
                       'bundle the Arrow C++ headers')] +
                     _build_ext.user_options)
 
+    def get_arrow_build_options(self):

Review Comment:
   It seems that you want to enable PyArrow components if corresponding Arrow 
C++ components are enabled.
   If so, you don't need to specify `PYARROW_BUILD_*` CMake variables by 
`setup.py` or can ignore CMake variables specified by`setup.py` in 
`CMakeLists.txt`. You can use 
https://github.com/apache/arrow/pull/37822/files#r1344887227 for this approach.



##########
python/CMakeLists.txt:
##########
@@ -683,14 +725,22 @@ if(PYARROW_BUILD_SUBSTRAIT)
     message(FATAL_ERROR "You must build Arrow C++ with ARROW_SUBSTRAIT=ON")
   endif()
   find_package(ArrowSubstrait REQUIRED)
-  if(PYARROW_BUNDLE_ARROW_CPP)
-    bundle_arrow_lib(${ARROW_SUBSTRAIT_SHARED_LIB} SO_VERSION 
${ARROW_SO_VERSION})
-    if(MSVC)
-      bundle_arrow_import_lib(${ARROW_SUBSTRAIT_IMPORT_LIB})
+
+  if(ARROW_BUILD_SHARED)
+    if(PYARROW_BUNDLE_ARROW_CPP)
+      bundle_arrow_lib(${ARROW_SUBSTRAIT_SHARED_LIB} SO_VERSION 
${ARROW_SO_VERSION})
+      if(MSVC)
+        bundle_arrow_import_lib(${ARROW_SUBSTRAIT_IMPORT_LIB})
+      endif()
     endif()
+    set(SUBSTRAIT_LINK_LIBS ArrowSubstrait::arrow_substrait_shared)
+  else()
+  # only link to the output of substrait, not to libarrow etc.
+  # if we link to the target directly we end up with multiple copies
+  # of libarrow / parquet etc. 
+  set(SUBSTRAIT_LINK_LIBS 
$<TARGET_FILE:ArrowSubstrait::arrow_substrait_static> )

Review Comment:
   Hmm. I think that CMake removes duplicated libraries automatically when we 
use CMake target.
   
   



##########
python/pyarrow/conftest.py:
##########
@@ -81,9 +85,16 @@
     'slow': False,
     'snappy': Codec.is_available('snappy'),
     'substrait': False,
+    'threading': is_threading_enabled(),
     'zstd': Codec.is_available('zstd'),
+    'processes': True

Review Comment:
   Could you keep this list in alphabetical order?
   



##########
python/pyarrow/conftest.py:
##########
@@ -51,6 +53,8 @@
     'slow',
     'requires_testing_data',
     'zstd',
+    'threading',
+    'processes',

Review Comment:
   Could you keep this list in alphabetical order?



-- 
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]

Reply via email to