Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: Permit to explicitly specify Python installation directory #1124

Merged
merged 2 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 12 additions & 8 deletions bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading