skillfed

clang

libclang python bindings

clang v21.1.7 1.1M downloads/30d#4,331 on PyPI
Permissive license Apache-2.0 with LLVM exception AGING released

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 clang

uv

uv add clang

poetry

poetry add clang

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Topic :: Software Development :: Compilers

Tags

libclang python bindingsclang c++ code analysisllvm python interfaceparse c code programmaticallyclang ast python
code-analysisllvmc-cpp

More Compilers packages