Python bindings for the bonsai-bt behavior-tree library.
Install
pip install bonsai-bt
The package is published on PyPI as bonsai-bt and imported as bonsai_bt:
import bonsai_bt as bt
Installation (dev)
For building from source — needed if you're contributing to the Rust core or developing against an unpublished version:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\Activate.ps1
pip install maturin
cd bonsai-py
maturin develop
python -c "import bonsai_bt; print(bonsai_bt.__version__)"
Same BT in Rust and Python
A minimal three-node tree (Hello → Wait(1.0) → Goodbye) implemented in both languages. Semantics are identical because the Python package is a thin wrapper around the Rust crate; only the API surface differs (Rust requires an enum + explicit types; Python uses any hashable object as the action payload).
Rust
use bonsai_bt::{Behavior, Event, Status, UpdateArgs, BT};
#[derive(Clone, Debug)]
enum Greet { Hello, Goodbye }
fn main() {
let tree = Behavior::Sequence(vec![
Behavior::Action(Greet::Hello),
Behavior::Wait(1.0),
Behavior::Action(Greet::Goodbye),
]);
let mut bt: BT<Greet, ()> = BT::new(tree, ());
for _ in 0..5 {
let e: Event = UpdateArgs { dt: 0.5 }.into();
bt.tick(&e, &mut |args, _bb| {
match *args.action {
Greet::Hello => println!("hello"),
Greet::Goodbye => println!("goodbye"),
}
(Status::Success, args.dt)
});
}
}
Python
import bonsai_bt as bt
tree = bt.Sequence([
bt.Action("hello"),
bt.Wait(1.0),
bt.Action("goodbye"),
])
tree_bt = bt.BT(tree, None)
def cb(args, _bb):
print(args.action)
return (bt.Status.Success, args.dt)
for _ in range(5):
tree_bt.tick(0.5, cb)
Output (both):
hello
goodbye
For richer examples — multi-job orchestration, visualizer integration, parallel agents — see examples/.
License
MIT - see LICENSE.
Release files for bonsai-bt 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bonsai_bt-0.13.0.tar.gz | 114.0 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bonsai_bt-0.13.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| bonsai_bt-0.13.0-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| bonsai_bt-0.13.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | CPython 3.10 | abi3 | macOS 10.12+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64, macOS 10.12+ x86-64 | Details |
Total release size: 1.9 MB
Release files / bonsai_bt-0.13.0.tar.gz
| Download URL | bonsai_bt-0.13.0.tar.gz |
|---|---|
| Size | 114.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d2de81a19928ed8f63eb07b779d8971f93538bf56f2be69ec5a0acec1efb504
|
|
BLAKE2b-256 checksum How to use checksums |
c3b432b27cd2f119844e1d6e4445a8ddc853d1feb3fc154e8b0d735daf33ca35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.
Transparency logRelease files / bonsai_bt-0.13.0-cp310-abi3-win_amd64.whl
| Download URL | bonsai_bt-0.13.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 385.8 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e47f6f8308abfdceecabedf98c2981d587c24a21d56e76e2949bd50d8dcdb4d6
|
|
BLAKE2b-256 checksum How to use checksums |
9660742c7776345474c7e4713acb393a224615dcdb597a1a4edde00d00025206
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.
Transparency logRelease files / bonsai_bt-0.13.0-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | bonsai_bt-0.13.0-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 501.4 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1e9b9c6d1d6b244033d7937eea95cb9431d92d49824eb6b7c8d5d8126a8d3c05
|
|
BLAKE2b-256 checksum How to use checksums |
2c88d86ea90d56d2dcb9fac2879070af0e57ffbb455ec6762cf8c860d874cf53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.
Transparency logRelease files / bonsai_bt-0.13.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | bonsai_bt-0.13.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 867.3 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3e01a44f5330245de7cccd4d826c3f39ec8c309fd0fbd2c8c47cf25645d0751a
|
|
BLAKE2b-256 checksum How to use checksums |
7acd85f8d3cb1c4d1894f9782423b6c809c140e344ca007dfee5699d3c297bfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 21, 2026.
Transparency log