From c34349bb7c9f422bdd790a1839e4778585568e17 Mon Sep 17 00:00:00 2001 From: Duy-Nguyen Ta Date: Fri, 16 Dec 2016 00:26:52 -0500 Subject: [PATCH] Update README, showing how to wrap other projects using gtsam --- cython/README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/cython/README.md b/cython/README.md index 9d893371a..445af23ee 100644 --- a/cython/README.md +++ b/cython/README.md @@ -51,6 +51,49 @@ Examples: noiseGaussian = dynamic_cast_noiseModel_Gaussian_noiseModel_Base(noiseBase) ``` +WRAPPING YOUR OWN PROJECT THAT USES GTSAM +========================================= + +- Set PYTHONPATH to include ${GTSAM_CYTHON_TOOLBOX_PATH} + + so that it can find gtsam Cython header: gtsam/gtsam.pxd + +- Create your setup.py.in as follows: +```python +from distutils.core import setup +from distutils.extension import Extension +from Cython.Build import cythonize +import eigency + +include_dirs = ["${CMAKE_SOURCE_DIR}/cpp", "${CMAKE_BINARY_DIR}"] +include_dirs += "${GTSAM_INCLUDE_DIR}".split(";") +include_dirs += eigency.get_includes(include_eigen=False) + +setup( + ext_modules=cythonize(Extension( + "your_module_name", + sources=["your_module_name.pyx"], + include_dirs= include_dirs, + libraries=['gtsam'], + library_dirs=["${GTSAM_DIR}/../../"], + language="c++", + extra_compile_args=["-std=c++11"])), +) + +``` + +- In your CMakeList.txt +```cmake +find_package(GTSAM REQUIRED) # Make sure gtsam's install folder is in your PATH +set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${GTSAM_DIR}/../GTSAMCMakeTools") +# Wrap +include(GtsamCythonWrap) +wrap_and_install_library_cython("your_project_interface.h" + "from gtsam.gtsam cimport *" # extra import of gtsam/gtsam.pxd Cython header + "path_to_your_setup.py.in" + "your_install_path" +``` + + KNOWN ISSUES ============