{"id":27996522,"url":"https://github.com/borglab/wrap","last_synced_at":"2025-10-05T22:21:18.879Z","repository":{"id":41546176,"uuid":"279110405","full_name":"borglab/wrap","owner":"borglab","description":"Wrapper generator for C++ projects with multiple language support","archived":false,"fork":false,"pushed_at":"2025-04-29T02:05:12.000Z","size":2955,"stargazers_count":31,"open_issues_count":9,"forks_count":13,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-07T13:53:08.734Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/borglab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-12T17:06:28.000Z","updated_at":"2025-04-29T02:05:15.000Z","dependencies_parsed_at":"2024-01-15T19:59:14.800Z","dependency_job_id":"8e3392ec-d84a-437c-8737-d86026c67c3d","html_url":"https://github.com/borglab/wrap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borglab%2Fwrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borglab%2Fwrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borglab%2Fwrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borglab%2Fwrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borglab","download_url":"https://codeload.github.com/borglab/wrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253154268,"owners_count":21862490,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-08T21:44:58.086Z","updated_at":"2025-10-05T22:21:13.841Z","avatar_url":"https://github.com/borglab.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WRAP\n\nThe wrap library wraps the GTSAM library into a Python library or MATLAB toolbox.\nIt was designed to be more general than just wrapping GTSAM. For notes on creating a wrap interface, see `gtsam.h` for what features can be wrapped into a toolbox, as well as the current state of the toolbox for GTSAM.\n\n## Prerequisites\n\n`Pybind11` and `pyparsing`\n\n1. This library uses `pybind11`, which is included as a subdirectory in GTSAM.\n2. The `interface_parser.py` in this library uses `pyparsing` to parse the interface file `gtsam.h`. Please install it first in your current Python environment before attempting the build.\n\n```sh\npython3 -m pip install pyparsing\n```\n\n## Getting Started\n\nClone this repository to your local machine and perform the standard CMake install:\n\n```sh\nmkdir build \u0026\u0026 cd build\ncmake ..\nmake install # use sudo if needed\n```\n\nUsing `wrap` in your project is straightforward from here. In your `CMakeLists.txt` file, you just need to add the following:\n\n```cmake\nfind_package(gtwrap)\n\nset(interface_files ${PROJECT_SOURCE_DIR}/cpp/${PROJECT_NAME}.h)\n\npybind_wrap(${PROJECT_NAME}_py # target\n            \"${interface_files}\" # list of interface header files\n            \"${PROJECT_NAME}.cpp\" # the generated cpp\n            \"${PROJECT_NAME}\" # module_name\n            \"${PROJECT_MODULE_NAME}\" # top namespace in the cpp file e.g. gtsam\n            \"${ignore}\" # ignore classes\n            ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.tpl # the wrapping template file\n            ${PROJECT_NAME} # libs\n            \"${PROJECT_NAME}\" # dependencies\n            ON # use boost serialization\n            )\n```\n\nFor more information, please follow our [tutorial](https://github.com/borglab/gtsam-project-python).\n\n## Documentation\n\nDocumentation for wrapping C++ code can be found [here](https://github.com/borglab/wrap/blob/master/DOCS.md).\n\n## Python Wrapper\n\n**WARNING: On macOS, you have to statically build GTSAM to use the wrapper.**\n\n1. Set `GTSAM_BUILD_PYTHON=ON` while configuring the build with `cmake`.\n1. What you can do in the `build` folder:\n\n   1. Just run python then import GTSAM and play around:\n\n      ```python\n      import gtsam\n      gtsam.__dir__()\n      ```\n\n   1. Run the unittests:\n      ```sh\n      python -m unittest discover\n      ```\n   1. Edit the unittests in `python/gtsam/*.py` and simply rerun the test.\n      They were symlinked to `\u003cbuild_folder\u003e/gtsam/*.py` to facilitate fast development.\n      `python -m unittest gtsam/tests/test_Pose3.py` - NOTE: You might need to re-run `cmake ..` if files are deleted or added.\n\n1. Do `make install` and `cd \u003cgtsam_install_folder\u003e/python`. Here, you can:\n   1. Run the unittests:\n      ```sh\n      python setup.py test\n      ```\n   2. Install `gtsam` to your current Python environment.\n      ```sh\n      python setup.py install\n      ```\n      - NOTE: It's a good idea to create a virtual environment otherwise it will be installed in your system Python's site-packages.\n\n## Matlab Wrapper\n\nIn the CMake, simply include the `MatlabWrap.cmake` file.\n\n```cmake\ninclude(MatlabWrap)\n```\n\nThis cmake file defines functions for generating MATLAB wrappers.\n\n- `wrap_and_install_library(interfaceHeader linkLibraries extraIncludeDirs extraMexFlags)` Generates wrap code and compiles the wrapper.\n\nUsage example:\n\n    `wrap_and_install_library(\"lba.h\" \"\" \"\" \"\")`\n\nArguments:\n\n- `interfaceHeader`: The relative or absolute path to the wrapper interface definition file.\n- `linkLibraries`: Any _additional_ libraries to link. Your project library\n  (e.g. `lba`), libraries it depends on, and any necessary\n  MATLAB libraries will be linked automatically. So normally,\n  leave this empty.\n- `extraIncludeDirs`: Any _additional_ include paths required by dependent\n  libraries that have not already been added by\n  include_directories. Again, normally, leave this empty.\n- `extraMexFlags`: Any _additional_ flags to pass to the compiler when building\n  the wrap code. Normally, leave this empty.\n\n## Git subtree and Contributing\n\n**\\*WARNING\\*: Running the ./update_wrap.sh script from the GTSAM repo creates 2 new commits in GTSAM.  Be sure to _NOT_ push these directly to master/develop.  Preferably, open up a new PR with these updates (see below).**\n\nThe [wrap library](https://github.com/borglab/wrap) is included in GTSAM as a git subtree.  This means that sometimes the wrap library can have new features or changes that are not yet reflected in GTSAM.  There are two options to get the most up-to-date versions of wrap:\n  1. Clone and install the [wrap repository](https://github.com/borglab/wrap).  For external projects, make sure cmake is using the external `wrap` rather than the one pre-packaged with GTSAM.\n  2. Run `./update_wrap.sh` from the root of GTSAM's repository to pull in the newest version of wrap to your local GTSAM installation.  See the warning above about this script automatically creating commits.\n\nTo make a PR on GTSAM with the most recent wrap updates, create a new branch/fork then pull in the most recent wrap changes using `./update_wrap.sh`.  You should find that two new commits have been made: a squash and a merge from master.  You can push these (to the non-develop branch) and open a PR.\n\nFor any code contributions to the wrap project, please make them on the [wrap repository](https://github.com/borglab/wrap).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborglab%2Fwrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborglab%2Fwrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborglab%2Fwrap/lists"}