Use symlink to pcbnew kiface for python module on Linux

Instead of installing an identical shared library into the Python
folder, just use a link to the existing library instead.

Fixes https://gitlab.com/kicad/code/kicad/issues/9974
This commit is contained in:
Ian McInerney 2022-06-22 23:15:22 +01:00
parent b51d8c9825
commit 9bb5beb264
2 changed files with 23 additions and 3 deletions

View File

@ -869,6 +869,16 @@ else()
set( PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}" set( PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}"
CACHE PATH "Python module install path." CACHE PATH "Python module install path."
) )
if( IS_ABSOLUTE ${PYTHON_SITE_PACKAGE_PATH} )
set( PYTHON_FULL_DEST "${PYTHON_SITE_PACKAGE_PATH}"
CACHE PATH "Python module full install path."
)
else()
set( PYTHON_FULL_DEST "${CMAKE_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGE_PATH}"
CACHE PATH "Python module full install path."
)
endif()
endif() endif()
message( STATUS "Python module install path: ${PYTHON_DEST}" ) message( STATUS "Python module install path: ${PYTHON_DEST}" )

View File

@ -828,9 +828,19 @@ elseif( APPLE )
) )
add_dependencies( ScriptingModulesPcbnewSoCopy ScriptingPythonDirectoryCreation ) add_dependencies( ScriptingModulesPcbnewSoCopy ScriptingPythonDirectoryCreation )
set( PYMOD_EXT "so" ) set( PYMOD_EXT "so" )
else() # only linux remains among supported platforms else()
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.kiface DESTINATION ${PYTHON_DEST} COMPONENT binary RENAME "_pcbnew.so" ) # Linux is the remaining platform, and we will create a symlink for the kiface from the python site-packages directory.
set( PYMOD_EXT "so" ) set( PYMOD_EXT "so" )
if( IS_ABSOLUTE ${KICAD_KIFACE} )
file( RELATIVE_PATH PCBNEW_PYTHON_SYMLINK ${PYTHON_FULL_DEST} ${KICAD_KIFACE}/_pcbnew${KIFACE_SUFFIX} )
else()
file( RELATIVE_PATH PCBNEW_PYTHON_SYMLINK ${PYTHON_FULL_DEST} ${CMAKE_INSTALL_PREFIX}/${KICAD_KIFACE}/_pcbnew${KIFACE_SUFFIX} )
endif()
install( CODE "message( STATUS \"Symlinking ${PYTHON_FULL_DEST}/_pcbnew.${PYMOD_EXT} to _pcbnew${KIFACE_SUFFIX}\")
execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink \"${PCBNEW_PYTHON_SYMLINK}\" \"${PYTHON_FULL_DEST}/_pcbnew.${PYMOD_EXT}\" )"
)
endif() endif()
if( APPLE ) if( APPLE )
@ -843,7 +853,7 @@ if( APPLE )
pcbnew_python_module ALL pcbnew_python_module ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT}
) )
else() elseif( WIN32 )
# For phase 1, copy _pcbnew.kiface to the python module. # For phase 1, copy _pcbnew.kiface to the python module.
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT} add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_pcbnew.${PYMOD_EXT}
DEPENDS pcbnew_kiface DEPENDS pcbnew_kiface