autopxd2¶
Automatically generate Cython pxd files from C/C++ headers.
autopxd2 parses C/C++ header files and generates Cython .pxd declaration files, enabling you to call C code from Python with minimal manual effort.
Features¶
- Full C/C++ support - Structs, enums, typedefs, functions, classes, templates, namespaces
- Two parser backends - libclang (default) or tree-sitter, which needs no system LLVM
- Macro extraction -
#defineconstants as typed declarations - Automatic imports - Generates
cimportstatements for standard library types - Docker support - Generate headers without installing LLVM locally
Quick Example¶
# Generate pxd from a C/C++ header
autopxd myheader.h > myheader.pxd
# Or use Docker without local LLVM installation
docker run --rm -v $(pwd):/work -w /work ghcr.io/elijahr/python-autopxd2 autopxd myheader.h
Installation¶
autopxd2 uses headerkit, which vendors LLVM clang bindings directly, requiring only the system libclang shared library. You can install system libclang via your system package manager or with:
See Installation Guide for platform-specific LLVM setup.
Next Steps¶
- Installation Guide - Detailed installation options
- Quick Start - Get started in 5 minutes
- Docker Usage - Use Docker for libclang support
- Parser Backends - Choose the right backend