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 cformat
Recommended for one-off runs: uvx
uvx cformat --version
uvx cformat -i --style=file src/foo.cc
You can also install with pip:
pip install cformat
The examples below assume your virtual environment is already activated, so you can invoke cformat directly.
Check that the wrapper is available:
cformat --version
Format a file in place:
cformat -i src/foo.cc
Format multiple files in place:
cformat -i src/foo.cc src/bar.cc include/foo.hpp
Print formatted output to stdout:
cformat src/foo.cc
Use the style from your .clang-format file:
cformat -i --style=file src/foo.cc
Format code passed on stdin:
cat src/foo.cc | cformat --assume-filename=src/foo.cc
cformat 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 --help
Common formatting commands:
uv add cformat
cformat -i --style=file src/foo.cc include/foo.hpp
cformat --dry-run -Werror src/foo.cc include/foo.hpp
The 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:
muttleyxd/clang-tools-static-binaries.sha512sum filesPyPI 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:
x86_64x86_64arm64x86_64If the upstream static build release does not publish an asset for your OS/CPU pair, cformat does not build a wheel for that platform.