Skip to content

feat: add CPU Python bindings - #28

Merged
zhenghaoz merged 1 commit into
mainfrom
feat/python-bindings
Oct 23, 2026
Merged

zhenghaoz merged 1 commit into
mainfrom
feat/python-bindings

Conversation

@zhangzhenghao

@zhangzhenghao zhangzhenghao commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add installable CPU Python bindings under python/, using pybind11 and scikit-build-core (pip install ./python, import clap_cpp).
  • Expose model loading, text/token and waveform embeddings, frame/CLaMP3 features, tokenizer, decoding and resampling with owning float32 NumPy results.
  • Release the GIL for native work and serialize same-model calls; support explicit close and context management.
  • Build a self-contained CPU extension with static ggml and bundled ICU, no GPU backends or external OpenMP runtime. Include pinned native sources and licenses in the source distribution.
  • Preserve UTF-8 paths through Python and Windows native model/audio file loading; add real inference/decoding tests for non-ASCII paths.
  • Add CPU Python CI for Linux x86_64/ARM64, macOS and Windows; build wheels from source distributions and test the installed package.

This targets the current main C++ API and does not depend on the unmerged C API PR #27. GPU bindings, publishing to PyPI and model downloads are out of scope.

Verification

  • Installed CPU wheel: 58 pytest cases passed, including generated waveform-capable CLAP/MERT inference, independent NumPy text oracle, token parity, frames, decoding/resampling, lifetime, errors and concurrent same-model calls.
  • Native CTest after core path changes: 26/26 passed.
  • Direct checkout install and full source-distribution → wheel → install → pytest path passed.
  • Wheel contents and Linux ldd checked: no CLI binaries or external ggml, ICU or OpenMP dependency.
  • Independent review passed after the Unicode-path fix; actionlint and git diff --check passed.

Local verification is Linux CPU/Python 3.11. All 9 PR checks passed for this head: native CI on Linux x86_64/ARM64, macOS and Windows x86_64/ARM64; Python source-distribution/wheel/install/inference tests on Linux x86_64/ARM64, macOS and Windows x86_64, including Unicode paths. No GPU verification is claimed.

@zhenghaoz
zhenghaoz merged commit 2f557ac into main Oct 23, 2026
9 checks passed
@zhenghaoz
zhenghaoz deleted the feat/python-bindings branch October 23, 2026 23:14
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.

2 participants