Skip to content

Commit e74dc2b

Browse files
authored
Use libclang package from PyPI (#12)
closes #11
1 parent 8461dcf commit e74dc2b

File tree

8 files changed

+28
-42
lines changed

8 files changed

+28
-42
lines changed

.github/workflows/python.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312
strategy:
1413
matrix:
@@ -34,6 +33,4 @@ jobs:
3433
- name: Type checks
3534
run: uv run mypy *.py --check-untyped-defs
3635
- name: Tests
37-
run: |
38-
PY_CPPMODEL_LIBCLANG_PATH=/usr/lib/llvm-18/lib/libclang-18.so.1 \
39-
uv run python -m unittest discover --verbose .
36+
run: uv run python -m unittest discover --verbose .

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
`py_cppmodel` is a Python wrapper around clang's python bindings to generate a
1515
simple Python model of a C++ translation unit.
1616

17-
## Limitations
18-
19-
Currently the environment variable `PY_CPPMODEL_LIBCLANG_PATH` must be defined
20-
to specify where libclang can be found. This may be fixed in the future.
21-
2217
## Development
2318

2419
To set up the development environment, execute the following commands:
@@ -30,7 +25,7 @@ uv sync
3025
To run the tests, run:
3126

3227
```sh
33-
./test.macos.sh
28+
uv run python -m unittest discover --verbose .
3429
```
3530

3631
To run type checking:

Sandbox.ipynb

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,6 @@
3232
"tags": []
3333
},
3434
"outputs": [],
35-
"source": [
36-
"# TODO: Change this for your OS-dependent or locally-built libclang path.\n",
37-
"clang.cindex.Config.set_library_file(\n",
38-
" \"/Library/Developer/CommandLineTools/usr/lib/libclang.dylib\"\n",
39-
")"
40-
]
41-
},
42-
{
43-
"cell_type": "code",
44-
"execution_count": null,
45-
"id": "3",
46-
"metadata": {
47-
"tags": []
48-
},
49-
"outputs": [],
5035
"source": [
5136
"COMPILER_ARGS = [\n",
5237
" \"-x\",\n",
@@ -60,7 +45,7 @@
6045
{
6146
"cell_type": "code",
6247
"execution_count": null,
63-
"id": "4",
48+
"id": "3",
6449
"metadata": {
6550
"tags": []
6651
},
@@ -81,7 +66,7 @@
8166
{
8267
"cell_type": "code",
8368
"execution_count": null,
84-
"id": "5",
69+
"id": "4",
8570
"metadata": {
8671
"tags": []
8772
},
@@ -93,7 +78,7 @@
9378
{
9479
"cell_type": "code",
9580
"execution_count": null,
96-
"id": "6",
81+
"id": "5",
9782
"metadata": {},
9883
"outputs": [],
9984
"source": []

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ license = { file = "LICENSE" }
88
authors = [{ name = "J.B. Coe", email = "jonathanbcoe@gmail.com" }]
99
dependencies = [
1010
"clang>=14.0",
11+
"libclang>=18.1.1",
1112
]
1213

1314
[project.urls]

test.macos.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ uv sync
77
uv run mypy *.py --check-untyped-defs
88

99
# Unit tests
10-
PY_CPPMODEL_LIBCLANG_PATH=/Library/Developer/CommandLineTools/usr/lib/libclang.dylib \
1110
uv run python -m unittest discover --verbose .

test_parse_standard_library_includes.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77
from ctypes.util import find_library
88

9-
LIBCLANG_PATH = os.environ.get("PY_CPPMODEL_LIBCLANG_PATH")
10-
if not LIBCLANG_PATH:
11-
raise RuntimeError("PY_CPPMODEL_LIBCLANG_PATH is unset")
12-
13-
clang.cindex.Config.set_library_file(LIBCLANG_PATH) # type: ignore
14-
159
from clang.cindex import TranslationUnit
1610

1711
COMPILER_ARGS = [

test_py_cppmodel.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
import py_cppmodel
44
import unittest
55

6-
LIBCLANG_PATH = os.environ.get("PY_CPPMODEL_LIBCLANG_PATH")
7-
if not LIBCLANG_PATH:
8-
raise RuntimeError("PY_CPPMODEL_LIBCLANG_PATH is unset")
9-
10-
clang.cindex.Config.set_library_file(LIBCLANG_PATH) # type: ignore
11-
126
from clang.cindex import TranslationUnit
137

148
COMPILER_ARGS = [

uv.lock

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)