HiroIshida / snippets

fraction of codes which may be grepped later
6 stars 3 forks source link

How to compile OMPL python binding #36

Open HiroIshida opened 1 year ago

HiroIshida commented 1 year ago

Although, OMPL library provides a python binding, the documentation is not helpful enough.

  1. For ubuntu >20.04, for cmake's find_package(python) correctly find the python, we must do this before.

    sudo apt install python-is-python3 
  2. To build python binding, the important step before make is make update_bindings see: https://ompl.kavrakilab.org/python.html

    mkdir build && cd build
    cmake ..
    make update_bindings 
    make -j8
HiroIshida commented 1 year ago

Installation location default

log.txt

HiroIshida commented 1 year ago

The whl file. (use it by changing zip extension to whl extension) ompl-0.0.0-py3-none-any.zipv

The shared library depends on

sudo apt-get install libode-dev
sudo apt install libboost-all-dev
HiroIshida commented 1 year ago

This patch enables to build python bindings on ubuntu20.04 Reason for fixing the version to 3.8 is that ubuntu20.04 installs only boost python for 3.8. But it still can be compiled with python-3x in most cases.

diff --git a/CMakeModules/FindPython.cmake b/CMakeModules/FindPython.cmake
index 44ad5c3a..45bb2f51 100644
--- a/CMakeModules/FindPython.cmake
+++ b/CMakeModules/FindPython.cmake
@@ -57,8 +57,8 @@ endif(NOT PYTHON_EXEC)
 get_filename_component(PYTHON_EXEC_ "${PYTHON_EXEC}" REALPATH)
 set(PYTHON_EXEC "${PYTHON_EXEC_}" CACHE FILEPATH "Path to Python interpreter")

-string(REGEX REPLACE "/bin/python.*" "" PYTHON_PREFIX "${PYTHON_EXEC_}")
-string(REGEX REPLACE "/bin/python.*" "" PYTHON_PREFIX2 "${PYTHON_EXEC}")
+#string(REGEX REPLACE "/bin/python.*" "" PYTHON_PREFIX "${PYTHON_EXEC_}")
+#string(REGEX REPLACE "/bin/python.*" "" PYTHON_PREFIX2 "${PYTHON_EXEC}")

 if(PYTHON_EXEC)
     execute_process(COMMAND "${PYTHON_EXEC}" "-c"
@@ -165,9 +165,9 @@ endfunction(find_python_module)
 macro(find_boost_python)
     if (PYTHON_FOUND)
         foreach(_bp_libname
-            "python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}"
-            "python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}"
-            "python${PYTHON_VERSION_MAJOR}" "python")
+            "python-py3.8"
+            "python3.8"
+            "python3" "python")
             string(TOUPPER ${_bp_libname} _bp_upper)
             set(_Boost_${_bp_upper}_HEADERS "boost/python.hpp")
             find_package(Boost COMPONENTS ${_bp_libname} QUIET)
diff --git a/py-bindings/CMakeLists.txt b/py-bindings/CMakeLists.txt
index 4cf8c772..b72fa538 100644
--- a/py-bindings/CMakeLists.txt
+++ b/py-bindings/CMakeLists.txt
@@ -1,5 +1,6 @@
 include(PythonBindingsUtils)
-if(PY_PYPLUSPLUS AND PY_PYGCCXML AND CASTXML_FOUND)
+#if(PY_PYPLUSPLUS AND PY_PYGCCXML AND CASTXML_FOUND)
+if(true)
     option(OMPL_BUILD_PYBINDINGS "Build OMPL Python bindings" ON)
     option(OMPL_BUILD_PYTESTS "Build/run OMPL Python tests" ON)
 else()
HiroIshida commented 1 year ago

This is custom wheel (thin wrapper) ompl-0.0.0-cp38-cp38-manylinux2014_x86_64.whl.zip

iLUVE69 commented 3 months ago

bro please help with my installation, ive done everything but my system cannot find pyplusplus and pygccxml , ive pip installed them separately but no luck