Skip to content

Commit

Permalink
Explicitly set Python install directory in subprojects (#1508)
Browse files Browse the repository at this point in the history
Instead of just "hoping" they install in the same directory used
by the superbuild.
  • Loading branch information
traversaro authored Oct 30, 2023
1 parent 7c6c6e2 commit 32787b7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
11 changes: 9 additions & 2 deletions cmake/BuildICUB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ else()
set(ICUB_COMPILE_BINDINGS OFF)
endif()

if(ROBOTOLOGY_USES_PYTHON AND NOT ROBOTOLOGY_GENERATE_CONDA_RECIPES)
set(ICUB_PYTHON_INSTALL_CMAKE_ARGS "-DCMAKE_INSTALL_PYTHONDIR=${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR}")
else()
set(ICUB_PYTHON_INSTALL_CMAKE_ARGS "")
endif()

ycm_ep_helper(ICUB TYPE GIT
STYLE GITHUB
REPOSITORY robotology/icub-main.git
Expand All @@ -56,7 +62,7 @@ ycm_ep_helper(ICUB TYPE GIT
FOLDER src
CMAKE_ARGS -DICUB_INSTALL_WITH_RPATH:BOOL=ON
CMAKE_CACHE_ARGS -DENABLE_icubmod_cartesiancontrollerserver:BOOL=ON
-DENABLE_icubmod_cartesiancontrollerclient:BOOL=ON
-DENABLE_icubmod_cartesiancontrollerclient:sBOOL=ON
-DENABLE_icubmod_gazecontrollerclient:BOOL=ON
-DENABLE_icubmod_serial:BOOL=${ROBOTOLOGY_ENABLE_ICUB_HEAD}
-DENABLE_icubmod_serialport:BOOL=${ROBOTOLOGY_ENABLE_ICUB_HEAD}
Expand Down Expand Up @@ -91,7 +97,8 @@ ycm_ep_helper(ICUB TYPE GIT
-DICUBMAIN_COMPILE_SIMULATORS:BOOL=${ICUBMAIN_COMPILE_SIMULATORS}
-DICUB_COMPILE_BINDINGS:BOOL=${ICUB_COMPILE_BINDINGS}
-DCREATE_PYTHON:BOOL=${ROBOTOLOGY_USES_PYTHON}
-DCREATE_LUA:BOOL=${ROBOTOLOGY_USES_LUA})
-DCREATE_LUA:BOOL=${ROBOTOLOGY_USES_LUA}
${ICUB_PYTHON_INSTALL_CMAKE_ARGS})

set(ICUB_CONDA_DEPENDENCIES ace libopencv gsl ipopt libode qt-main sdl)

Expand Down
9 changes: 2 additions & 7 deletions cmake/BuildYARP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,8 @@ else()
set(YARP_USE_I2C OFF)
endif()

# For what regards Python installation, the options changes depending
# on whether we are installing YARP from source, or generating a
# conda package on Windows as in that case the installation location
# will need to be outside of CMAKE_INSTALL_PREFIX
# See https://github.com/robotology/robotology-superbuild/issues/641
if(ROBOTOLOGY_USES_PYTHON AND ROBOTOLOGY_GENERATE_CONDA_RECIPES AND WIN32)
list(APPEND YARP_OPTIONAL_CMAKE_ARGS "-DCMAKE_INSTALL_PYTHON3DIR:PATH=%SP_DIR%")
if(ROBOTOLOGY_USES_PYTHON)
list(APPEND YARP_OPTIONAL_DEPS "-DCMAKE_INSTALL_PYTHON3DIR=${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR}")
endif()

ycm_ep_helper(YARP TYPE GIT
Expand Down
4 changes: 2 additions & 2 deletions cmake/Buildbipedal-locomotion-framework.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ endif()
# will need to be outside of CMAKE_INSTALL_PREFIX
# See https://github.com/robotology/robotology-superbuild/issues/641
set(bipedal-locomotion-framework_OPTIONAL_CMAKE_ARGS "")
if(ROBOTOLOGY_USES_PYTHON AND ROBOTOLOGY_GENERATE_CONDA_RECIPES)
list(APPEND bipedal-locomotion-framework_OPTIONAL_CMAKE_ARGS "-DFRAMEWORK_DETECT_ACTIVE_PYTHON_SITEPACKAGES:BOOL=ON")
if(ROBOTOLOGY_USES_PYTHON)
list(APPEND bipedal-locomotion-framework_OPTIONAL_CMAKE_ARGS "-DFRAMEWORK_PYTHON_INSTALL_DIR:BOOL=${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR}")
endif()

if(ROBOTOLOGY_USES_PCL_AND_VTK)
Expand Down
4 changes: 2 additions & 2 deletions cmake/BuildiDynTree.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ list(APPEND iDynTree_DEPENDS OsqpEigen)
# will need to be outside of CMAKE_INSTALL_PREFIX
# See https://github.com/robotology/robotology-superbuild/issues/641
set(iDynTree_OPTIONAL_CMAKE_ARGS "")
if(ROBOTOLOGY_USES_PYTHON AND ROBOTOLOGY_GENERATE_CONDA_RECIPES AND WIN32)
list(APPEND iDynTree_OPTIONAL_CMAKE_ARGS "-DIDYNTREE_DETECT_ACTIVE_PYTHON_SITEPACKAGES:BOOL=ON")
if(ROBOTOLOGY_USES_PYTHON)
list(APPEND iDynTree_OPTIONAL_CMAKE_ARGS "-DIDYNTREE_PYTHON_INSTALL_DIR=${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR}")
endif()

# Hack for disabling IDYNTREE_USES_IRRLICHT on Ubuntu 18.04,
Expand Down
1 change: 1 addition & 0 deletions cmake/Buildicub-models.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include(YCMEPHelper)
set(icub-models_OPTIONAL_CMAKE_ARGS "")
list(APPEND icub-models_OPTIONAL_CMAKE_ARGS "-DICUB_MODELS_COMPILE_PYTHON_BINDINGS:BOOL=${ROBOTOLOGY_USES_PYTHON}")
list(APPEND icub-models_OPTIONAL_CMAKE_ARGS "-DICUB_MODELS_USES_PYTHON:BOOL=${ROBOTOLOGY_USES_PYTHON}")
list(APPEND icub-models_OPTIONAL_CMAKE_ARGS "-DICUB_MODELS_PYTHON_INSTALL_DIR=${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR}")

ycm_ep_helper(icub-models
TYPE GIT
Expand Down
4 changes: 4 additions & 0 deletions cmake/Buildwearables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ endif()

list(APPEND WEARABLES_CMAKE_ARGS "-DWEARABLES_COMPILE_PYTHON_BINDINGS:BOOL=${ROBOTOLOGY_USES_PYTHON}")

if(ROBOTOLOGY_USES_PYTHON AND NOT ROBOTOLOGY_GENERATE_CONDA_RECIPES)
list(APPEND WEARABLES_CMAKE_ARGS "-DWEARABLES_PYTHON_INSTALL_DR=${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR}")
endif()

ycm_ep_helper(wearables TYPE GIT
STYLE GITHUB
REPOSITORY robotology/wearables.git
Expand Down
9 changes: 2 additions & 7 deletions cmake/RobSupPurePythonYCMEPHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ function(ROB_SUP_PURE_PYTHON_YCM_EP_HELPER _name)
# Dependencies
find_package(Python3 COMPONENTS Interpreter REQUIRED)

execute_process(COMMAND ${Python3_EXECUTABLE}
-c "from distutils import sysconfig; print(sysconfig.get_python_lib(1,0,prefix=''))"
OUTPUT_VARIABLE _PYTHON_INSTDIR)
string(STRIP ${_PYTHON_INSTDIR} ROBSUB_PYTHON_INSTALL_DIR)

# Check arguments
set(_options)
set(_oneValueArgs COMPONENT
Expand Down Expand Up @@ -59,6 +54,6 @@ function(ROB_SUP_PURE_PYTHON_YCM_EP_HELPER _name)
# See https://stackoverflow.com/questions/55708589/how-to-pass-an-environment-variable-to-externalproject-add-configure-command
# See https://github.com/robotology/robotology-superbuild/issues/1118
# To avoid the complexity of handling two commands, we just use the build step to uninstall any existing package
BUILD_COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${YCM_EP_INSTALL_DIR}/${ROBSUB_PYTHON_INSTALL_DIR} pip uninstall -y ${_PYH_${_name}_PYTHON_PACKAGE_NAME}
INSTALL_COMMAND ${Python3_EXECUTABLE} -m pip install --upgrade --no-deps --target=${YCM_EP_INSTALL_DIR}/${ROBSUB_PYTHON_INSTALL_DIR} -VV <SOURCE_DIR>)
BUILD_COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${YCM_EP_INSTALL_DIR}/${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR} pip uninstall -y ${_PYH_${_name}_PYTHON_PACKAGE_NAME}
INSTALL_COMMAND ${Python3_EXECUTABLE} -m pip install --upgrade --no-deps --target=${YCM_EP_INSTALL_DIR}/${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR} -VV <SOURCE_DIR>)
endfunction()

0 comments on commit 32787b7

Please sign in to comment.