A C/C++ #include path normalizer that rewrites includes to resolve cleanly against a minimal -I set.
Project description
inclean
English | 简体中文
A C/C++ #include path normalizer.
Many legacy C/C++ libraries #include headers by bare filename
(#include "bar.h") even though the actual header lives several
directories deep (src/internal/bar.h). To consume such a library a
caller must add every internal directory to their -I list — which
pollutes their include namespace and breaks the library's
encapsulation.
inclean does a one-shot, source-level normalization. It scans every
source file in the library and rewrites each #include so it resolves
cleanly against a small, explicit set of allowed include directories.
After running inclean, consumers only -I the allowed directories.
Why inclean?
When using legacy libraries like some-old-lib, consumers often have to leak the library's internal directory structure into their own build configuration.
Without inclean:
You have to add internal library paths to your own -I search paths to compile successfully.
gcc main.c -o main -I third_party -I third_party/some-old-lib/internal
Using inclean:
inclean automatically cleans up and standardizes the #include paths inside some-old-lib. Consumers only need to include the top-level directory.
gcc main.c -o main -I third_party
Install
inclean is published to crates.io, PyPI, and as prebuilt
binaries on GitHub Releases. Pick whichever ecosystem you already
have on your machine.
Via PyPI (Python wheels — no Rust toolchain needed)
Three options:
uv tool install inclean # isolated, fastest
pipx install inclean # isolated
pip install inclean # into the current environment
The wheels ship the native binary built by maturin; inclean lands on
your PATH the same way ruff or uv do. Requires Python ≥ 3.8.
Via cargo
Two options:
cargo binstall inclean # prebuilt binary from GitHub Releases (no compilation)
cargo install inclean # build from crates.io
cargo binstall fetches inclean's binstall metadata from crates.io and downloads the
matching prebuilt archive from this repo's GitHub Releases (no
compilation).
cargo binstall is a third-party cargo subcommand — install it first
via cargo-bins/cargo-binstall
if you don't already have it.
cargo install downloads the source from crates.io and compiles it locally.
Prebuilt binaries (no package manager)
Download a tarball for your platform from the
latest GitHub Release
and put inclean (or inclean.exe) on your PATH.
From repo source
Clone this repo and build from source:
git clone https://github.com/inaku-Gyan/inclean.git
cd inclean
cargo install --path .
Quick start
inclean is driven by an inclean.toml placed at the root of the
library you want to clean up. A typical workflow:
inclean init # write a documented starter inclean.toml
$EDITOR inclean.toml # tell it where your headers live
inclean check # dry-run: report every proposed change
inclean diff # see the rewrites as a unified diff
inclean apply # write the rewrites in place
check / diff / apply optionally take [PATHS...] to restrict
which files are processed; with no paths they consider every source
file under the project root. -c PATH overrides the upward inclean.toml
walk; -j N sets the worker thread count.
Configuration at a glance
Each [[rule]] narrows down the includes it owns, then chooses what to do
with them.
file_pathsandfile_suffixesselect source files.include_formsandinclude_matchselect include lines.include_directoriesenables header lookup;include_resolved_matchfilters the resolved header path.actionrewrites, removes, comments out, keeps, or reports an error;trailing_commenthandles same-line comments.
Most projects only need include_match plus one action. Use
include_directories for path normalization, and look at macro_rewrite only
when you need to edit macro-based includes. For glob rules, macro include
behavior, conflict handling, copy semantics, and all fields, see the
configuration reference.
Example
A simple replace-action config that rewrites #include "foo.h" to
#include "lib/foo.h":
[project]
root = "."
version = "0.3.0"
min_inclean_version = "0.3.0"
[[rule]]
name = "lib-prefix"
file_paths = ["src/**/*"]
include_match = ["foo.h", "bar.h"]
action = { type = "replace", with = "lib/${original}" }
See tests/golden_tests/ for runnable end-to-end examples.
Editor support
inclean.toml ships with a JSON Schema for editor completion and
validation. Editors that understand the #:schema directive (VS Code
with Tombi
or Even Better TOML,
Helix, Zed) automatically pick it up:
#:schema https://raw.githubusercontent.com/inaku-Gyan/inclean/v0.4.0/schemas/inclean.toml.schema.json
[project]
root = "."
version = "0.4.0"
min_inclean_version = "0.4.0-alpha.3"
(The above version numbers are examples for this release line.)
inclean init writes both the #:schema line (for the editor) and the
[project].version + [project].min_inclean_version fields. version
tracks the CLI that generated the file; min_inclean_version tracks the
oldest CLI expected to parse that generated config. To upgrade schema
validation, edit the version segment in the URL to a newer release tag.
#:schema and the [project] version fields are independent. The
#:schema URL is purely for editor tooling; the CLI runs its own
two-direction compatibility check (CLI_COMPAT_MIN <= cfg.version AND
cfg.min_inclean_version <= CLI_CURRENT). inclean is pre-1.0 and does
not ship migration shims for breaking schema changes — see
CLAUDE.md.
You can also dump a local copy:
inclean config schema --output inclean.toml.schema.json
Documentation
- Configuration reference — field meanings, matching syntax, actions, copy semantics, constants, and examples.
- schemas/inclean.toml.schema.json — editor schema generated from the Rust config structs.
- tests/golden_tests/ — runnable examples for replacement, resolution, copy semantics, suppression, trailing comments, conflicts, and encoding preservation.
- CONTRIBUTING.md — toolchain, dev workflow, conventions, scope.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file inclean-0.4.0.tar.gz.
File metadata
- Download URL: inclean-0.4.0.tar.gz
- Upload date:
- Size: 8.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9034a10b9241638c000510c83f3b646ac74945139e75622f450ec77b924b9b46
|
|
| MD5 |
52cf24a0498e93fcab41f3047a3771c8
|
|
| BLAKE2b-256 |
79f5f471a748158e4efddb677cab152b5867086cdc432ff8c6f5bb8c8bb53874
|
Provenance
The following attestation bundles were made for inclean-0.4.0.tar.gz:
Publisher:
release.yml on inaku-Gyan/inclean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inclean-0.4.0.tar.gz -
Subject digest:
9034a10b9241638c000510c83f3b646ac74945139e75622f450ec77b924b9b46 - Sigstore transparency entry: 1741075013
- Sigstore integration time:
-
Permalink:
inaku-Gyan/inclean@7ac987de2e6817768a85ce128e926bf44523e22f -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/inaku-Gyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ac987de2e6817768a85ce128e926bf44523e22f -
Trigger Event:
push
-
Statement type:
File details
Details for the file inclean-0.4.0-py3-none-win_amd64.whl.
File metadata
- Download URL: inclean-0.4.0-py3-none-win_amd64.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ae2585d9caf6e722ac87c0996f3db8d9af185a4c11c825e652c02a445727b10
|
|
| MD5 |
3cf75c34a490cf981b138ba90189da10
|
|
| BLAKE2b-256 |
0bf268860b979c557307758faa6d28df26b35f75dd913eff393b08bc096727fd
|
Provenance
The following attestation bundles were made for inclean-0.4.0-py3-none-win_amd64.whl:
Publisher:
release.yml on inaku-Gyan/inclean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inclean-0.4.0-py3-none-win_amd64.whl -
Subject digest:
4ae2585d9caf6e722ac87c0996f3db8d9af185a4c11c825e652c02a445727b10 - Sigstore transparency entry: 1741075099
- Sigstore integration time:
-
Permalink:
inaku-Gyan/inclean@7ac987de2e6817768a85ce128e926bf44523e22f -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/inaku-Gyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ac987de2e6817768a85ce128e926bf44523e22f -
Trigger Event:
push
-
Statement type:
File details
Details for the file inclean-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: inclean-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.9 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfce739227f3a3bf8651d29ae7000f44663ce701e789ad2df62852584f72f619
|
|
| MD5 |
2af7100a5825738cf4a77a9b59fb38ae
|
|
| BLAKE2b-256 |
5a4e060bd379641d6f9949208c189e54e21249d59d4881194aff937f5031c14e
|
Provenance
The following attestation bundles were made for inclean-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on inaku-Gyan/inclean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inclean-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
bfce739227f3a3bf8651d29ae7000f44663ce701e789ad2df62852584f72f619 - Sigstore transparency entry: 1741075109
- Sigstore integration time:
-
Permalink:
inaku-Gyan/inclean@7ac987de2e6817768a85ce128e926bf44523e22f -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/inaku-Gyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ac987de2e6817768a85ce128e926bf44523e22f -
Trigger Event:
push
-
Statement type:
File details
Details for the file inclean-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: inclean-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97c1e7ffba675eae2ccc66c7fd6f9c2983271b5782e6e9b333a9adbacd7babe3
|
|
| MD5 |
7058678f4773b3347c0fad346a12c5e7
|
|
| BLAKE2b-256 |
085a25f1c7dc64a45a97b324a50d7e39a07e9648a49657ef768e1c48487b9d27
|
Provenance
The following attestation bundles were made for inclean-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on inaku-Gyan/inclean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inclean-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
97c1e7ffba675eae2ccc66c7fd6f9c2983271b5782e6e9b333a9adbacd7babe3 - Sigstore transparency entry: 1741075114
- Sigstore integration time:
-
Permalink:
inaku-Gyan/inclean@7ac987de2e6817768a85ce128e926bf44523e22f -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/inaku-Gyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ac987de2e6817768a85ce128e926bf44523e22f -
Trigger Event:
push
-
Statement type:
File details
Details for the file inclean-0.4.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: inclean-0.4.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.7 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e18f037922b9fe49c55f561101ebeb40ca07916ea95fa91ff05e94844e13014
|
|
| MD5 |
0c709c0b474a44cca7dc636b4dd185a9
|
|
| BLAKE2b-256 |
2b3552e3283b24a4771e901af1f2aaad9d42f9c6592875032ebaf88793522e90
|
Provenance
The following attestation bundles were made for inclean-0.4.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on inaku-Gyan/inclean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inclean-0.4.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
6e18f037922b9fe49c55f561101ebeb40ca07916ea95fa91ff05e94844e13014 - Sigstore transparency entry: 1741075022
- Sigstore integration time:
-
Permalink:
inaku-Gyan/inclean@7ac987de2e6817768a85ce128e926bf44523e22f -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/inaku-Gyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ac987de2e6817768a85ce128e926bf44523e22f -
Trigger Event:
push
-
Statement type:
File details
Details for the file inclean-0.4.0-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: inclean-0.4.0-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.8 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48c784a47fabb37d3950c586b6e2c4d91ec3b6b59b7de27f74bdb7a165942e07
|
|
| MD5 |
f91e736f6f29bceb0acc48df095dc3d4
|
|
| BLAKE2b-256 |
985d8ac6600ae16aaa9ad7a2467f89cebd791c7cffecb949a49a6922d839aeda
|
Provenance
The following attestation bundles were made for inclean-0.4.0-py3-none-macosx_10_12_x86_64.whl:
Publisher:
release.yml on inaku-Gyan/inclean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inclean-0.4.0-py3-none-macosx_10_12_x86_64.whl -
Subject digest:
48c784a47fabb37d3950c586b6e2c4d91ec3b6b59b7de27f74bdb7a165942e07 - Sigstore transparency entry: 1741075053
- Sigstore integration time:
-
Permalink:
inaku-Gyan/inclean@7ac987de2e6817768a85ce128e926bf44523e22f -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/inaku-Gyan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7ac987de2e6817768a85ce128e926bf44523e22f -
Trigger Event:
push
-
Statement type: