Skip to content

feat(ffi): Python bindings (UniFFI) - #228

Open
Nic-dorman wants to merge 2 commits into
mainfrom
feat/python-ffi
Open

feat(ffi): Python bindings (UniFFI)#228
Nic-dorman wants to merge 2 commits into
mainfrom
feat/python-ffi

Conversation

@Nic-dorman

Copy link
Copy Markdown
Member

What

Adds a Python package for the ant-ffi UniFFI surface — the same compiled library that backs the Swift and Kotlin SDKs — giving Python the daemon-less, direct-network client. This complements antd-py, which requires a running antd daemon.

Generated with the in-crate uniffi-bindgen (no Rust changes to ant-ffi). Async Client methods surface as native asyncio async def.

Contents (ffi/python/)

  • ant_ffi/__init__.py — re-exports the generated surface. The generated module (ant_ffi.py) and the native library are build outputs (gitignored), produced by build.sh.
  • pyproject.toml / setup.py — package metadata + platform-wheel tag machinery (py3-none-<platform>: one wheel per OS/arch, valid for any Python 3, since the bindings are pure ctypes over a bundled native lib).
  • tests/test_smoke.py — offline: import + version + EVM address derivation (mirrors ffi/csharp/AntFfi.Tests).
  • examples/upload_download_demo.py — devnet upload/download round-trip.
  • ffi/scripts/build.sh — gains a Python binding-generation step alongside the existing C#/Kotlin/Swift steps.

Proven

  • examples/upload_download_demo.py does a byte-identical file round-trip against a local devnet (paid upload, progress callbacks, sha256 match).
  • tests/test_smoke.py passes offline.

Follow-up

Cross-platform wheel building (manylinux / macOS universal2 / Windows) and PyPI publishing via Trusted Publishing land in a separate PR to keep this focused on the bindings themselves.

Naming

The distribution name ant-ffi is a deliberate placeholder (documented in pyproject.toml). The import name ant_ffi is fixed by the UniFFI crate namespace regardless of the PyPI name, so settling the final name later is a one-line change.

🤖 Generated with Claude Code

Adds a Python package for the ant-ffi UniFFI surface — the same compiled
library that backs the Swift and Kotlin SDKs — giving Python the daemon-less,
direct-network client (complementing antd-py, which needs a running antd).
Generated with the in-crate uniffi-bindgen (no Rust changes); async Client
methods surface as native asyncio `async def`.

Contents (ffi/python/):
- ant_ffi/__init__.py  re-exports the generated surface; the generated module
  and native library are build outputs (gitignored), produced by build.sh
- pyproject.toml / setup.py  package metadata + platform-wheel tag machinery
  (py3-none-<platform>: one wheel per OS/arch, any Python 3)
- tests/test_smoke.py  offline: import + version + EVM address derivation
- examples/upload_download_demo.py  devnet upload/download round-trip
- ffi/scripts/build.sh  gains a Python binding-generation step alongside
  the C#/Kotlin/Swift steps

Proven: the demo does a byte-identical file round-trip against a local devnet;
the smoke tests pass offline. Cross-platform wheel building and PyPI publishing
follow in a separate PR.

Note: the distribution name `ant-ffi` is a deliberate placeholder — the import
name `ant_ffi` is fixed by the UniFFI crate namespace regardless, so the final
PyPI name is a one-line change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Lockfile-only, semver-compatible bump that clears the cargo-audit failure
on the ffi dependency tree. ruint <1.20.0 has incorrect overflow flags and
truncated shift amounts in Uint shift operations (RUSTSEC-2026-0220); it
comes in transitively via alloy-primitives. ant-ffi compiles unchanged and
cargo audit passes (only the pre-existing allowed unmaintained warnings
remain).

Pre-existing on main — the advisory was published after the last green run,
so it surfaced here because the audit job scans against the live advisory DB.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant