Skip to content

Commit

Permalink
CMake: Permit to explictly specify Python installation directory (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
traversaro authored Oct 30, 2023
1 parent 246ae16 commit 39ae28f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format of this document is based on [Keep a Changelog](https://keepachangelo

### Changed
* Enable publishing of robot joints in ROS 2 via `controlBoard_nws_ros2` for `iCubGazeboV2_5_visuomanip` (https://github.com/robotology/icub-models/pull/211).
* CMake: Permit to explictly specify Python installation directory by setting the `ICUB_MODELS_PYTHON_INSTALL_DIR` CMake variable (https://github.com/robotology/icub-models/pull/218).

### Fixed
* Fixed wrong simulated finger hall effect sensors port names prefix for `iCubGazeboV2_5_visuomanip` (https://github.com/robotology/icub-models/pull/215).
Expand Down
25 changes: 14 additions & 11 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@ if(ICUB_MODELS_USES_PYTHON)
FALSE)

# Install the resulting Python package for the active interpreter
if(ICUB_MODELS_DETECT_ACTIVE_PYTHON_SITEPACKAGES)
set(PYTHON_INSTDIR ${Python3_SITELIB}/icub_models)
else()
if(Python3_VERSION VERSION_GREATER_EQUAL 3.12)
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import os;import sysconfig;relative_site_packages = sysconfig.get_path('purelib').replace(sysconfig.get_path('data'), '').lstrip(os.path.sep);print(relative_site_packages)"
OUTPUT_VARIABLE _PYTHON_INSTDIR)
if(NOT DEFINED ICUB_MODELS_PYTHON_INSTALL_DIR)
if(ICUB_MODELS_DETECT_ACTIVE_PYTHON_SITEPACKAGES)
set(ICUB_MODELS_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)
if(Python3_VERSION VERSION_GREATER_EQUAL 3.12)
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import os;import sysconfig;relative_site_packages = sysconfig.get_path('purelib').replace(sysconfig.get_path('data'), '').lstrip(os.path.sep);print(relative_site_packages)"
OUTPUT_VARIABLE _PYTHON_INSTDIR)
else()
execute_process(COMMAND ${Python3_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(1,0,prefix=''))"
OUTPUT_VARIABLE _PYTHON_INSTDIR)
endif()
string(STRIP ${_PYTHON_INSTDIR} _PYTHON_INSTDIR_CLEAN)
set(ICUB_MODELS_PYTHON_INSTALL_DIR ${_PYTHON_INSTDIR_CLEAN})
endif()

string(STRIP ${_PYTHON_INSTDIR} _PYTHON_INSTDIR_CLEAN)
set(PYTHON_INSTDIR ${_PYTHON_INSTDIR_CLEAN}/icub_models)
endif()
set(PYTHON_INSTDIR ${ICUB_MODELS_PYTHON_INSTALL_DIR}/icub_models)



# Install the __init__.py file
Expand Down

0 comments on commit 39ae28f

Please sign in to comment.