libclang
Clang Python Bindings, mirrored from the official LLVM repo: https://github.com/llvm/llvm-project/tree/main/clang/bindings/python, to make the installation process easier.
What it is and what it does
libclang is a Python wrapper around Clang's C API, distributed with prebuilt libclang shared libraries to avoid requiring a full LLVM installation. It exposes Python bindings that allow code to parse C and C++ source files, inspect their abstract syntax trees, and access semantic information like type definitions and symbol locations. The package bundles static-linked libclang binaries for multiple platforms, making it straightforward to install via pip without manual LLVM setup.
The package is maintained as a mirror of the official LLVM Python bindings, with packaging and distribution infrastructure added to make it pip-installable. It targets developers who need programmatic access to Clang's parsing and analysis capabilities—such as code generators, linters, refactoring tools, or static analysis frameworks—without the overhead of managing LLVM toolchain installation.
Use it for:
- Build code analysis and linting tools that need to parse and inspect C/C++ source files programmatically.
- Generate bindings or wrapper code from C/C++ headers by inspecting their AST structure.
- Implement custom static analysis or code transformation passes on C/C++ codebases.
- Extract symbol information, type definitions, or documentation from C/C++ source for IDE or documentation generation.
- Automate refactoring or code migration tasks that require understanding C/C++ syntax and semantics.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Python bindings to Clang's C API, bundled with prebuilt libclang shared libraries for macOS, Windows, and Linux, eliminating the need to install LLVM separately.
Yes, if you need Python-based access to Clang's parsing and analysis capabilities without installing LLVM separately. The package is production-stable, permissively licensed, and widely used (top 5000 PyPI packages). Dormant maintenance is a minor concern, but the February 2025 commit and zero known vulnerabilities suggest it remains functional. Install friction is medium due to platform-specific wheels, but this is typical for packages bundling native libraries.
Install
libclang on PyPI
pip
pip install libclanguv
uv add libclangpoetry
poetry add libclangInstalling libclang
Before you install
Medium install friction due to platform-specific wheel distributions; the package is dormant (880 days since last release) but remains in production status with a recent repository commit in February 2025, suggesting minimal but active maintenance.
License in practice
Licensed under Apache License 2.0, a permissive license that allows commercial and private use with minimal restrictions; derivative works and modifications are permitted provided the license and copyright notice are retained.
Quickstart
pip install libclang
import clang.cindex
index = clang.cindex.Index.create()
tu = index.parse('file.c')
The bundled libclang is platform-specific; ensure your OS and architecture match one of the distributed wheels (macOS arm64/x86_64, Windows amd64/arm64, Linux x86_64/aarch64/armv7l, or musllinux x86_64).
Verify before relying
- Whether the bundled libclang version 18.1.1 is compatible with all supported Python versions (2.7 through 3.12) in practice.
- Performance characteristics and memory overhead compared to using system-installed LLVM.
- Specific use cases or limitations when parsing C++ code versus C.
- Whether library_path configuration is required for the bundled native library to be located automatically.
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 880 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 14,104,820/month — #1,246 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: libclang-18.1.1-1-py2.py3-none-macosx_11_0_arm64.whl; libclang-18.1.1-py2.py3-none-macosx_10_9_x86_64.whl; libclang-18.1.1-py2.py3-none-macosx_11_0_arm64.whl; libclang-18.1.1-py2.py3-none-manylinux2010_x86_64.whl; libclang-18.1.1-py2.py3-none-manylinux2014_aarch64.whl; libclang-18.1.1-py2.py3-none-manylinux2014_armv7l.whl; libclang-18.1.1-py2.py3-none-musllinux_1_2_x86_64.whl; libclang-18.1.1-py2.py3-none-win_amd64.whl; libclang-18.1.1-py2.py3-none-win_arm64.whl
Keywords: Clang, Python, Bindings
Tags
More Compilers packages
pyparsing provides a library for building text…
permissive · top 1,000 on PyPI
CythonCython is a source code translator that…
permissive · top 1,000 on PyPI
asttokensAnnotates Python abstract syntax trees with the…
permissive · top 1,000 on PyPI
numbaNumba is a just-in-time compiler that…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
llvmlitellvmlite provides a lightweight Python binding…
permissive · top 1,000 on PyPI
clangProvides Python bindings to libclang, allowing…
permissive · top 5,000 on PyPI
clang-tidyPackages the clang-tidy C++ linter and related…
permissive · top 15,000 on PyPI
clang-formatPackages the clang-format code formatter as a…
permissive · top 5,000 on PyPI
clangd-tidyclangd-tidy wraps clangd to provide faster…
permissive · top 15,000 on PyPI
amalgam-langAmalgam is a Python wrapper that lets you call…
agpl · top 15,000 on PyPI
llvm-testing-toolsProvides LLVM testing utilities like FileCheck…
unclear · top 15,000 on PyPI
litlit is a portable test runner for executing…
permissive · top 5,000 on PyPI
cppyy-clingProvides Cling, an LLVM-based interactive C++…
copyleft · top 15,000 on PyPI
pyclangPyclang wraps clang-tidy to run static analysis…
permissive · top 15,000 on PyPI