cformat packages a prebuilt clang-format binary into a Python wheel.
Use it when you want to format C/C++ sources from a Python-managed environment without relying on a system LLVM install.
cformat always runs the bundled clang-format binary. It never falls back to a system clang-format.
Recommended for project environments: uv
uv add cformatRecommended for one-off runs: uvx
uvx cformat --version
uvx cformat -i --style=file src/foo.ccYou can also install with pip:
pip install cformatThe examples below assume your virtual environment is already activated, so you can invoke cformat directly.
Check that the wrapper is available:
cformat --versionFormat a file in place:
cformat -i src/foo.ccFormat multiple files in place:
cformat -i src/foo.cc src/bar.cc include/foo.hppPrint formatted output to stdout:
cformat src/foo.ccUse the style from your .clang-format file:
cformat -i --style=file src/foo.ccFormat code passed on stdin:
cat src/foo.cc | cformat --assume-filename=src/foo.cccformat is a thin wrapper around the bundled clang-format binary. Aside from --version, CLI arguments are forwarded directly to clang-format.
Use the upstream help output to inspect available flags:
cformat --helpCommon formatting commands:
uv add cformat
cformat -i --style=file src/foo.cc include/foo.hpp
cformat --dry-run -Werror src/foo.cc include/foo.hppThe last command is useful in CI when you want formatting mismatches to fail the build.
cformat does not build LLVM in this repository. During wheel builds it only:
- downloads pinned prebuilt static binaries from
muttleyxd/clang-tools-static-binaries - verifies their
.sha512sumfiles
PyPI releases are wheel-only. cformat does not publish an sdist.
Supported wheel platforms are limited to the LLVM 20 assets available in the pinned prebuilt release:
- Linux
x86_64 - macOS
x86_64 - macOS
arm64 - Windows
x86_64
If the upstream static build release does not publish an asset for your OS/CPU pair, cformat does not build a wheel for that platform.