Skip to content

Commit

Permalink
Keep old find_package logic for linux_mac builds
Browse files Browse the repository at this point in the history
  • Loading branch information
dudoslav authored and github-actions committed Aug 15, 2024
1 parent d8127a1 commit 61c55d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-linux_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ jobs:
run: |
set -e pipefail
python -m pip install --upgrade pip virtualenv
pip install pyarrow pybind11[global] numpy
pip install pyarrow pybind11 numpy
- name: 'Brew setup on macOS' # x-ref c8e49ba8f8b9ce
if: ${{ startsWith(matrix.os, 'macos-') == true }}
Expand Down
29 changes: 28 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,37 @@ if (${TILEDB_ARROW_TESTS})
# Tell CMake to prefer Python from the PATH
set(Python_FIND_STRATEGY "LOCATION")
find_package(Python COMPONENTS Interpreter Development REQUIRED)
find_package(pybind11 REQUIRED)
find_package(pybind11)

message(STATUS "Configuring Apache Arrow integration test with Python ${Python_VERSION} (${Python_EXECUTABLE})")

# If we can't find the pybind11 cmake config (not available in pypi yet)
# try to find with the current executable.
if (NOT ${pybind11_FOUND})
# Get the include arguments from the python executable (has "-I" compiler option)
execute_process(COMMAND ${Python_EXECUTABLE} -m pybind11 --includes
OUTPUT_VARIABLE CMD_PYBIND11_INCLUDE
RESULT_VARIABLE CMD_PYBIND11_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (${CMD_PYBIND11_RESULT})
message(FATAL_ERROR "Unable to find pybind11 via cmake or 'python3 -m pybind11 --includes'")
endif()

# Convert args to list
separate_arguments(CMD_PARSED_INCLUDES NATIVE_COMMAND ${CMD_PYBIND11_INCLUDE})
# Remove the "-I" from each include
foreach(INCL_PATH IN LISTS CMD_PARSED_INCLUDES)
string(REPLACE "-I" "" INCL_PATH ${INCL_PATH})
list(APPEND PYBIND11_INCLUDE_DIRECTORIES ${INCL_PATH})
endforeach()

file(TO_CMAKE_PATH "${Python_SITELIB}" SAFE_Python_SITELIB)
set(pybind11_FOUND TRUE CACHE BOOL "pybind11 include path found")
add_library(pybind11::embed INTERFACE IMPORTED)
target_include_directories(pybind11::embed INTERFACE ${PYBIND11_INCLUDE_DIRECTORIES})
target_link_libraries(pybind11::embed INTERFACE Python::Python)
target_compile_definitions(pybind11::embed INTERFACE -DTILEDB_PYTHON_SITELIB_PATH="${SAFE_Python_SITELIB}")
endif()
file(TO_CMAKE_PATH ${CMAKE_CURRENT_BINARY_DIR} SAFE_CURRENT_BINARY_DIR)
target_compile_definitions(pybind11::embed INTERFACE -DTILEDB_PYTHON_UNIT_PATH="${SAFE_CURRENT_BINARY_DIR}")
endif()
Expand Down

0 comments on commit 61c55d1

Please sign in to comment.