Skip to content

Commit

Permalink
[ESI Runtime] Fix the wheel build
Browse files Browse the repository at this point in the history
pybind11_stubgen issues. Try to get it working in both regular cmake
builds and wheel builds.
  • Loading branch information
teqdruid committed Jul 26, 2024
1 parent 96b6a63 commit 9081c63
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/Dialect/ESI/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,26 +266,27 @@ if(Python3_FOUND)
target_link_libraries(esiCppAccel PRIVATE ESICppRuntime)

# Check for stubgen and generate stubs if available.
execute_process(
COMMAND "${Python3_EXECUTABLE}" -c "import pybind11_stubgen"
RESULT_VARIABLE STUBGEN_EXISTS
ERROR_QUIET
)
if (STUBGEN_EXISTS EQUAL "0")
find_program(STUBGEN pybind11-stubgen)
if ("${STUBGEN}" STREQUAL "STUBGEN-NOTFOUND")
message(STATUS "pybind11_stubgen not found. Skipping stub generation.")
else()
if(WIN32)
set(stubgen_python_path "$ENV{PYTHONPATH};${CMAKE_CURRENT_BINARY_DIR}/python")
else()
set(stubgen_python_path "$ENV{PYTHONPATH}:${CMAKE_CURRENT_BINARY_DIR}/python")
endif()
add_custom_command(
TARGET esiCppAccel
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python"
python -m pybind11_stubgen
COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${stubgen_python_path}"
${STUBGEN}
-o "${CMAKE_CURRENT_BINARY_DIR}/python/esiaccel"
esiaccel.esiCppAccel
)
else()
message(STATUS "pybind11_stubgen not found. Skipping stub generation.")
endif()

if (WHEEL_BUILD)
if (NOT STUBGEN_EXISTS EQUAL "0")
if ("${STUBGEN}" STREQUAL "STUBGEN-NOTFOUND")
message (FATAL_ERROR "pybind11_stubgen is required for a wheel build.")
endif()
set_target_properties(esiCppAccel PROPERTIES
Expand Down

0 comments on commit 9081c63

Please sign in to comment.