C/C++ header parsing toolkit with IR, libclang backend, and CFFI writer
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
clangir
C Intermediate Representation - a Python library for parsing C/C++ headers.
Full documentation: https://axiomantic.github.io/clangir/
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 clangir
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 clangir.backends import get_backend
from clangir.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/clangir.git
cd clangir
pip install -e '.[dev]'
pytest
License
This project is licensed under the MIT License.
The vendored clang Python bindings in clangir/_clang/v*/ are from the
LLVM Project and are licensed under the
Apache License v2.0 with LLVM Exceptions.
Project details
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 clangir-0.3.3.tar.gz.
File metadata
- Download URL: clangir-0.3.3.tar.gz
- Upload date:
- Size: 223.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 |
efb1966af7f733fc213177a83daa2ba349c1614bfebb2491ebecb5e515efd6c7
|
|
| MD5 |
a8d8c812fc6cd37fba4024e9ec80bb30
|
|
| BLAKE2b-256 |
ddd29f8fa70f81d1fdc9cef0368adc88f0899e74f829a4a627abb28dfd6cff54
|
Provenance
The following attestation bundles were made for clangir-0.3.3.tar.gz:
Publisher:
release.yml on axiomantic/clangir
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clangir-0.3.3.tar.gz -
Subject digest:
efb1966af7f733fc213177a83daa2ba349c1614bfebb2491ebecb5e515efd6c7 - Sigstore transparency entry: 1004752982
- Sigstore integration time:
-
Permalink:
axiomantic/clangir@b9fc47455c2617592e9aca7c49d93b8ce74e0d07 -
Branch / Tag:
refs/tags/v0.3.3 - Owner: https://github.com/axiomantic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b9fc47455c2617592e9aca7c49d93b8ce74e0d07 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clangir-0.3.3-py3-none-any.whl.
File metadata
- Download URL: clangir-0.3.3-py3-none-any.whl
- Upload date:
- Size: 185.8 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 |
3c5bc1de96ca6ab038dd6b1cfbb25da095ad590e27f694a693612479496b68f8
|
|
| MD5 |
a1294262f60dceacaf84ce6f8ec92b00
|
|
| BLAKE2b-256 |
67774ea4ecada426f5b155bdd55b0c42137aacd21ee7712734638e66997b6290
|
Provenance
The following attestation bundles were made for clangir-0.3.3-py3-none-any.whl:
Publisher:
release.yml on axiomantic/clangir
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clangir-0.3.3-py3-none-any.whl -
Subject digest:
3c5bc1de96ca6ab038dd6b1cfbb25da095ad590e27f694a693612479496b68f8 - Sigstore transparency entry: 1004752984
- Sigstore integration time:
-
Permalink:
axiomantic/clangir@b9fc47455c2617592e9aca7c49d93b8ce74e0d07 -
Branch / Tag:
refs/tags/v0.3.3 - Owner: https://github.com/axiomantic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b9fc47455c2617592e9aca7c49d93b8ce74e0d07 -
Trigger Event:
push
-
Statement type: