You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-7
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,25 @@
2
2
3
3
PyLibClang is a comprehensive Python binding for [libclang](https://clang.llvm.org/docs/LibClang.html).
4
4
5
-
It distinguishes itself from the official [clang python bindings](https://libclang.readthedocs.io/en/latest/) in the following ways:
6
-
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.
7
-
2. The binding is automatically generated from libclang header files using [pybind11-weaver](https://pypi.org/project/pybind11-weaver/), simplifying the process of remaining current with the latest libclang.
5
+
It distinguishes itself from the official [clang python bindings](https://libclang.readthedocs.io/en/latest/) in the
6
+
following ways:
7
+
8
+
1. It is a comprehensive binding, meaning it brings all libclang APIs into the Python environment. Conversely, the
9
+
official binding only exposes a subset of the APIs.
10
+
2. The binding is automatically generated from libclang header files
11
+
using [pybind11-weaver](https://pypi.org/project/pybind11-weaver/), simplifying the process of remaining current with
12
+
the latest libclang.
8
13
3. It is exported from C++, thereby facilitating faster performance than the official binding.
9
14
4. It is directly accessible from PYPI.
10
15
11
16
## Installation
12
17
13
18
At present, only Linux builds have been tested.
14
-
Windows/MacOS users may need to install from source and potentially modify some compilation flags in `setup.py` to enable successful compilation.
19
+
Windows/MacOS users may need to install from source and potentially modify some compilation flags in `setup.py` to
20
+
enable successful compilation.
15
21
16
22
### From PYPI
23
+
17
24
```bash
18
25
pip install pylibclang
19
26
```
@@ -30,9 +37,38 @@ pip install .
30
37
31
38
## Usage
32
39
33
-
As no wrapper exists yet, the raw C API from the `pylibclang._C` module must be used directly, and every C-API is accessible from it. For instance, to obtain the version of libclang:
40
+
### Regarding the Version Number
41
+
42
+
The version number adopts the format of `{pylibclang_ver}{clang_ver}`, wherein `pylibclang_ver` is an integer
43
+
and `clang_ver` represents the version of the underlying libclang. For example, `9817.0.3` indicates that the version of
44
+
pylibclang is `98`, and the version of libclang is `17.0.3`.
45
+
46
+
### Cindex
47
+
48
+
There is a `cindex.py`, ported from the official clang python
49
+
bindings, [`cindex.py`](https://github.com/llvm/llvm-project/blob/main/clang/bindings/python/clang/cindex.py), which
50
+
serves as a wrapper around the raw C API.
51
+
52
+
Though not thoroughly tested, it should suffice for most use cases and is recommended as the initial entry point to the
53
+
library.
54
+
55
+
Should you encounter any issues, please report them on Github, or attempt to rectify them yourself and submit a pull
56
+
request. Typically, there are two kinds of problems you might face:
57
+
58
+
1. Unresolved `cindex.py` code. In this case, updating the `cindex.py` may be necessary.
59
+
2. Incompatible C-API call. For instance, a function might require an `int *` as both input and output, but `cindex.py`
60
+
only passes an `int` as input. Owing to the constraints of Pybind11, this value will never be updated. In such cases,
61
+
adding a new binding code in `c_src/binding.cpp`, rebuilding the project, and then calling it from `cindex.py` may be
62
+
required.
63
+
64
+
### Raw C API
65
+
66
+
`pylibclang._C` is the pybind11 binding for all the C APIs in libclang. If anything is missing in `cindex.py`, the raw C
67
+
API can always be directly utilized. For instance, `cindex.py` does not expose `clang_getClangVersion`, but you can
0 commit comments