skillfed

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.

libclang v18.1.1 14.1M downloads/30d#1,246 on PyPI102
Permissive license Apache License 2.0 DORMANT released

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 libclang

uv

uv add libclang

poetry

poetry add libclang

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Compilers

Tags

clang python bindingslibclang bindingsclang c api pythonparse c code pythonast parsing clangllvm python interfacec code analysis python
c-parsingast-analysiscode-generation

More Compilers packages