diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 234ad1ebf03..a4a900b9911 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -90,9 +90,6 @@ option( ) mark_as_advanced(CUDF_BUILD_STREAMS_TEST_UTIL) -option(USE_LIBARROW_FROM_PYARROW "Use the libarrow contained within pyarrow." OFF) -mark_as_advanced(USE_LIBARROW_FROM_PYARROW) - message(VERBOSE "CUDF: Build with NVTX support: ${USE_NVTX}") message(VERBOSE "CUDF: Configure CMake to build tests: ${BUILD_TESTS}") message(VERBOSE "CUDF: Configure CMake to build (google & nvbench) benchmarks: ${BUILD_BENCHMARKS}") diff --git a/cpp/cmake/thirdparty/get_arrow.cmake b/cpp/cmake/thirdparty/get_arrow.cmake index 03393a41e7a..3475dab2623 100644 --- a/cpp/cmake/thirdparty/get_arrow.cmake +++ b/cpp/cmake/thirdparty/get_arrow.cmake @@ -32,7 +32,7 @@ function(find_libarrow_in_python_wheel PYARROW_VERSION) # `${MINOR_VERSION}${PATCH_VERSION}` is almost always equivalent to "00"), # the soname is not generated by concatenating the major, minor, and patch versions into a single # version number soname, just `${MAJOR_VERSION}00` - set(PYARROW_LIB "libarrow.so.${PYARROW_SO_VER}00") + set(PYARROW_LIB "libarrow.${CMAKE_SHARED_LIBRARY_SUFFIX}.${PYARROW_SO_VER}00") execute_process( COMMAND "${Python_EXECUTABLE}" -c "import pyarrow; print(pyarrow.get_library_dirs()[0])" @@ -90,10 +90,10 @@ endfunction() # This function finds arrow and sets any additional necessary environment variables. function(find_and_configure_arrow VERSION BUILD_STATIC ENABLE_S3 ENABLE_ORC ENABLE_PYTHON - ENABLE_PARQUET + ENABLE_PARQUET PYARROW_LIBARROW ) - if(USE_LIBARROW_FROM_PYARROW) + if(PYARROW_LIBARROW) # Generate a FindArrow.cmake to find pyarrow's libarrow.so find_libarrow_in_python_wheel(${VERSION}) set(ARROW_FOUND @@ -431,7 +431,35 @@ if(NOT DEFINED CUDF_VERSION_Arrow) ) endif() +# If the pyarrow package contains libarrow we want to link against it directly instead of searching +# for a separate libarrow. Even if libcudf was built against a different libarrow, that library +# would have to be ABI-compatible with the one in pyarrow for the packages to work together, and for +# wheels we must use the library in the pyarrow wheel, so it's best to simply be consistent. +find_package(Python 3.9 COMPONENTS Interpreter) + +if (${Python_FOUND}) + execute_process( + COMMAND "${Python_EXECUTABLE}" -c "import importlib; print(importlib.util.find_spec('pyarrow') is not None)" + OUTPUT_VARIABLE _pyarrow_installed + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if (${_pyarrow_installed} STREQUAL "True") + execute_process( + COMMAND "${Python_EXECUTABLE}" -c "import pyarrow; print(pyarrow.get_library_dirs()[0])" + OUTPUT_VARIABLE _pyarrow_lib_dir + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + file(GLOB _pyarrow_libs "${_pyarrow_lib_dir}/libarrow.${CMAKE_SHARED_LIBRARY_SUFFIX}*") + list(LENGTH _pyarrow_libs _pyarrow_libs_len) + if(_pyarrow_libs_len GREATER 0) + set(USE_LIBARROW_FROM_PYARROW ON) + else() + set(USE_LIBARROW_FROM_PYARROW OFF) + endif() + endif() +endif() + find_and_configure_arrow( ${CUDF_VERSION_Arrow} ${CUDF_USE_ARROW_STATIC} ${CUDF_ENABLE_ARROW_S3} ${CUDF_ENABLE_ARROW_ORC} - ${CUDF_ENABLE_ARROW_PYTHON} ${CUDF_ENABLE_ARROW_PARQUET} + ${CUDF_ENABLE_ARROW_PYTHON} ${CUDF_ENABLE_ARROW_PARQUET} ${USE_LIBARROW_FROM_PYARROW} ) diff --git a/python/cudf/CMakeLists.txt b/python/cudf/CMakeLists.txt index 8bc94ab3a68..a76a38e2728 100644 --- a/python/cudf/CMakeLists.txt +++ b/python/cudf/CMakeLists.txt @@ -34,25 +34,9 @@ option(FIND_CUDF_CPP "Search for existing CUDF C++ installations before defaulti OFF ) -# If the pyarrow package contains libarrow we want to link against it directly instead of searching -# for a separate libarrow. Even if libcudf was built against a different libarrow, that library -# would have to be ABI-compatible with the one in pyarrow for the packages to work together, and for -# wheels we must use the library in the pyarrow wheel. +# Find Python early so that later commands can use it find_package(Python 3.9 REQUIRED COMPONENTS Interpreter) -execute_process( - COMMAND "${Python_EXECUTABLE}" -c "import pyarrow; print(pyarrow.get_library_dirs()[0])" - OUTPUT_VARIABLE _pyarrow_lib_dir - OUTPUT_STRIP_TRAILING_WHITESPACE -) -file(GLOB _pyarrow_libs "${_pyarrow_lib_dir}/libarrow.${CMAKE_SHARED_LIBRARY_SUFFIX}*") -list(LENGTH _pyarrow_libs _pyarrow_libs_len) -if(_pyarrow_libs_len GREATER 0) - set(USE_LIBARROW_FROM_PYARROW ON) -else() - set(USE_LIBARROW_FROM_PYARROW OFF) -endif() - # If the user requested it we attempt to find CUDF. if(FIND_CUDF_CPP) # We need to find arrow before libcudf since libcudf requires it but doesn't bundle arrow