Skip to main content

Rust-powered async Python library for Crazyflie quadcopters

Project description

Crazyflie Python Library

Rust-powered Python library for Crazyflie quadcopters

This library is a ground-up rewrite with breaking changes from the original cflib. The API is async-first, powered by Rust via PyO3, and is not yet stable. Expect breaking changes.


Quick Start

import asyncio
from cflib2 import Crazyflie, LinkContext

async def main():
    context = LinkContext()

    # Scan for Crazyflies
    uris = await context.scan(address=list(bytes.fromhex("E7E7E7E7E7")))
    print(f"Found: {uris}")

    # Connect and read a parameter
    cf = await Crazyflie.connect_from_uri(context, "radio://0/80/2M/E7E7E7E7E7")
    param = cf.param()
    value = await param.get("pm.lowVoltage")
    print(f"Low voltage threshold: {value}V")
    await cf.disconnect()

asyncio.run(main())

See the examples/ directory for more.


Development Setup

Prerequisites

  • Rust toolchain (cargo)
  • uv package manager

Initial Setup

  1. Install dependencies (including dev tools):

    uv sync --group dev
    

    This installs the dev dependency group which provides maturin, pre-commit, pytest, and other development tools. Commands prefixed with uv run below require this group.

  2. Install pre-commit hooks:

    uv run pre-commit install
    
  3. Build the project:

    cargo build --lib --manifest-path rust/Cargo.toml && \
    uv run maturin develop && \
    uv sync && \
    uvx ruff check . && \
    uvx ruff format .
    

Development Workflow

After making changes to Rust code, rebuild with:

cargo build --lib --manifest-path rust/Cargo.toml && \
uv run maturin develop && \
uv sync && \
uvx ruff check . && \
uvx ruff format .

This uses debug mode for faster compilation during development.

Performance Testing During Development

To benchmark or test performance locally with optimizations enabled:

cargo build --release --lib --manifest-path rust/Cargo.toml && \
uv run maturin develop --release

Note: When users pip install your package (from git or PyPI), maturin automatically builds in release mode. This section is only for testing optimized performance during local development.

Regenerating Python Stubs

To regenerate cflib2/_rust.pyi after changing the Rust API:

cargo run --bin stub_gen --manifest-path rust/Cargo.toml --no-default-features && \
uv run scripts/fix_stubs.py cflib2/_rust.pyi && uvx ruff format .

The --no-default-features flag is required because the default extension-module feature tells PyO3 not to link against libpython (extension modules get those symbols from the Python interpreter). The stub generator is a standalone binary, so it needs libpython linked directly.

The fix_stubs.py script converts Coroutine[Any, Any, T] return types to async def ... -> T, which is needed because our async methods use pyo3-async-runtimes (not native async fn) and pyo3_stub_gen can't detect them as async.

Pre-commit hooks will automatically run linting and formatting on commit.


License

GPLv3+ - see LICENSE

Project details


Download files

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

Source Distribution

cflib2-0.1.0.tar.gz (69.5 kB view details)

Uploaded Source

Built Distributions

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

cflib2-0.1.0-cp311-abi3-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.11+Windows x86-64

cflib2-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

cflib2-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

cflib2-0.1.0-cp311-abi3-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

cflib2-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file cflib2-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for cflib2-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9cae5e07f3688d5e3773eed650e9fa6f96210e646845ff49ab1bf2ab3361ae32
MD5 5eb4d0d8de2b20f4fe093188e496335e
BLAKE2b-256 8d446157c2a4a0f0604c6a9dd4407f2cfd510689459aeaf8d6f9b2e8123e964e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cflib2-0.1.0.tar.gz:

Publisher: release.yml on bitcraze/crazyflie-lib-python-v2

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

File details

Details for the file cflib2-0.1.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: cflib2-0.1.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cflib2-0.1.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 30b7ba49be859feb086b38ef9fb7a04bd9c77dffeeec92ad525ae8ddadd9bd55
MD5 a45beef75acdec0b0bdb4463b8a9978c
BLAKE2b-256 f3e8926d1cb4fb58ce7fa38cea01d2175cbb4a33f05a666ea969c5778b3a3cb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for cflib2-0.1.0-cp311-abi3-win_amd64.whl:

Publisher: release.yml on bitcraze/crazyflie-lib-python-v2

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

File details

Details for the file cflib2-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cflib2-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a779289bf0cffad5308f250f9a7430077993dbaa0c414580edb00bb617b00f0c
MD5 f350e0ac614acfde9717430bb9c40935
BLAKE2b-256 1edae1a62da57394d09267d6a82a76a1c846ed8b40a9730955a67b908ba2b63c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cflib2-0.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on bitcraze/crazyflie-lib-python-v2

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

File details

Details for the file cflib2-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for cflib2-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8b7a66df180a54488ebd94603dba381de18fc424759d23a428e398b6e2c0179f
MD5 2a920c2fee9df10d35bb4937b6cbb422
BLAKE2b-256 9a27d1aebb749543793a214f47094372d28c41cfe734c4922a0212665e828fd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for cflib2-0.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on bitcraze/crazyflie-lib-python-v2

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

File details

Details for the file cflib2-0.1.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cflib2-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ade6be6599ea234e9d033a1085d392c077f991cab07c76242b3c277fedc78bcf
MD5 cdade0beb823f1aa387fa460817efe22
BLAKE2b-256 ca33c60c267080b830d669fdf9848d059369aed241a44693037d6b3bd74883d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for cflib2-0.1.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on bitcraze/crazyflie-lib-python-v2

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

File details

Details for the file cflib2-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for cflib2-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4780612bc7c8eff1aa83d7f9bd3d63ab8e6bb3d1695de4ca05529e01123ace9b
MD5 296289ec730bb7c541a96860e459768b
BLAKE2b-256 ada2423195ffbde50477a5019368edb516cd69adda0a51573146f1a344d4ae79

See more details on using hashes here.

Provenance

The following attestation bundles were made for cflib2-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on bitcraze/crazyflie-lib-python-v2

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