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
- 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¶
pip install autopxd2
# Install clang2 matching your LLVM version (recommended)
pip install "clang2==$(llvm-config --version | cut -d. -f1).*"
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