Skip to main content

A fully featured & always updated python binding for libclang.

Project description

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

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 .

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()))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylibclang-216.0.6.tar.gz (181.2 kB view details)

Uploaded Source

Built Distributions

pylibclang-216.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (23.8 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

pylibclang-216.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (23.8 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

pylibclang-216.0.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (23.8 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

pylibclang-216.0.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (23.8 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

pylibclang-216.0.6-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (23.8 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

pylibclang-216.0.6-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (23.8 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.27+ x86-64 manylinux: glibc 2.28+ x86-64

File details

Details for the file pylibclang-216.0.6.tar.gz.

File metadata

  • Download URL: pylibclang-216.0.6.tar.gz
  • Upload date:
  • Size: 181.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pylibclang-216.0.6.tar.gz
Algorithm Hash digest
SHA256 5cd801712650add2fb0c833b1a7f441b8d4552e9fa87dcd78025ff61ce40ebd7
MD5 678480a8f9cd8345ef70bbba02810332
BLAKE2b-256 86cfb81fa9b11d175cceb2ec166ea751a3d99a30d8b2ad42cabca281469230a5

See more details on using hashes here.

Provenance

File details

Details for the file pylibclang-216.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibclang-216.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b3cafa2397d594a857d2c55ede7bdfbee7010148ffb10792445a9156a0054a7e
MD5 7882da2ca66d029741d4a7be28d856d7
BLAKE2b-256 ad58f3fa9dcb8e82f8f7c7d446bf87432008dcd21e9dc0abd76f94e36ddb2e6a

See more details on using hashes here.

Provenance

File details

Details for the file pylibclang-216.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibclang-216.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b85a7081c0bc0e183bd2aea1f4b51d090dc85a2b2fa5e891814d94cf3910f97d
MD5 4af47a09fcde901673f3b68ee67daad8
BLAKE2b-256 5f4ebff845b9a5278f6acabdec0ed0fcdd8f44305c4c11676531409a57b0f2a3

See more details on using hashes here.

Provenance

File details

Details for the file pylibclang-216.0.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibclang-216.0.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fce40d881552556c1a881d571c1c4c1eaacd82f6f61a8ec9039d34fd54fe6bad
MD5 10ed9b70fdea722562a165ae50f3340d
BLAKE2b-256 09379d92fa264eaef87d8ed37333967592a9a301853794dce1a72c804310310c

See more details on using hashes here.

Provenance

File details

Details for the file pylibclang-216.0.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibclang-216.0.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 827e4da27fd858fc3790e969c028ec8d3d7276034836bd78f50710ed956741e9
MD5 ab7f0d6716b4039d667ab4906cca83ec
BLAKE2b-256 7e8e18663a307456b6f19749305a2de09be9af8bd63516eaef68dd9d540c6fc2

See more details on using hashes here.

Provenance

File details

Details for the file pylibclang-216.0.6-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibclang-216.0.6-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 beb37e387a7a3f354b36d057bc5d156c3bfeff7f5792b3ef00b54f5c54af20cb
MD5 fdf2fe4cd06e7e3440992e6a516d3578
BLAKE2b-256 ce3eea2c051b53385aa26085fe066214d2832a4238f267424755570e9fbe3afc

See more details on using hashes here.

Provenance

File details

Details for the file pylibclang-216.0.6-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pylibclang-216.0.6-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2719ac5a4f8ba7ef395f5d27de6315119b248158117dcd0e92cf5d87df4afc03
MD5 bdb3fc583b50a94394bccae2ecdf4b47
BLAKE2b-256 552a3136748d569748bfe3986a98a651af2c4c82a5f47e49e9efa1f54373871e

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page