-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ca9409e
Showing
25 changed files
with
33,047 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
graft c_src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# PyLibClang | ||
|
||
PyLibClang is a comprehensive Python binding for [libclang](https://clang.llvm.org/docs/LibClang.html). | ||
|
||
It distinguishes itself from the official [clang python bindings](https://libclang.readthedocs.io/en/latest/) 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](https://pypi.org/project/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 | ||
```bash | ||
pip install pylibclang | ||
``` | ||
|
||
### From source | ||
|
||
Please note that compilation may be time-consuming due to the substantial volume of C++ code involved. | ||
|
||
```bash | ||
git clone https://gihub.com/edimetia3d/pylibclang | ||
cd pylibclang | ||
pip install . | ||
``` | ||
|
||
## Usage | ||
|
||
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: | ||
|
||
```python | ||
import pylibclang._C as libclang | ||
print(libclang.clang_getCString(libclang.clang_getClangVersion())) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#/!/bin/bash | ||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; | ||
cd $SCRIPT_DIR | ||
|
||
rm -rf ./wheelhouse | ||
PLAT=manylinux_2_28_x86_64 | ||
DOCKER_IMAGE="quay.io/pypa/${PLAT}" | ||
docker pull $DOCKER_IMAGE | ||
docker run --rm -i -e PLAT=${PLAT} -v `pwd`:/io $DOCKER_IMAGE /io/build_wheels.sh | ||
python3 -m pip install --upgrade build twine | ||
python3 -m build -o ./wheelhouse --sdist | ||
|
||
if [ "$1" = "upload" ]; | ||
then | ||
python3 -m twine upload wheelhouse/* | ||
else | ||
echo Uploading ignored | ||
fi | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
set -e -u -x | ||
|
||
function repair_wheel { | ||
wheel="$1" | ||
if ! auditwheel show "$wheel"; then | ||
echo "Skipping non-platform wheel $wheel" | ||
else | ||
auditwheel repair "$wheel" --plat "$PLAT" -w /io/wheelhouse/ | ||
fi | ||
} | ||
|
||
# Compile wheels | ||
rm -rf /io/wheelhouse/* | ||
mkdir -p /io/wheelhouse/ | ||
chmod 777 /io/wheelhouse | ||
cp -r /io ~/src | ||
rm -rf /opt/python/cp36* | ||
for PYBIN in /opt/python/cp*/bin; do | ||
"${PYBIN}/pip" install --upgrade build | ||
"${PYBIN}/python" -m build ~/src -o ~/src/wheelhouse/ -w | ||
done | ||
|
||
# Bundle external shared libraries into the wheels | ||
for whl in ~/src/wheelhouse/*.whl; do | ||
repair_wheel "$whl" | ||
done |
Oops, something went wrong.