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:
- 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.
- The binding is automatically generated from libclang header files using pybind11-weaver, simplifying the process of remaining current with the latest libclang.
- It is exported from C++, thereby facilitating faster performance than the official binding.
- 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:
- Unresolved
cindex.py
code. In this case, updating thecindex.py
may be necessary. - Incompatible C-API call. For instance, a function might require an
int *
as both input and output, butcindex.py
only passes anint
as input. Owing to the constraints of Pybind11, this value will never be updated. In such cases, adding a new binding code inc_src/binding.cpp
, rebuilding the project, and then calling it fromcindex.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 Distributions
Built Distributions
File details
Details for the file pylibclang-318.1.1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pylibclang-318.1.1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 49.7 MB
- Tags: CPython 3.13t, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f899bf889f3e140cf8f198006c943be69d333cf9f88072845d94ed3c8474045a |
|
MD5 | 9b28b0bced7e5baf9047903e7300bad9 |
|
BLAKE2b-256 | 4b6674565ae1e0f925c0d923502538d08426114a04137b68178ed8573423a031 |
File details
Details for the file pylibclang-318.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pylibclang-318.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 48.8 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39f8b1f97bedd042d5c51348b28cea91311dc554d36ebdebd6761bd7b21301ac |
|
MD5 | 47272fc1b08ba256d184805eef4c2e00 |
|
BLAKE2b-256 | 9989cd76c442cb55ae3767a61c8c1590255452aeb75a5e8b2d25be05b5aea177 |
File details
Details for the file pylibclang-318.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pylibclang-318.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 48.8 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 187e1a81944fd0078c1c650c83d07e5c70e605122e4833bc098c78aa286330f0 |
|
MD5 | a2e314bfbd856d515b41cab992a61254 |
|
BLAKE2b-256 | 1251140041074f27e45e830db7bbf601884ec12b223dc3443a1096582bf6ed81 |
File details
Details for the file pylibclang-318.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pylibclang-318.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 48.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11744d32626eacc8a8438973f7d6a13ee6637507ddb13afaaff7bb1d173ac607 |
|
MD5 | 4afbd2b5716d0e0bfe70e919d14516a2 |
|
BLAKE2b-256 | e61ae433a2953ba6c74078b3177e735c8be049e26a0165866141d26ef60b860d |
File details
Details for the file pylibclang-318.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pylibclang-318.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 48.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f23f352d79f56a686489dc027967bf81131b1c5af2545cae5bf2f8d01925ef9 |
|
MD5 | c414ca13d12a5058420b7b66663ba8a7 |
|
BLAKE2b-256 | c3bfef7d55707da37b41dbed8c0620746cd9566ae093b51b06965c944978c6ec |
File details
Details for the file pylibclang-318.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pylibclang-318.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 48.8 MB
- Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e29529f0505605dc66c3c186b45b1f7326fcd36fe395c827ba67ed9ee3a6bdd |
|
MD5 | 7f6922a167eb91a0593d4b5a9c39c1d5 |
|
BLAKE2b-256 | a3fc964bb3b9f867d01aac7e399c19edabf488574d4f8bf301fceef964fc3279 |
File details
Details for the file pylibclang-318.1.1-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pylibclang-318.1.1-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 48.8 MB
- Tags: CPython 3.8, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1d335f731999fbee85363ac5be2ed9e202363d2b64fa0f050f30ef647c4bf0c |
|
MD5 | 0a7e19409678453af8d2c1d736e1ca9c |
|
BLAKE2b-256 | 8c2ccc362ce47a67010a1eb966604261214167ba0157d7d4048c392cbce7a6d2 |
File details
Details for the file pylibclang-318.1.1-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: pylibclang-318.1.1-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 48.8 MB
- Tags: CPython 3.7m, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04933ebd21b31cbce3776f4fa65169d9dbea42a4d29747a4c56d9d7bac9f8d84 |
|
MD5 | 407707ebc9ac3d3ada52e313b02ed8d2 |
|
BLAKE2b-256 | febe1b33ca3ecccfa7b7de950921978c523149b0cda65e6efce766bb04bd29c1 |