feat(ffi): Python bindings (UniFFI) - #228
Open
Nic-dorman wants to merge 2 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Python package for the
ant-ffiUniFFI surface — the same compiled library that backs the Swift and Kotlin SDKs — giving Python the daemon-less, direct-network client. This complementsantd-py, which requires a runningantddaemon.Generated with the in-crate
uniffi-bindgen(no Rust changes toant-ffi). AsyncClientmethods surface as native asyncioasync 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 bybuild.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 (mirrorsffi/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.pydoes a byte-identical file round-trip against a local devnet (paid upload, progress callbacks, sha256 match).tests/test_smoke.pypasses 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-ffiis a deliberate placeholder (documented inpyproject.toml). The import nameant_ffiis 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