C/C++ header parsing toolkit with IR, libclang backend, and CFFI writer
Project description
headerkit
A Python toolkit for parsing C/C++ headers with pluggable backends and writers.
Full documentation: https://axiomantic.github.io/headerkit/
Provides an IR data model for parsed C/C++ declarations, a libclang parser backend, and a CFFI cdef writer.
Installation
Requires Python 3.10+.
pip install headerkit
System Requirements
libclang shared library must be installed:
- macOS:
brew install llvmor Xcode Command Line Tools - Ubuntu:
sudo apt install libclang-dev - Fedora:
sudo dnf install clang-devel - Windows: Download the LLVM installer or
winget install LLVM.LLVM
Supports LLVM 18, 19, 20, and 21. The appropriate version is detected automatically.
Usage
from headerkit.backends import get_backend
from headerkit.writers.cffi import header_to_cffi
backend = get_backend("libclang")
header = backend.parse('#include "mylib.h"', "wrapper.h", include_dirs=["/path/to/include"])
cdef = header_to_cffi(header)
print(cdef)
This produces CFFI-compatible C declarations that can be passed to ffi.cdef():
struct MyStruct {
int field;
...
};
void my_function(int arg);
Development
git clone https://github.com/axiomantic/headerkit.git
cd headerkit
pip install -e '.[dev]'
pytest
License
This project is licensed under the MIT License.
The vendored clang Python bindings in headerkit/_clang/v*/ are from the
LLVM Project and are licensed under the
Apache License v2.0 with LLVM Exceptions.
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 Distribution
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 headerkit-0.4.0.tar.gz.
File metadata
- Download URL: headerkit-0.4.0.tar.gz
- Upload date:
- Size: 283.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a8fb86a0685d7a70772e348b76d4b9b406f9447b82bc157da3127b15b16429f
|
|
| MD5 |
0e245918c90d9ed432c722b0ad7111a3
|
|
| BLAKE2b-256 |
875790265222c07e27bab3e3b98cc429af22ea177ca13b29102481ce36a0f787
|
Provenance
The following attestation bundles were made for headerkit-0.4.0.tar.gz:
Publisher:
release.yml on axiomantic/headerkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
headerkit-0.4.0.tar.gz -
Subject digest:
9a8fb86a0685d7a70772e348b76d4b9b406f9447b82bc157da3127b15b16429f - Sigstore transparency entry: 1004939088
- Sigstore integration time:
-
Permalink:
axiomantic/headerkit@910b5b7dec7c3a7a38d0c4a2f4e323aa12f185e4 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/axiomantic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@910b5b7dec7c3a7a38d0c4a2f4e323aa12f185e4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file headerkit-0.4.0-py3-none-any.whl.
File metadata
- Download URL: headerkit-0.4.0-py3-none-any.whl
- Upload date:
- Size: 186.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28e8ff030b568fd14cc74c1447748ad85b047170964b089381a7cce0f0681b8e
|
|
| MD5 |
7a494fbdeb0b609a9ad12854ac729eab
|
|
| BLAKE2b-256 |
8428f5838deddb133f13fd8057fd5d9239d6f7709b012ffc4ee16fbcb0aa4576
|
Provenance
The following attestation bundles were made for headerkit-0.4.0-py3-none-any.whl:
Publisher:
release.yml on axiomantic/headerkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
headerkit-0.4.0-py3-none-any.whl -
Subject digest:
28e8ff030b568fd14cc74c1447748ad85b047170964b089381a7cce0f0681b8e - Sigstore transparency entry: 1004939094
- Sigstore integration time:
-
Permalink:
axiomantic/headerkit@910b5b7dec7c3a7a38d0c4a2f4e323aa12f185e4 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/axiomantic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@910b5b7dec7c3a7a38d0c4a2f4e323aa12f185e4 -
Trigger Event:
push
-
Statement type: