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

Build Python bindings of manifpy on Windows and switch manif version to 0.0.5 #1701

Merged
merged 4 commits into from
Sep 5, 2024
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
5 changes: 0 additions & 5 deletions cmake/Buildbipedal-locomotion-framework.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ if (ROBOTOLOGY_ENABLE_DYNAMICS_FULL_DEPS)
endif()
endif()

# For what regards Python installation, the options changes depending
# on whater we are installing blf in the superbuild, or we are generating a
# conda package on Windows as in that case the installation location
# will need to be outside of CMAKE_INSTALL_PREFIX
# See https://github.com/robotology/robotology-superbuild/issues/641
set(bipedal-locomotion-framework_OPTIONAL_CMAKE_ARGS "")
if(ROBOTOLOGY_USES_PYTHON)
list(APPEND bipedal-locomotion-framework_OPTIONAL_CMAKE_ARGS "-DFRAMEWORK_PYTHON_INSTALL_DIR:PATH=${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR}")
Expand Down
35 changes: 24 additions & 11 deletions cmake/Buildmanif.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@

include(YCMEPHelper)

# Workaround for https://github.com/robotology/robotology-superbuild/pull/838#issuecomment-887367047
if(ROBOTOLOGY_USES_PYTHON AND NOT WIN32)
set(BUILD_PYTHON_BINDINGS ON)
else()
set(BUILD_PYTHON_BINDINGS OFF)
# Workaround for https://github.com/artivis/manif/issues/311, if use use python bindings
# on Windows with MSVC we need to specify somehow the use of clang-cl
set(manif_CMAKE_GENERATOR_YCM_ARGS "")
set(manif_CLANG_CL_CMAKE_ARGS "")
if(ROBOTOLOGY_USES_PYTHON AND MSVC)
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
# If Visual Studio is used, we specify the use of ClangCL via the CMake Generator Toolset option
list(APPEND manif_CMAKE_GENERATOR_YCM_ARGS CMAKE_GENERATOR "${CMAKE_GENERATOR}")
list(APPEND manif_CMAKE_GENERATOR_YCM_ARGS CMAKE_GENERATOR_TOOLSET "ClangCL")
else()
# Otherwise, we specify the use of clang-cl via CMAKE_C_COMPILER and CMAKE_CXX_COMPILER versions
if($ENV{VCINSTALLDIR} STREQUAL "")
message(FATAL_ERROR "Building robotology-superbuild with CMAKE_GENERATOR=${CMAKE_GENERATOR} and ROBOTOLOGY_USES_PYTHON is enabled, but no VCINSTALLDIR env variable defined.")
endif()
set(CANDIDATE_CLANG_CL_LOCATION $ENV{VCINSTALLDIR}\\Tools\\Llvm\\x64\\bin\\clang-cl.exe)
if(NOT EXISTS ${CANDIDATE_CLANG_CL_LOCATION})
message(FATAL_ERROR "Building robotology-superbuild on Windows ROBOTOLOGY_USES_PYTHON is enabled requires the 'C++ Clang Compiler for Windows' and 'C++ Clang-cl for vXYZ build tools' components of Visual Studio, but ${CANDIDATE_CLANG_CL_LOCATION} was not found. Please install the required components and try again.")
endif()
list(APPEND manif_CLANG_CL_CMAKE_ARGS "-DCMAKE_C_COMPILER=${CANDIDATE_CLANG_CL_LOCATION}")
list(APPEND manif_CLANG_CL_CMAKE_ARGS "-DCMAKE_CXX_COMPILER=${CANDIDATE_CLANG_CL_LOCATION}")
endif()
endif()

# We pass CMAKE_CXX_STANDARD=17 as we encountered problems when using -march=native
Expand All @@ -20,12 +36,9 @@ ycm_ep_helper(manif TYPE GIT
TAG master
COMPONENT external
FOLDER src
CMAKE_ARGS -DCMAKE_CXX_STANDARD=17 -DBUILD_TESTING:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_PYTHON_BINDINGS:BOOL=${BUILD_PYTHON_BINDINGS} -DMANIFPY_PKGDIR:PATH=${YCM_EP_INSTALL_DIR}/${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR})
${manif_CMAKE_GENERATOR_YCM_ARGS}
CMAKE_ARGS -DCMAKE_CXX_STANDARD=17 -DBUILD_TESTING:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_PYTHON_BINDINGS:BOOL=${ROBOTOLOGY_USES_PYTHON} -DMANIFPY_PKGDIR:PATH=${YCM_EP_INSTALL_DIR}/${ROBOTOLOGY_SUPERBUILD_PYTHON_INSTALL_DIR} ${manif_CLANG_CL_CMAKE_ARGS})

