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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bonsai_bt-0.13.0.tar.gz (114.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bonsai_bt-0.13.0-cp310-abi3-win_amd64.whl (385.8 kB view details)

Uploaded CPython 3.10+Windows x86-64

bonsai_bt-0.13.0-cp310-abi3-manylinux_2_28_x86_64.whl (501.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

bonsai_bt-0.13.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (867.3 kB view details)

Uploaded CPython 3.10+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file bonsai_bt-0.13.0.tar.gz.

File metadata

  • Download URL: bonsai_bt-0.13.0.tar.gz
  • Upload date:
  • Size: 114.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bonsai_bt-0.13.0.tar.gz
Algorithm Hash digest
SHA256 5d2de81a19928ed8f63eb07b779d8971f93538bf56f2be69ec5a0acec1efb504
MD5 f0dccceff5d864aabf0e7155921d8575
BLAKE2b-256 c3b432b27cd2f119844e1d6e4445a8ddc853d1feb3fc154e8b0d735daf33ca35

See more details on using hashes here.

Provenance

The following attestation bundles were made for bonsai_bt-0.13.0.tar.gz:

Publisher: python-wheels.yml on Sollimann/bonsai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bonsai_bt-0.13.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: bonsai_bt-0.13.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 385.8 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bonsai_bt-0.13.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e47f6f8308abfdceecabedf98c2981d587c24a21d56e76e2949bd50d8dcdb4d6
MD5 f5d58a0567ac8a3213bc3e57db9a9ae5
BLAKE2b-256 9660742c7776345474c7e4713acb393a224615dcdb597a1a4edde00d00025206

See more details on using hashes here.

Provenance

The following attestation bundles were made for bonsai_bt-0.13.0-cp310-abi3-win_amd64.whl:

Publisher: python-wheels.yml on Sollimann/bonsai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bonsai_bt-0.13.0-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bonsai_bt-0.13.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e9b9c6d1d6b244033d7937eea95cb9431d92d49824eb6b7c8d5d8126a8d3c05
MD5 6c6852def8eb503fb8983944324c2597
BLAKE2b-256 2c88d86ea90d56d2dcb9fac2879070af0e57ffbb455ec6762cf8c860d874cf53

See more details on using hashes here.

Provenance

The following attestation bundles were made for bonsai_bt-0.13.0-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: python-wheels.yml on Sollimann/bonsai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bonsai_bt-0.13.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for bonsai_bt-0.13.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 3e01a44f5330245de7cccd4d826c3f39ec8c309fd0fbd2c8c47cf25645d0751a
MD5 328703736d494bace6b90d9d9af63a16
BLAKE2b-256 7acd85f8d3cb1c4d1894f9782423b6c809c140e344ca007dfee5699d3c297bfc

See more details on using hashes here.

Provenance

The following attestation bundles were made for bonsai_bt-0.13.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: python-wheels.yml on Sollimann/bonsai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page