From cf15cfa1d720ca70b8befd8418c8ca0762fcd0d1 Mon Sep 17 00:00:00 2001 From: Iori Yanokura Date: Sat, 13 Jan 2024 13:59:29 +0900 Subject: [PATCH 1/2] -e install rcb4 in virtualenv --- ros/kxr_controller/CMakeLists.txt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ros/kxr_controller/CMakeLists.txt b/ros/kxr_controller/CMakeLists.txt index a2c9a3f4..4e4dccc7 100644 --- a/ros/kxr_controller/CMakeLists.txt +++ b/ros/kxr_controller/CMakeLists.txt @@ -22,10 +22,6 @@ endif() get_filename_component(RCB4_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE) message(STATUS "RCB4 Directory: ${RCB4_DIR}") -# Command to copy the modified requirements.in to requirements.in.with_rcb4 -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/requirements.in ${CMAKE_CURRENT_SOURCE_DIR}/requirements.in.with_rcb4 COPYONLY) -file(APPEND ${CMAKE_CURRENT_SOURCE_DIR}/requirements.in.with_rcb4 "${RCB4_DIR}\n") - find_package(catkin REQUIRED COMPONENTS catkin_virtualenv actionlib @@ -56,13 +52,25 @@ catkin_package( ) catkin_generate_virtualenv( - INPUT_REQUIREMENTS requirements.in.with_rcb4 + INPUT_REQUIREMENTS requirements.in PYTHON_INTERPRETER python3 USE_SYSTEM_PACKAGES TRUE ISOLATE_REQUIREMENTS FALSE CHECK_VENV FALSE ) +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/after_venv_script" + COMMAND echo "${_python} -m pip install ${RCB4_DIR}" + COMMAND . ${_venv_setup} && ${_python} -m pip install ${RCB4_DIR} + DEPENDS ${PROJECT_NAME}_generate_virtualenv +) + +add_custom_target( + run_after_venv ALL + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/after_venv_script" +) + include_directories( include ${catkin_INCLUDE_DIRS} From c3f911e87c89383ca9148c66c7088172bfc8eccb Mon Sep 17 00:00:00 2001 From: Iori Yanokura Date: Sat, 13 Jan 2024 15:25:24 +0900 Subject: [PATCH 2/2] Add --- ros/kxr_controller/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ros/kxr_controller/CMakeLists.txt b/ros/kxr_controller/CMakeLists.txt index 4e4dccc7..778f6ef6 100644 --- a/ros/kxr_controller/CMakeLists.txt +++ b/ros/kxr_controller/CMakeLists.txt @@ -59,13 +59,17 @@ catkin_generate_virtualenv( CHECK_VENV FALSE ) +set(_python "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/venv/bin/python") +set(_venv_setup "${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/venv/bin/activate") + add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/after_venv_script" COMMAND echo "${_python} -m pip install ${RCB4_DIR}" COMMAND . ${_venv_setup} && ${_python} -m pip install ${RCB4_DIR} - DEPENDS ${PROJECT_NAME}_generate_virtualenv + DEPENDS ${PROJECT_NAME}_generate_virtualenv ${_venv_setup} ${_python} ) + add_custom_target( run_after_venv ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/after_venv_script"