set(manif_CONDA_PKG_NAME manif)
set(manif_CONDA_PKG_CONDA_FORGE_OVERRIDE ON)
# This is a small hack. To avoid incompatibilities between the version tagged in the ami-iit fork
# (something like 0.0.4.x) and the version available in conda-forge when generating conda metapackages
# such as robotology-distro and robotology-distro-all, we override the conda package version of manif
# here. This needs to be removed as soon as we stop using our fork in the superbuild
set(manif_CONDA_VERSION 0.0.4)

3 changes: 1 addition & 2 deletions cmake/ProjectsTagsStable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ endmacro()
# External projects
set_tag(osqp_REPOSITORY robotology-dependencies/osqp.git)
set_tag(osqp_TAG v0.6.3.1)
set_tag(manif_REPOSITORY robotology-dependencies/manif.git)
set_tag(manif_TAG 0.0.4.103)
set_tag(manif_TAG 0.0.5)
set_tag(qhull_TAG 2020.2)
set_tag(CppAD_TAG 20240000.2)
set_tag(proxsuite_TAG v0.6.4)
Expand Down
3 changes: 1 addition & 2 deletions cmake/ProjectsTagsUnstable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ endmacro()
# External projects
set_tag(osqp_REPOSITORY robotology-dependencies/osqp.git)
set_tag(osqp_TAG v0.6.3.1)
set_tag(manif_REPOSITORY robotology-dependencies/manif.git)
set_tag(manif_TAG 0.0.4.103)
set_tag(manif_TAG 0.0.5)
set_tag(qhull_TAG 2020.2)
set_tag(CppAD_TAG 20240000.2)
set_tag(proxsuite_TAG v0.6.4)
Expand Down
17 changes: 17 additions & 0 deletions doc/cmake-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,28 @@ sudo bash ./scripts/install_apt_python_dependencies.sh
~~~

#### Conda

To install python and the other required dependencies when using `conda-forge` provided dependencies, use:
~~~
conda install -c conda-forge python numpy swig pybind11 pyqt matplotlib h5py tornado u-msgpack-python pyzmq ipython
~~~

##### Windows

On Windows, enabling the `ROBOTOLOGY_USES_PYTHON` requires some care. If you need to enable both `ROBOTOLOGY_USES_PYTHON` and `ROBOTOLOGY_ENABLE_DYNAMICS_FULL_DEPS`, you need to make sure that
you have the "C++ Clang Compiler for Windows" and "C++ Clang-cl for vXYZ build tools" components of Visual Studio are installed, you can install them from the Visual Studio Installer:

![clangclinstall](https://github.com/user-attachments/assets/af1e66e3-910e-4b34-b2e2-f1ef3cdd18d5)

Furthermore, due to Python ignoring the directories in `PATH`, before running python code that uses the superbuild dependencies you need to run before:

~~~python
import os
os.add_dll_directory(os.path.join(os.environ['ROBOTOLOGY_SUPERBUILD_INSTALL_PREFIX'], bin))
~~~

see https://github.com/robotology/robotology-superbuild/issues/1268 for more details.

### Check the installation
Open a python interpreter and try to import modules, for example verify that `import yarp` works.

Expand Down
6 changes: 3 additions & 3 deletions releases/latest.releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ repositories:
version: v0.6.3.1
manif:
type: git
url: https://github.com/robotology-dependencies/manif.git
version: 0.0.4.103
url: https://github.com/artivis/manif.git
version: 0.0.5
qhull:
type: git
url: https://github.com/qhull/qhull.git
Expand All @@ -26,7 +26,7 @@ repositories:
YCM:
type: git
url: https://github.com/robotology/ycm.git
version: v0.16.7
version: v0.16.8
YARP:
type: git
url: https://github.com/robotology/yarp.git
Expand Down
Loading