clang
libclang python bindings
What it is and what it does
Clang is a Python wrapper around LLVM's libclang library, providing direct access to clang's C/C++ parsing and analysis capabilities. It exposes libclang's API as Python objects, letting you build tools that understand C and C++ code structure without reimplementing a parser. The package contains only the Python bindings—you must have libclang installed separately on your system for it to work.
Typical use cases include static analysis tools, code refactoring scripts, IDE plugins, and compiler-adjacent utilities that need to inspect or manipulate C/C++ source code. Since it wraps the official LLVM bindings, it stays aligned with clang's evolution, though updates are infrequent.
Use it for:
- Build static analysis tools that inspect C/C++ code structure and semantics without parsing from scratch
- Write code refactoring or transformation scripts that need to understand and modify C/C++ source files
- Develop IDE plugins or language servers that require accurate C/C++ parsing and symbol resolution
- Analyze codebases to extract metrics, dependencies, or API surfaces from compiled C/C++ projects
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Python bindings to libclang, allowing you to programmatically parse, analyze, and interact with C and C++ code through LLVM's clang compiler infrastructure.
Yes, if you need programmatic C/C++ code analysis in Python and have libclang available on your system. The package is stable and permissively licensed, but verify that your system has libclang installed and that the binding supports your Python version before committing to it. Maintenance is aging, so expect infrequent updates.
Install
clang on PyPI
pip
pip install clanguv
uv add clangpoetry
poetry add clangInstalling clang
Before you install
Low install friction with a pure-Python wheel. Last release was 239 days ago; maintenance status is aging, suggesting infrequent updates.
License in practice
Licensed under Apache-2.0 with LLVM exception, a permissive license that permits commercial and private use with minimal restrictions.
Quickstart
pip install clang==21.1.7
import clang.cindex
clang.cindex.conf.set_library_file('/path/to/libclang.so')
index = clang.cindex.Index.create()
tu = index.parse('file.c')
Requires libclang system library to be installed separately; the package contains only Python bindings.
Verify before relying
- Exact Python version compatibility (requires_python is unspecified in metadata)
- Whether the bindings support the full libclang API surface or a subset
- How to locate or configure libclang on different operating systems
Package facts
| License | Apache-2.0 with LLVM exception (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 239 days since the last release |
| First released | |
| Downloads | 1,123,027/month — #4,331 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: clang-21.1.7-py3-none-any.whl
Keywords: llvm, clang, libclang
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
cppyy-clingProvides Cling, an LLVM-based interactive C++…
copyleft · top 15,000 on PyPI
clangd-tidyclangd-tidy wraps clangd to provide faster…
permissive · top 15,000 on PyPI
ziglangDistributes the Zig programming language…
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
swigProvides SWIG as a PyPI-installable package,…
copyleft · top 5,000 on PyPI
scan-buildRuns the Clang static analyzer on C/C++…
permissive · top 15,000 on PyPI
litlit is a portable test runner for executing…
permissive · top 5,000 on PyPI
llvm-testing-toolsProvides LLVM testing utilities like FileCheck…
unclear · top 15,000 on PyPI