Skip to content

Commit

Permalink
create .so symlink to libraries instead of second installation; hardc…
Browse files Browse the repository at this point in the history
…ode symlinks as .so so python can find them on macos
  • Loading branch information
bennibbelink committed Oct 2, 2024
1 parent bc7f623 commit 26a7eef
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,15 @@ if(Cython_FOUND)
TARGETS ${name}
LIBRARY DESTINATION lib
)
INSTALL(
TARGETS ${name}
LIBRARY DESTINATION ${PYTHON_SITE_PACKAGES}
# Add symlinks to PYTHON_SITE_PACKAGES so python can find our cython modules
# Python will only import libraries with .so extensions
# so we hardcode the symlink with .so even on APPLE
INSTALL(CODE "
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_INSTALL_PREFIX}/lib/${name}${suffix}
${PYTHON_SITE_PACKAGES}/${name}.so
)"
)

copy_when_diff(${_generated_h} ${_h_file})
Expand Down

0 comments on commit 26a7eef

Please sign in to comment.