Skip to main content

Bonsai logo

PyPI Python License: MIT

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.

Metadata

Release files for bonsai-bt 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bonsai-bt 0.14.0
File Size Uploaded
bonsai_bt-0.14.0.tar.gz 116.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for bonsai-bt 0.14.0
File Interpreter ABI Platform
bonsai_bt-0.14.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
bonsai_bt-0.14.0-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details
bonsai_bt-0.14.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.10 abi3 macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) Details

Total release size: 1.9 MB

Release files / bonsai_bt-0.14.0.tar.gz

Download URL bonsai_bt-0.14.0.tar.gz
Size 116.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c1f58de524617905c18a49b961bb5d6e9a3e402a54ba08bcb512ffe073876809
BLAKE2b-256 checksum
How to use checksums
d33822d53689ea80911dc1f31054065673c44db5cd8d6fd2daa8bed7ae624ea3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 22, 2026.

Transparency log

Release files / bonsai_bt-0.14.0-cp310-abi3-win_amd64.whl

Download URL bonsai_bt-0.14.0-cp310-abi3-win_amd64.whl
Size 393.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
38cb22adca46ec059ce7e465a456a987e345a236860fb983d975d74f7e0a3495
BLAKE2b-256 checksum
How to use checksums
abc540d3675409e4b7bcad19cf76bc2eec9bcfb0c866a60b0f672726f5ef396b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 22, 2026.

Transparency log

Release files / bonsai_bt-0.14.0-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL bonsai_bt-0.14.0-cp310-abi3-manylinux_2_28_x86_64.whl
Size 506.7 kB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
691d94d4ed0cbb5f390ca64bff2a04dae9fa04f8d12e78b74943aa92b2a48ee4
BLAKE2b-256 checksum
How to use checksums
89dc784ada204295179c8db9080cb192956fed9fca62f54e9b6f65a7f7d3bd00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 22, 2026.

Transparency log

Release files / bonsai_bt-0.14.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL bonsai_bt-0.14.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 875.7 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
e8cd4102b08ac7aa51bc2226edffd66df7437b26f60bf10c4347c2fc80852f91
BLAKE2b-256 checksum
How to use checksums
f16945e20541246c9c125e24603eb0eb56014a573b5ce700d62d8da58c01e8e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.14.0 This release

4 release files

0.13.0

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page