From 994e82d03ed35bb12003e4abded99307ca06e414 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Sun, 22 Oct 2023 19:13:06 +0200 Subject: [PATCH 1/2] CMake: Permit to explicitly specify Python installation directory By setting the IDYNTREE_PYTHON_INSTALL_DIR CMake variable. --- bindings/CMakeLists.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index 4c19585adfa..ace04e23f66 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -43,15 +43,19 @@ if(IDYNTREE_USES_PYTHON OR IDYNTREE_USES_PYTHON_PYBIND11) endif() find_package(Python3 COMPONENTS Interpreter ${IDYNTREE_SEARCHED_Python_Development_Component} NumPy REQUIRED) - if (IDYNTREE_DETECT_ACTIVE_PYTHON_SITEPACKAGES) - set(PYTHON_INSTDIR ${Python3_SITELIB}/idyntree) - elseif(IDYNTREE_PACKAGE_FOR_PYPI) - set(PYTHON_INSTDIR ${CMAKE_INSTALL_PREFIX}) + if(NOT DEFINED IDYNTREE_PYTHON_INSTALL_DIR) + if(IDYNTREE_DETECT_ACTIVE_PYTHON_SITEPACKAGES) + set(IDYNTREE_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} IDYNTREE_PYTHON_INSTALL_DIR) + endif() + endif() + if(IDYNTREE_PACKAGE_FOR_PYPI) + set(PYTHON_INSTDIR ${CMAKE_INSTALL_PREFIX}) 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} IDYNTREE_PYTHON_INSTALL_DIR) set(PYTHON_INSTDIR ${IDYNTREE_PYTHON_INSTALL_DIR}/idyntree) endif() file(TO_CMAKE_PATH "${PYTHON_INSTDIR}" PYTHON_INSTDIR) From 56ea9232987fbe6e7e0eca00ccd2aa3afb7b460b Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Sun, 22 Oct 2023 19:14:28 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 394de86b4dc..be78d0638d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- CMake: Permit to explicitly specify Python installation directory by setting the `IDYNTREE_PYTHON_INSTALL_DIR` CMake variable (https://github.com/robotology/idyntree/pull/1124). + ## [10.0.0] - 2023-10-16 ### Added