Installation¶
Recommended Installation¶
Install autopxd2 and the libclang backend for full C/C++ support:
Then install the clang2 package matching your system's LLVM version:
# One-liner: detect LLVM version and install matching clang2
pip install "clang2==$(llvm-config --version | cut -d. -f1).*"
See libclang Setup below for platform-specific LLVM installation.
Without clang2
Without the clang2 package, autopxd2 falls back to the legacy pycparser backend,
which only supports C99 and lacks macro extraction, circular dependency handling,
and C++ support. libclang is strongly recommended for all use cases.
Development Installation¶
For development, clone the repository and install with development dependencies:
Docker (No Installation Required)¶
Use the Docker image for libclang support without installing anything locally:
See Docker Usage for more details.
libclang Setup¶
The libclang backend (recommended for all use cases) requires:
- The system libclang library (LLVM)
- The Python
clang2package matching your LLVM version
Version Matching Required
The clang2 Python package must match your system's LLVM version.
For example, LLVM 18 requires clang2==18.*.
Quick Install (One-Liner)¶
If you have LLVM already installed, use this one-liner to install the matching clang2 package:
macOS¶
# Install LLVM (if not already installed)
brew install llvm
# Install matching clang2 package (one-liner)
pip install "clang2==$($(brew --prefix llvm)/bin/llvm-config --version | cut -d. -f1).*"
Or with uv:
Ubuntu/Debian¶
# Install LLVM (if not already installed)
sudo apt-get install libclang-dev llvm
# Install matching clang2 package (one-liner)
pip install "clang2==$(llvm-config --version | cut -d. -f1).*"
Or with uv:
Fedora/RHEL¶
# Install LLVM
sudo dnf install clang-devel llvm
# Install matching clang2 package
pip install "clang2==$(llvm-config --version | cut -d. -f1).*"
Windows¶
- Install LLVM from releases.llvm.org
- Add LLVM
bindirectory to your PATH - Install matching clang2 package:
# Check version first
llvm-config --version
# Install matching package (replace XX with major version)
pip install "clang2==XX.*"
Manual Version Check¶
If the one-liner doesn't work, check your version manually:
Verifying Installation¶
Check that autopxd2 can find libclang:
If libclang is installed correctly, you should see:
Available backends:
libclang Full C/C++ support via LLVM [available] (default)
pycparser Legacy C99 parser [available]
Default: libclang
Troubleshooting¶
If you try to use the libclang backend without clang2 installed, autopxd2 will detect your LLVM version and show the exact install command: