Skip to content

Commit

Permalink
python_orocos_kdl: remove AMENT_IGNORE and add manual PYTHONPATH envi…
Browse files Browse the repository at this point in the history
…ronment hook
  • Loading branch information
mjbogusz committed Dec 8, 2017
1 parent d8531ab commit 2175675
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Empty file removed python_orocos_kdl/AMENT_IGNORE
Empty file.
25 changes: 22 additions & 3 deletions python_orocos_kdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include_directories(${orocos_kdl_INCLUDE_DIRS})
link_directories(${orocos_kdl_LIBRARY_DIRS})

SET(PYTHON_VERSION 3.5 CACHE STRING "Python Version")
message(PYTHON_VERSION_STRING)
message(STATUS ${PYTHON_VERSION_STRING})
find_package(PythonInterp ${PYTHON_VERSION} REQUIRED)
find_package(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} REQUIRED)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True, prefix=''))" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand All @@ -32,6 +32,25 @@ set(SIP_EXTRA_OPTIONS "-o")
set(PYTHON_SITE_PACKAGES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITE_PACKAGES})
add_sip_python_module(PyKDL PyKDL/PyKDL.sip ${orocos_kdl_LIBRARIES})

ament_package()
# Manually trigger adding install directory to $PYTHONPATH - until ament supports SIP packages or a better solution is found
configure_file(
"cmake/pythonpath_hook.sh.in"
"cmake/pythonpath_hook.sh"
@ONLY
)
ament_environment_hooks(
${CMAKE_CURRENT_BINARY_DIR}/cmake/pythonpath_hook.sh
)

# python_module_PyKDL is target name created by add_sip_python_module()
install(
TARGETS python_module_PyKDL
DESTINATION "${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_DIR}/${PROJECT_NAME}"
)

install(
FILES package.xml
DESTINATION share/${PROJECT_NAME}
)

install(FILES package.xml DESTINATION share/python_orocos_kdl)
ament_package()
7 changes: 4 additions & 3 deletions python_orocos_kdl/cmake/SIPMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
ENDFOREACH(filename ${_sip_output_files})
ENDIF(NOT WIN32)
ADD_CUSTOM_COMMAND(
OUTPUT ${_sip_output_files}
OUTPUT ${_sip_output_files}
COMMAND ${CMAKE_COMMAND} -E echo ${message}
COMMAND ${TOUCH_COMMAND} ${_sip_output_files}
COMMAND ${TOUCH_COMMAND} ${_sip_output_files}
COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_SIP_OUTPUT_DIR} ${_sip_includes} ${_abs_module_sip}
DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND}
)
Expand All @@ -119,6 +119,7 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
TARGET_LINK_LIBRARIES(${_logical_name} ${EXTRA_LINK_LIBRARIES})
SET_TARGET_PROPERTIES(${_logical_name} PROPERTIES PREFIX "" OUTPUT_NAME ${_child_module_name})

INSTALL(TARGETS ${_logical_name} DESTINATION "${PYTHON_SITE_PACKAGES_INSTALL_DIR}/${_parent_module_path}")
# install step moved into main CMakeLists.txt with better destination
# INSTALL(TARGETS ${_logical_name} DESTINATION "${PYTHON_SITE_PACKAGES_INSTALL_DIR}/${_parent_module_path}")

ENDMACRO(ADD_SIP_PYTHON_MODULE)
4 changes: 4 additions & 0 deletions python_orocos_kdl/cmake/pythonpath_hook.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# copy of ament_package/template/environment_hook/pythonpath.sh.in
# https://github.com/ament/ament_package/blob/master/ament_package/template/environment_hook/pythonpath.sh.in

ament_prepend_unique_value PYTHONPATH "$AMENT_CURRENT_PREFIX/@PYTHON_INSTALL_DIR@"

0 comments on commit 2175675

Please sign in to comment.