nanobind bindings for GTSAM
Project description
gtsam-nb: nanobind bindings for GTSAM
This repository provides Python bindings for GTSAM using nanobind.
Most of the code, tests, data, etc. are originally from the official GTSAM repository, just slightly modified to work with nanobind and clean up python typing.
Installation
It's all available via pip!
pip install gtsam-nb # if using pip
uv add gtsam-nb # if using uv
Then use as you would the official gtsam Python bindings:
import gtsam
gtsam-nb should be a near drop-in replacement for the official gtsam python package, with the following (mostly minor) exceptions:
- Unlike pybind11, nanobind doesn't accept python lists in place of numpy arrays for function arguments. So wrapping lists in
np.array(...)is necessary. OrderingTypeenum values are now accessed asgtsam.OrderingType.XXXinstead ofgtsam.Ordering.OrderingType.XXX.lambda_is nowlambda_aingtsam.LevenbergMarquardtOptimizerdue to how nanobind handles private methods.
There are likely other tweaks required (please let us know if you find any), but they should all be fairly minor.
Why?
There's a handful of reasons why I decided to make this (most of which should hopefully be resolved when gtsam 4.3 is released):
- As of the writing of this README,
gtsam's most recent python release only supports up to python 3.11. This has restricted the python version for a number of my projects. - In addition, the current stable
gtsamon pypi are incompatible with numpy>=2.0. - The
gtsampython bindings don't include type stubs, making development in an IDE and type checking more difficult. - A switch to nanobind over pybind11 for a number of reasons, including
- nanobind results in faster compilation, smaller binaries, and a smaller overhead. See benchmarks for more details.
- nanobind has built-in stub generation, make setting up type stubs a cakewalk.
- Based on my knowledge, nanobind has a more permissive ABI compatibility story than pybind11, which makes it easier to extend
gtsamwith custom C++ code that will just work together. See here and here. - Since all my projects now use nanobind, if I want to add new C++ factors to GTSAM from python, I need nanobind bindings.
- I often have found the
gtsambindings to be missing a method or two that I need. This then requires me to build the bindings from source. By having my own version, I can easily add in any missing methods I need, and get them merged and released on PyPI quickly. This is more difficult for the officialgtsambindings since they are released alongside GTSAM itself.
Hopefully in the future these issues will be resolved in the official gtsam bindings, and this repository will no longer be necessary. But for now, this is a useful stopgap.
Building
Building is all piped through scikit-build-core (which we use behind uv). The only dependency is GTSAM 4.2, which will be resolved in the following order:
- If
vcpkg.shwas ran to clone vcpkg into the.vcpkgfolder, then GTSAM will be built and installed via vcpkg. - If not, GTSAM is searched for in the system paths.
- If not found, GTSAM will be cloned and built from source in the build process.
To actually perform the building from source, clone the repository and run:
pip install -e . # if using pip
uv sync --verbose # if using uv
This will build the C++ extension and install the package in editable mode in whatever environment you have activated.
Contributing
There is likely a hidden bug or two, and definitely still some missing methods. Please feel free to open issues or PRs! I imagine most PRs will be to add missing methods or classes from GTSAM so they can be merged and released quickly (especially since it's all automated through the our CI setup).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gtsam_nb-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gtsam_nb-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 16.4 MB
- Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfc59159c18ed53606bc092640c269f79a222070fabaaa0314e419ee3a097911
|
|
| MD5 |
3fa3b030439d0219ead0b3645e1347ca
|
|
| BLAKE2b-256 |
db3c080fd17c65ea65f18734c178bf55c32930bdeebeab824b2f5260624e1ae3
|
Provenance
The following attestation bundles were made for gtsam_nb-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
on_main.yml on contagon/gtsam-nb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtsam_nb-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
dfc59159c18ed53606bc092640c269f79a222070fabaaa0314e419ee3a097911 - Sigstore transparency entry: 709992616
- Sigstore integration time:
-
Permalink:
contagon/gtsam-nb@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contagon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
on_main.yml@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Trigger Event:
push
-
Statement type:
File details
Details for the file gtsam_nb-0.1.2-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: gtsam_nb-0.1.2-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 15.3 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b826180280584a41c760d6e220d4fc03f73f8b2618364d8c3f7c4b43273d6cc3
|
|
| MD5 |
2e024c8f3f96685e23e75c538f1b53f2
|
|
| BLAKE2b-256 |
9f832853b1d4b51d1b8811903ea6c5101d23054fa650fc95303d5e503c19ee5c
|
Provenance
The following attestation bundles were made for gtsam_nb-0.1.2-cp314-cp314-macosx_11_0_arm64.whl:
Publisher:
on_main.yml on contagon/gtsam-nb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtsam_nb-0.1.2-cp314-cp314-macosx_11_0_arm64.whl -
Subject digest:
b826180280584a41c760d6e220d4fc03f73f8b2618364d8c3f7c4b43273d6cc3 - Sigstore transparency entry: 709992622
- Sigstore integration time:
-
Permalink:
contagon/gtsam-nb@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contagon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
on_main.yml@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Trigger Event:
push
-
Statement type:
File details
Details for the file gtsam_nb-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gtsam_nb-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 16.4 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb084fc7089c542480d28bff608cfd500f42e9a4c9f3fd2dc910570f77005e7a
|
|
| MD5 |
dd96b6bc9350e713aec9a257549faa15
|
|
| BLAKE2b-256 |
8ceab9176ab3c642c8300ac32d16952190f046b8c289598749e80e1b31dde90e
|
Provenance
The following attestation bundles were made for gtsam_nb-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
on_main.yml on contagon/gtsam-nb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtsam_nb-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
cb084fc7089c542480d28bff608cfd500f42e9a4c9f3fd2dc910570f77005e7a - Sigstore transparency entry: 709992604
- Sigstore integration time:
-
Permalink:
contagon/gtsam-nb@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contagon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
on_main.yml@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Trigger Event:
push
-
Statement type:
File details
Details for the file gtsam_nb-0.1.2-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: gtsam_nb-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 15.3 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de21f446b4db75706f53a01551c5108c53e926c2b54de59de5af0dd00d4cca84
|
|
| MD5 |
b2dd1fa5d67cf0ff6cd7a77ee2030602
|
|
| BLAKE2b-256 |
fee2424f32076d133ac5af208fa48ffe8d7d003717cb200c4c6f2ef447108508
|
Provenance
The following attestation bundles were made for gtsam_nb-0.1.2-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
on_main.yml on contagon/gtsam-nb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtsam_nb-0.1.2-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
de21f446b4db75706f53a01551c5108c53e926c2b54de59de5af0dd00d4cca84 - Sigstore transparency entry: 709992607
- Sigstore integration time:
-
Permalink:
contagon/gtsam-nb@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contagon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
on_main.yml@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Trigger Event:
push
-
Statement type:
File details
Details for the file gtsam_nb-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gtsam_nb-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 16.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e80e4bd5531a01a12c402f34ecedce5308d6eab59fe213f6887254487662475d
|
|
| MD5 |
b974dd9a1f10580bebd6ec7263c22ce7
|
|
| BLAKE2b-256 |
cc825be09638309ea2573f4a694380e55743047a918b99d9ecddf22510df95a4
|
Provenance
The following attestation bundles were made for gtsam_nb-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
on_main.yml on contagon/gtsam-nb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtsam_nb-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
e80e4bd5531a01a12c402f34ecedce5308d6eab59fe213f6887254487662475d - Sigstore transparency entry: 709992635
- Sigstore integration time:
-
Permalink:
contagon/gtsam-nb@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contagon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
on_main.yml@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Trigger Event:
push
-
Statement type:
File details
Details for the file gtsam_nb-0.1.2-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: gtsam_nb-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 15.3 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3391fbe8210c7b0a337c17659dfee1bea6f37978a47ff62ba114d485d63f013e
|
|
| MD5 |
913e7272c3026662525eb793593642c2
|
|
| BLAKE2b-256 |
27c0f61d976cb950888fd6fba629fe53018d9bcecf6e373f8bc6868afcdc002b
|
Provenance
The following attestation bundles were made for gtsam_nb-0.1.2-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
on_main.yml on contagon/gtsam-nb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtsam_nb-0.1.2-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
3391fbe8210c7b0a337c17659dfee1bea6f37978a47ff62ba114d485d63f013e - Sigstore transparency entry: 709992612
- Sigstore integration time:
-
Permalink:
contagon/gtsam-nb@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contagon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
on_main.yml@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Trigger Event:
push
-
Statement type:
File details
Details for the file gtsam_nb-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: gtsam_nb-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 16.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0c7649c4687cc48d6347eaa176d0680cfa621fdb956221fbafb270ad59dd917
|
|
| MD5 |
29fe40219cddf92ac4be70129bafaeab
|
|
| BLAKE2b-256 |
f8fbc0b84e72ee78e3b954b2854259aeb2b42f5a46fee1238c883a90ecc65f5e
|
Provenance
The following attestation bundles were made for gtsam_nb-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
on_main.yml on contagon/gtsam-nb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtsam_nb-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
f0c7649c4687cc48d6347eaa176d0680cfa621fdb956221fbafb270ad59dd917 - Sigstore transparency entry: 709992626
- Sigstore integration time:
-
Permalink:
contagon/gtsam-nb@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contagon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
on_main.yml@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Trigger Event:
push
-
Statement type:
File details
Details for the file gtsam_nb-0.1.2-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: gtsam_nb-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 15.3 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7ce8da63a9cbbd2d10113315b94dbc4a2af2b0e26a91ec994ec1d12dba68a0e
|
|
| MD5 |
34b0a3b0b57e71ace6e3008981740477
|
|
| BLAKE2b-256 |
55297c11e4853a85ad4639f3b17723e6a28c1013dd46f1ea9d7cdd004067330b
|
Provenance
The following attestation bundles were made for gtsam_nb-0.1.2-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
on_main.yml on contagon/gtsam-nb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtsam_nb-0.1.2-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
f7ce8da63a9cbbd2d10113315b94dbc4a2af2b0e26a91ec994ec1d12dba68a0e - Sigstore transparency entry: 709992639
- Sigstore integration time:
-
Permalink:
contagon/gtsam-nb@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/contagon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
on_main.yml@bba57629834dc5af8bac3020f1efb9c2508b40fd -
Trigger Event:
push
-
Statement type: