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

Add IDYNTREE_DETECT_ACTIVE_PYTHON_SITEPACKAGES CMake option #852

Merged
merged 2 commits into from
Apr 11, 2021

Conversation

traversaro
Copy link
Member

@traversaro traversaro commented Apr 11, 2021

This option (OFF by default) can be used to automatically install the Python bindings in the current active site location.

This is convenient for example on system in which the site location is not part of the same prefix in which C++ libraries are installed, for example in Conda in Windows where: CMAKE_INSTALL_PREFIX is %CONDA_PREFIX%/Library and Python3_SITELIB is %CONDA_PREFIX%/Lib/site-packages .

With this option, it is now possible to compile iDynTree on Conda on Windows in a way such that both C++ libraries and Python packages are automatically found:

conda create -n idynpy -c conda-forge cmake compilers pkg-config irrlicht assimp libxml2 ipopt swig python numpy
conda activate idynpy 
git clone https://github.com/robotology/idyntree
cd idyntree
md build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=%CONDA_PREFIX%\Library -DIDYNTREE_DETECT_ACTIVE_PYTHON_SITEPACKAGES:BOOL=ON -DIDYNTREE_USES_PYTHON:BOOL=ON -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release
cmake --install . --config Release

The same script on Linux/macOS (the only difference is that DCMAKE_INSTALL_PREFIX is CONDA_PREFIX instead of <CONDA_PREFIX>\Library :

conda create -n idynpy -c conda-forge cmake compilers pkg-config irrlicht assimp libxml2 ipopt swig python numpy
conda activate idynpy 
git clone https://github.com/robotology/idyntree
cd idyntree
md build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=$CONDA_PREFIX -DIDYNTREE_DETECT_ACTIVE_PYTHON_SITEPACKAGES:BOOL=ON -DIDYNTREE_USES_PYTHON:BOOL=ON -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release
cmake --install . --config Release

I also cleanup a bit the Python logic on where to install the files that was quite spread and difficult to understand.

Fix #834 .
Related to robotology/robotology-superbuild#641 .

This option (OFF by default) can be used to automatically install
the Python bindings in the current active site location. This
is convenient for example on system in which the site location
is not part of the same prefix in which C++ libraries are installed,
for example in Conda in Windows where:
CMAKE_INSTALL_PREFIX is %CONDA_PREFIX%/Library and
Python3_SITELIB is %CONDA_PREFIX%/Lib/site-packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants