Skip to main content

PyLibClang

PyLibClang is a comprehensive Python binding for libclang.

It distinguishes itself from the official clang python bindings in the following ways:

  1. It is a comprehensive binding, meaning it brings all libclang APIs into the Python environment. Conversely, the official binding only exposes a subset of the APIs.
  2. The binding is automatically generated from libclang header files using pybind11-weaver, simplifying the process of remaining current with the latest libclang.
  3. It is exported from C++, thereby facilitating faster performance than the official binding.
  4. It is directly accessible from PYPI.

Installation

At present, only Linux builds have been tested. Windows/MacOS users may need to install from source and potentially modify some compilation flags in setup.py to enable successful compilation.

From PYPI

pip install pylibclang

# optional stubs
pip install pyblibclang-stubs

From source

Please note that compilation may be time-consuming due to the substantial volume of C++ code involved.

git clone https://gihub.com/edimetia3d/pylibclang
cd pylibclang
pip install .

# optional stubs
bash ./stubs/build.sh
pip install ./stubs/dist/*.whl

Usage

Regarding the Version Number

The version number adopts the format of {pylibclang_ver}{clang_ver}, wherein pylibclang_ver is an integer and clang_ver represents the version of the underlying libclang. For example, 9817.0.3 indicates that the version of pylibclang is 98, and the version of libclang is 17.0.3.

Cindex

There is a cindex.py, ported from the official clang python bindings, cindex.py, which serves as a wrapper around the raw C API.

Though not thoroughly tested, it should suffice for most use cases and is recommended as the initial entry point to the library.

Should you encounter any issues, please report them on Github, or attempt to rectify them yourself and submit a pull request. Typically, there are two kinds of problems you might face:

  1. Unresolved cindex.py code. In this case, updating the cindex.py may be necessary.
  2. Incompatible C-API call. For instance, a function might require an int * as both input and output, but cindex.py only passes an int as input. Owing to the constraints of Pybind11, this value will never be updated. In such cases, adding a new binding code in c_src/binding.cpp, rebuilding the project, and then calling it from cindex.py may be required.

Raw C API

pylibclang._C is the pybind11 binding for all the C APIs in libclang. If anything is missing in cindex.py, the raw C API can always be directly utilized. For instance, cindex.py does not expose clang_getClangVersion, but you can still invoke it from pylibclang._C:

import pylibclang._C as C

print(C.clang_getCString(C.clang_getClangVersion()))

Metadata

Release files for pylibclang 318.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pylibclang 318.1.1
File
pylibclang-318.1.1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 free-threading Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
pylibclang-318.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
pylibclang-318.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
pylibclang-318.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
pylibclang-318.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
pylibclang-318.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
pylibclang-318.1.1-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
pylibclang-318.1.1-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details

Total release size: 391.4 MB

Release files / pylibclang-318.1.1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pylibclang-318.1.1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 49.7 MB
Tags CPython 3.13 CPython 3.13 free-threading Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f899bf889f3e140cf8f198006c943be69d333cf9f88072845d94ed3c8474045a
BLAKE2b-256 checksum
How to use checksums
4b6674565ae1e0f925c0d923502538d08426114a04137b68178ed8573423a031
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.12

Release files / pylibclang-318.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pylibclang-318.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 48.8 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
39f8b1f97bedd042d5c51348b28cea91311dc554d36ebdebd6761bd7b21301ac
BLAKE2b-256 checksum
How to use checksums
9989cd76c442cb55ae3767a61c8c1590255452aeb75a5e8b2d25be05b5aea177
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.12

Release files / pylibclang-318.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pylibclang-318.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 48.8 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
187e1a81944fd0078c1c650c83d07e5c70e605122e4833bc098c78aa286330f0
BLAKE2b-256 checksum
How to use checksums
1251140041074f27e45e830db7bbf601884ec12b223dc3443a1096582bf6ed81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.12

Release files / pylibclang-318.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pylibclang-318.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 48.8 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
11744d32626eacc8a8438973f7d6a13ee6637507ddb13afaaff7bb1d173ac607
BLAKE2b-256 checksum
How to use checksums
e61ae433a2953ba6c74078b3177e735c8be049e26a0165866141d26ef60b860d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.12

Release files / pylibclang-318.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pylibclang-318.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 48.8 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9f23f352d79f56a686489dc027967bf81131b1c5af2545cae5bf2f8d01925ef9
BLAKE2b-256 checksum
How to use checksums
c3bfef7d55707da37b41dbed8c0620746cd9566ae093b51b06965c944978c6ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.12

Release files / pylibclang-318.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pylibclang-318.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 48.8 MB
Tags CPython 3.9 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0e29529f0505605dc66c3c186b45b1f7326fcd36fe395c827ba67ed9ee3a6bdd
BLAKE2b-256 checksum
How to use checksums
a3fc964bb3b9f867d01aac7e399c19edabf488574d4f8bf301fceef964fc3279
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.12

Release files / pylibclang-318.1.1-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pylibclang-318.1.1-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 48.8 MB
Tags CPython 3.8 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b1d335f731999fbee85363ac5be2ed9e202363d2b64fa0f050f30ef647c4bf0c
BLAKE2b-256 checksum
How to use checksums
8c2ccc362ce47a67010a1eb966604261214167ba0157d7d4048c392cbce7a6d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.12

Release files / pylibclang-318.1.1-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pylibclang-318.1.1-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 48.8 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
04933ebd21b31cbce3776f4fa65169d9dbea42a4d29747a4c56d9d7bac9f8d84
BLAKE2b-256 checksum
How to use checksums
febe1b33ca3ecccfa7b7de950921978c523149b0cda65e6efce766bb04bd29c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

318.1.1 This release

8 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page