macOS/bpy module: install scripts relative to bpy.so

Brew's Python framework's site-packages is a symlink so the assumption
that Resources and site-packages would be in the same directory
doesn't hold. So install scripts etc relative to bpy.so. Part of D14111
This commit is contained in:
Ankit Meel 2022-02-17 01:28:10 +05:30
parent 57013e2a44
commit 71545e542c

@ -319,11 +319,16 @@ elseif(WIN32)
elseif(APPLE) elseif(APPLE)
if(WITH_PYTHON_MODULE) if(WITH_PYTHON_MODULE)
if(WITH_INSTALL_PORTABLE) if(WITH_INSTALL_PORTABLE)
set(BPY_INSTALL_DIR)
set(TARGETDIR_VER $<TARGET_FILE_DIR:blender>/../Resources/${BLENDER_VERSION}) set(TARGETDIR_VER $<TARGET_FILE_DIR:blender>/../Resources/${BLENDER_VERSION})
# Keep the `BLENDER_VERSION` folder and bpy.so in the build folder. # Keep the `BLENDER_VERSION` folder and bpy.so in the build folder.
set(INSTALL_BPY_TO_SITE_PACKAGES OFF) set(INSTALL_BPY_TO_SITE_PACKAGES OFF)
else() else()
set(TARGETDIR_VER "${PYTHON_LIBPATH}/Resources/${BLENDER_VERSION}") # Parent directory of bpy.so for installation.
set(BPY_INSTALL_DIR ${PYTHON_LIBPATH}/site-packages)
# Defined in terms of site-packages since the site-packages
# directory can be a symlink (brew for example).
set(TARGETDIR_VER "${BPY_INSTALL_DIR}/../Resources/${BLENDER_VERSION}")
set(INSTALL_BPY_TO_SITE_PACKAGES ON) set(INSTALL_BPY_TO_SITE_PACKAGES ON)
endif() endif()
else() else()
@ -1108,11 +1113,12 @@ elseif(APPLE)
) )
unset(_py_inc_suffix) unset(_py_inc_suffix)
endif() endif()
if(WITH_PYTHON_MODULE) if(WITH_PYTHON_MODULE)
if(INSTALL_BPY_TO_SITE_PACKAGES) if(INSTALL_BPY_TO_SITE_PACKAGES)
install( install(
TARGETS blender TARGETS blender
LIBRARY DESTINATION ${PYTHON_LIBPATH}/site-packages LIBRARY DESTINATION ${BPY_INSTALL_DIR}
) )
endif() endif()
endif() endif()