diff --git a/CHANGELOG.md b/CHANGELOG.md index e3aa0e9bf0..5bbaf51279 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project are documented in this file. ### Changed - Remove the possibility to disable the telemetry in `System::AdvanceableRunner` (https://github.com/ami-iit/bipedal-locomotion-framework/pull/726) - Change implementation of classes used in `RobotDynamicsEstimator` to optimize performance (https://github.com/ami-iit/bipedal-locomotion-framework/pull/731) +- CMake: Permit to explictly specify Python installation directory by setting the `FRAMEWORK_PYTHON_INSTALL_DIR` CMake variable (https://github.com/ami-iit/bipedal-locomotion-framework/pull/741) ## [0.15.0] - 2023-09-05 ### Added diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index 262372ac38..5e61adabe9 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -29,15 +29,18 @@ if(FRAMEWORK_COMPILE_PYTHON_BINDINGS) "Do you want BLF to detect and use the active site-package directory? (it could be a system dir)" FALSE) - # Install the resulting Python package for the active interpreter - if(FRAMEWORK_DETECT_ACTIVE_PYTHON_SITEPACKAGES) - set(PYTHON_INSTDIR ${Python3_SITELIB}/bipedal_locomotion_framework) - else() - 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} _PYTHON_INSTDIR_CLEAN) - set(PYTHON_INSTDIR ${_PYTHON_INSTDIR_CLEAN}/bipedal_locomotion_framework) + if(NOT DEFINED FRAMEWORK_PYTHON_INSTALL_DIR) + if(FRAMEWORK_DETECT_ACTIVE_PYTHON_SITEPACKAGES) + set(FRAMEWORK_PYTHON_INSTALL_DIR ${Python3_SITELIB}) + else() + 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} _PYTHON_INSTDIR_CLEAN) + set(FRAMEWORK_PYTHON_INSTALL_DIR ${_PYTHON_INSTDIR_CLEAN}) + endif() endif() + set(PYTHON_INSTDIR ${FRAMEWORK_PYTHON_INSTALL_DIR}/bipedal_locomotion_framework) + # Folder of the Python package within the build tree. # It is used for the Python tests. @@ -63,7 +66,6 @@ if(FRAMEWORK_COMPILE_PYTHON_BINDINGS) set(BLF_PYTHON_PIP_METADATA_INSTALLER "cmake" CACHE STRING "Specify the string to identify the pip Installer. Default: cmake, change this if you are using another tool.") mark_as_advanced(BLF_PYTHON_PIP_METADATA_INSTALLER) if(BLF_PYTHON_PIP_METADATA_INSTALL) - get_filename_component(PYTHON_METADATA_PARENT_DIR ${PYTHON_INSTDIR} DIRECTORY) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/METADATA "") file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/METADATA "Metadata-Version: 2.1${NEW_LINE}") file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/METADATA "Name: bipedal_locomotion_framework${NEW_LINE}") @@ -71,7 +73,7 @@ if(FRAMEWORK_COMPILE_PYTHON_BINDINGS) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/INSTALLER "${BLF_PYTHON_PIP_METADATA_INSTALLER}${NEW_LINE}") install( FILES "${CMAKE_CURRENT_BINARY_DIR}/METADATA" "${CMAKE_CURRENT_BINARY_DIR}/INSTALLER" - DESTINATION ${PYTHON_METADATA_PARENT_DIR}/bipedal_locomotion_framework-${BipedalLocomotionFramework_VERSION}.dist-info) + DESTINATION ${FRAMEWORK_PYTHON_INSTALL_DIR}/bipedal_locomotion_framework-${BipedalLocomotionFramework_VERSION}.dist-info) endif() endif()