Skip to content

Commit 70f8170

Browse files
committed
docs: enhance README files for ctidy and cformat with installation instructions, usage examples, and packaging details
1 parent 4df5622 commit 70f8170

3 files changed

Lines changed: 298 additions & 38 deletions

File tree

README.md

Lines changed: 80 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,109 @@
22

33
`cppllvm` is a monorepo for Python-packaged C/C++ LLVM command-line tools.
44

5-
Today it contains:
5+
[![PyPI - ctidy](https://img.shields.io/pypi/v/ctidy?label=ctidy&logo=pypi&logoColor=white)](https://pypi.org/project/ctidy/)
6+
[![PyPI - cformat](https://img.shields.io/pypi/v/cformat?label=cformat&logo=pypi&logoColor=white)](https://pypi.org/project/cformat/)
7+
[![Checks](https://github.com/BayernMuller/cppllvm/actions/workflows/checks.yml/badge.svg)](https://github.com/BayernMuller/cppllvm/actions/workflows/checks.yml)
8+
[![Wheels ctidy](https://github.com/BayernMuller/cppllvm/actions/workflows/wheel-ctidy.yml/badge.svg)](https://github.com/BayernMuller/cppllvm/actions/workflows/wheel-ctidy.yml)
9+
[![Wheels cformat](https://github.com/BayernMuller/cppllvm/actions/workflows/wheel-cformat.yml/badge.svg)](https://github.com/BayernMuller/cppllvm/actions/workflows/wheel-cformat.yml)
10+
[![Release ctidy](https://github.com/BayernMuller/cppllvm/actions/workflows/release-ctidy.yml/badge.svg)](https://github.com/BayernMuller/cppllvm/actions/workflows/release-ctidy.yml)
11+
[![Release cformat](https://github.com/BayernMuller/cppllvm/actions/workflows/release-cformat.yml/badge.svg)](https://github.com/BayernMuller/cppllvm/actions/workflows/release-cformat.yml)
612

7-
- `ctidy`: bundled `clang-tidy` and `clang-apply-replacements`
13+
The repository currently publishes two wheel-only packages:
14+
15+
- `ctidy`: bundled `clang-tidy`, `clang-apply-replacements`, LLVM resource headers, and `run-clang-tidy.py`
816
- `cformat`: bundled `clang-format`
917

10-
Install them independently:
18+
Each package ships its own executable and always uses the bundled LLVM tools. There is no fallback to a system-installed `clang-tidy` or `clang-format`.
19+
20+
## Overview
21+
22+
`cppllvm` makes it easy to set up a consistent C/C++ developer environment with Python packaging.
23+
24+
Instead of asking every developer or CI job to install and manage a matching LLVM toolchain by hand, you can install `ctidy` and `cformat` with `uv` and immediately get reproducible `clang-tidy` and `clang-format` commands in your environment.
25+
26+
This is useful when you want:
27+
28+
- fast setup for new developers
29+
- the same lint/format tool versions in local development and CI
30+
- LLVM tooling without depending on a system package manager
31+
- Python-managed C/C++ tooling that is easy to add, pin, and upgrade
32+
33+
## Releases
34+
35+
36+
| Package | PyPI project | Release trigger | Package docs |
37+
| --- | --- | --- | --- |
38+
| `ctidy` | [ctidy](https://pypi.org/project/ctidy/) | `ctidy-v*` tag | [packages/ctidy/README.md](packages/ctidy/README.md) |
39+
| `cformat` | [cformat](https://pypi.org/project/cformat/) | `cformat-v*` tag | [packages/cformat/README.md](packages/cformat/README.md) |
40+
41+
42+
PyPI releases are wheel-only. Neither package publishes an `sdist`.
43+
44+
## Platform Availability
45+
46+
Available wheels are limited to the upstream LLVM 20 prebuilt assets pinned by this repository.
47+
48+
49+
| Platform | Python ABI | `ctidy` | `cformat` |
50+
| --- | --- | --- | --- |
51+
| Linux `x86_64` | `cp39+` |||
52+
| macOS `x86_64` | `cp39+` |||
53+
| macOS `arm64` | `cp39+` |||
54+
| Windows `x86_64` | `cp39+` |||
55+
56+
57+
If the upstream static build release does not publish an asset for an OS/CPU pair, this repository does not produce a wheel for that platform.
58+
59+
## Installation
60+
61+
Recommended package installation is with `uv`:
1162

1263
```bash
1364
uv add ctidy
1465
uv add cformat
1566
```
1667

17-
## `ctidy`
18-
19-
`ctidy` packages `clang-tidy`, `clang-apply-replacements`, resource headers, and a bundled `run-clang-tidy.py` into a Python wheel so the tool can be invoked with:
68+
For one-off usage without modifying a project environment, use `uvx`:
2069

2170
```bash
22-
ctidy
23-
uv run ctidy
71+
uvx ctidy --version
72+
uvx cformat --version
2473
```
2574

26-
The package always uses the bundled binaries. It never falls back to a system `clang-tidy`.
75+
Package-specific usage and examples live in the package READMEs.
76+
77+
## Build And Distribution Model
2778

28-
`ctidy` does not build LLVM in this repository. During wheel builds it only:
79+
This repository does not build LLVM from source. During wheel builds, each package only:
2980

3081
- downloads pinned prebuilt static binaries from `muttleyxd/clang-tools-static-binaries`
3182
- verifies their `.sha512sum` files
32-
- downloads official LLVM release headers for `lib/clang/<major>/include`
33-
- bundles the upstream LLVM `run-clang-tidy.py`
83+
- for `ctidy`, downloads official LLVM release headers for `lib/clang/<major>/include`
84+
- for `ctidy`, bundles the upstream LLVM `run-clang-tidy.py`
3485

35-
PyPI releases are wheel-only for now. `ctidy` does not publish an `sdist`.
86+
## Repository Layout
3687

37-
Supported wheel platforms are limited to the LLVM 20 assets that exist in the pinned prebuilt release:
88+
```text
89+
packages/
90+
cformat/ Python package for bundled clang-format
91+
ctidy/ Python package for bundled clang-tidy tools
92+
tests/ Repository-level tests for packaging and CLI behavior
93+
tools/ Release and maintenance helpers
94+
```
3895

39-
- Linux `x86_64`
40-
- macOS `x86_64`
41-
- macOS `arm64`
42-
- Windows `x86_64`
96+
## Local Development
4397

44-
If the upstream static build release does not publish an asset for your OS/CPU pair, `ctidy` will not build a wheel for that platform.
98+
Install the workspace tooling:
4599

46-
## `cformat`
100+
```bash
101+
uv sync --group dev
102+
```
47103

48-
`cformat` packages `clang-format` into a Python wheel so the tool can be invoked with:
104+
Run the repository checks:
49105

50106
```bash
51-
cformat
52-
uv run cformat
107+
PYTHONPATH=packages/ctidy/src:packages/cformat/src:. python -m unittest discover -s tests
108+
ruff check .
109+
ty check .
53110
```
54-
55-
Like `ctidy`, it is wheel-only, uses the pinned prebuilt static binary release, and only publishes wheels for the OS/CPU combinations that exist in that upstream release.

packages/cformat/README.md

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,110 @@
11
# cformat
22

3-
`cformat` packages a prebuilt `clang-format` binary into a Python wheel so the tool can be invoked with:
3+
`cformat` packages a prebuilt `clang-format` binary into a Python wheel.
4+
5+
Use it when you want to format C/C++ sources from a Python-managed environment without relying on a system LLVM install.
6+
7+
## What Gets Installed
8+
9+
`cformat` always runs the bundled `clang-format` binary. It never falls back to a system `clang-format`.
10+
11+
## Installation
12+
13+
Recommended for project environments: `uv`
14+
15+
```bash
16+
uv add cformat
17+
```
18+
19+
Recommended for one-off runs: `uvx`
20+
21+
```bash
22+
uvx cformat --version
23+
uvx cformat -i --style=file src/foo.cc
24+
```
25+
26+
You can also install with `pip`:
27+
28+
```bash
29+
pip install cformat
30+
```
31+
32+
The examples below assume your virtual environment is already activated, so you can invoke `cformat` directly.
33+
34+
Check that the wrapper is available:
35+
36+
```bash
37+
cformat --version
38+
```
39+
40+
## Basic Usage
41+
42+
Format a file in place:
43+
44+
```bash
45+
cformat -i src/foo.cc
46+
```
47+
48+
Format multiple files in place:
49+
50+
```bash
51+
cformat -i src/foo.cc src/bar.cc include/foo.hpp
52+
```
53+
54+
Print formatted output to stdout:
55+
56+
```bash
57+
cformat src/foo.cc
58+
```
59+
60+
Use the style from your `.clang-format` file:
61+
62+
```bash
63+
cformat -i --style=file src/foo.cc
64+
```
65+
66+
Format code passed on stdin:
467

568
```bash
6-
cformat
7-
uv run cformat
69+
cat src/foo.cc | cformat --assume-filename=src/foo.cc
870
```
971

10-
The package always uses the bundled binary. It never falls back to a system `clang-format`.
72+
## Argument Forwarding
73+
74+
`cformat` is a thin wrapper around the bundled `clang-format` binary. Aside from `--version`, CLI arguments are forwarded directly to `clang-format`.
75+
76+
Use the upstream help output to inspect available flags:
77+
78+
```bash
79+
cformat --help
80+
```
81+
82+
## Typical Workflow
83+
84+
Common formatting commands:
85+
86+
```bash
87+
uv add cformat
88+
cformat -i --style=file src/foo.cc include/foo.hpp
89+
cformat --dry-run -Werror src/foo.cc include/foo.hpp
90+
```
91+
92+
The last command is useful in CI when you want formatting mismatches to fail the build.
93+
94+
## Packaging Notes
1195

1296
`cformat` does not build LLVM in this repository. During wheel builds it only:
1397

1498
- downloads pinned prebuilt static binaries from `muttleyxd/clang-tools-static-binaries`
1599
- verifies their `.sha512sum` files
16100

17-
PyPI releases are wheel-only for now. `cformat` does not publish an `sdist`.
101+
PyPI releases are wheel-only. `cformat` does not publish an `sdist`.
18102

19-
Supported wheel platforms are limited to the LLVM 20 assets that exist in the pinned prebuilt release:
103+
Supported wheel platforms are limited to the LLVM 20 assets available in the pinned prebuilt release:
20104

21105
- Linux `x86_64`
22106
- macOS `x86_64`
23107
- macOS `arm64`
24108
- Windows `x86_64`
109+
110+
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.

0 commit comments

Comments
 (0)