diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 626f07a..ab964ec 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -8,7 +8,6 @@ on: jobs: build: - runs-on: ubuntu-latest strategy: matrix: @@ -34,6 +33,4 @@ jobs: - name: Type checks run: uv run mypy *.py --check-untyped-defs - name: Tests - run: | - PY_CPPMODEL_LIBCLANG_PATH=/usr/lib/llvm-18/lib/libclang-18.so.1 \ - uv run python -m unittest discover --verbose . + run: uv run python -m unittest discover --verbose . diff --git a/README.md b/README.md index 3887ce4..85a9eb9 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,6 @@ `py_cppmodel` is a Python wrapper around clang's python bindings to generate a simple Python model of a C++ translation unit. -## Limitations - -Currently the environment variable `PY_CPPMODEL_LIBCLANG_PATH` must be defined -to specify where libclang can be found. This may be fixed in the future. - ## Development To set up the development environment, execute the following commands: @@ -30,7 +25,7 @@ uv sync To run the tests, run: ```sh -./test.macos.sh +uv run python -m unittest discover --verbose . ``` To run type checking: diff --git a/Sandbox.ipynb b/Sandbox.ipynb index bbc9f13..56f0ffb 100644 --- a/Sandbox.ipynb +++ b/Sandbox.ipynb @@ -32,21 +32,6 @@ "tags": [] }, "outputs": [], - "source": [ - "# TODO: Change this for your OS-dependent or locally-built libclang path.\n", - "clang.cindex.Config.set_library_file(\n", - " \"/Library/Developer/CommandLineTools/usr/lib/libclang.dylib\"\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "3", - "metadata": { - "tags": [] - }, - "outputs": [], "source": [ "COMPILER_ARGS = [\n", " \"-x\",\n", @@ -60,7 +45,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4", + "id": "3", "metadata": { "tags": [] }, @@ -81,7 +66,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5", + "id": "4", "metadata": { "tags": [] }, @@ -93,7 +78,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6", + "id": "5", "metadata": {}, "outputs": [], "source": [] diff --git a/pyproject.toml b/pyproject.toml index 80e745d..4bc20cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,7 @@ license = { file = "LICENSE" } authors = [{ name = "J.B. Coe", email = "jonathanbcoe@gmail.com" }] dependencies = [ "clang>=14.0", + "libclang>=18.1.1", ] [project.urls] diff --git a/test.macos.sh b/test.macos.sh index 576aeaf..64489aa 100755 --- a/test.macos.sh +++ b/test.macos.sh @@ -7,5 +7,4 @@ uv sync uv run mypy *.py --check-untyped-defs # Unit tests -PY_CPPMODEL_LIBCLANG_PATH=/Library/Developer/CommandLineTools/usr/lib/libclang.dylib \ uv run python -m unittest discover --verbose . diff --git a/test_parse_standard_library_includes.py b/test_parse_standard_library_includes.py index ef600de..6faad31 100644 --- a/test_parse_standard_library_includes.py +++ b/test_parse_standard_library_includes.py @@ -6,12 +6,6 @@ from ctypes.util import find_library -LIBCLANG_PATH = os.environ.get("PY_CPPMODEL_LIBCLANG_PATH") -if not LIBCLANG_PATH: - raise RuntimeError("PY_CPPMODEL_LIBCLANG_PATH is unset") - -clang.cindex.Config.set_library_file(LIBCLANG_PATH) # type: ignore - from clang.cindex import TranslationUnit COMPILER_ARGS = [ diff --git a/test_py_cppmodel.py b/test_py_cppmodel.py index 785cdbd..d623353 100644 --- a/test_py_cppmodel.py +++ b/test_py_cppmodel.py @@ -3,12 +3,6 @@ import py_cppmodel import unittest -LIBCLANG_PATH = os.environ.get("PY_CPPMODEL_LIBCLANG_PATH") -if not LIBCLANG_PATH: - raise RuntimeError("PY_CPPMODEL_LIBCLANG_PATH is unset") - -clang.cindex.Config.set_library_file(LIBCLANG_PATH) # type: ignore - from clang.cindex import TranslationUnit COMPILER_ARGS = [ diff --git a/uv.lock b/uv.lock index 622fadd..4282f53 100644 --- a/uv.lock +++ b/uv.lock @@ -946,6 +946,23 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/82/3d/14ce75ef66813643812f3093ab17e46d3a206942ce7376d31ec2d36229e7/lark-1.3.1-py3-none-any.whl", hash = "sha256:c629b661023a014c37da873b4ff58a817398d12635d3bbb2c5a03be7fe5d1e12", size = 113151, upload-time = "2025-10-27T18:25:54.882Z" }, ] +[[package]] +name = "libclang" +version = "18.1.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6e/5c/ca35e19a4f142adffa27e3d652196b7362fa612243e2b916845d801454fc/libclang-18.1.1.tar.gz", hash = "sha256:a1214966d08d73d971287fc3ead8dfaf82eb07fb197680d8b3859dbbbbf78250", size = 39612, upload-time = "2024-03-17T16:04:37.434Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4b/49/f5e3e7e1419872b69f6f5e82ba56e33955a74bd537d8a1f5f1eff2f3668a/libclang-18.1.1-1-py2.py3-none-macosx_11_0_arm64.whl", hash = "sha256:0b2e143f0fac830156feb56f9231ff8338c20aecfe72b4ffe96f19e5a1dbb69a", size = 25836045, upload-time = "2024-06-30T17:40:31.646Z" }, + { url = "https://files.pythonhosted.org/packages/e2/e5/fc61bbded91a8830ccce94c5294ecd6e88e496cc85f6704bf350c0634b70/libclang-18.1.1-py2.py3-none-macosx_10_9_x86_64.whl", hash = "sha256:6f14c3f194704e5d09769108f03185fce7acaf1d1ae4bbb2f30a72c2400cb7c5", size = 26502641, upload-time = "2024-03-18T15:52:26.722Z" }, + { url = "https://files.pythonhosted.org/packages/db/ed/1df62b44db2583375f6a8a5e2ca5432bbdc3edb477942b9b7c848c720055/libclang-18.1.1-py2.py3-none-macosx_11_0_arm64.whl", hash = "sha256:83ce5045d101b669ac38e6da8e58765f12da2d3aafb3b9b98d88b286a60964d8", size = 26420207, upload-time = "2024-03-17T15:00:26.63Z" }, + { url = "https://files.pythonhosted.org/packages/1d/fc/716c1e62e512ef1c160e7984a73a5fc7df45166f2ff3f254e71c58076f7c/libclang-18.1.1-py2.py3-none-manylinux2010_x86_64.whl", hash = "sha256:c533091d8a3bbf7460a00cb6c1a71da93bffe148f172c7d03b1c31fbf8aa2a0b", size = 24515943, upload-time = "2024-03-17T16:03:45.942Z" }, + { url = "https://files.pythonhosted.org/packages/3c/3d/f0ac1150280d8d20d059608cf2d5ff61b7c3b7f7bcf9c0f425ab92df769a/libclang-18.1.1-py2.py3-none-manylinux2014_aarch64.whl", hash = "sha256:54dda940a4a0491a9d1532bf071ea3ef26e6dbaf03b5000ed94dd7174e8f9592", size = 23784972, upload-time = "2024-03-17T16:12:47.677Z" }, + { url = "https://files.pythonhosted.org/packages/fe/2f/d920822c2b1ce9326a4c78c0c2b4aa3fde610c7ee9f631b600acb5376c26/libclang-18.1.1-py2.py3-none-manylinux2014_armv7l.whl", hash = "sha256:cf4a99b05376513717ab5d82a0db832c56ccea4fd61a69dbb7bccf2dfb207dbe", size = 20259606, upload-time = "2024-03-17T16:17:42.437Z" }, + { url = "https://files.pythonhosted.org/packages/2d/c2/de1db8c6d413597076a4259cea409b83459b2db997c003578affdd32bf66/libclang-18.1.1-py2.py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:69f8eb8f65c279e765ffd28aaa7e9e364c776c17618af8bff22a8df58677ff4f", size = 24921494, upload-time = "2024-03-17T16:14:20.132Z" }, + { url = "https://files.pythonhosted.org/packages/0b/2d/3f480b1e1d31eb3d6de5e3ef641954e5c67430d5ac93b7fa7e07589576c7/libclang-18.1.1-py2.py3-none-win_amd64.whl", hash = "sha256:4dd2d3b82fab35e2bf9ca717d7b63ac990a3519c7e312f19fa8e86dcc712f7fb", size = 26415083, upload-time = "2024-03-17T16:42:21.703Z" }, + { url = "https://files.pythonhosted.org/packages/71/cf/e01dc4cc79779cd82d77888a88ae2fa424d93b445ad4f6c02bfc18335b70/libclang-18.1.1-py2.py3-none-win_arm64.whl", hash = "sha256:3f0e1f49f04d3cd198985fea0511576b0aee16f9ff0e0f0cad7f9c57ec3c20e8", size = 22361112, upload-time = "2024-03-17T16:42:59.565Z" }, +] + [[package]] name = "librt" version = "0.7.8" @@ -1448,6 +1465,7 @@ version = "0.0.1" source = { editable = "." } dependencies = [ { name = "clang" }, + { name = "libclang" }, ] [package.dev-dependencies] @@ -1461,7 +1479,10 @@ dev = [ ] [package.metadata] -requires-dist = [{ name = "clang", specifier = ">=14.0" }] +requires-dist = [ + { name = "clang", specifier = ">=14.0" }, + { name = "libclang", specifier = ">=18.1.1" }, +] [package.metadata.requires-dev] dev = [