From 2bd25e9469aa11648c4bb4a82db2beeeac108fb1 Mon Sep 17 00:00:00 2001 From: MaxBetz <104758467+MaxBetzDLR@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:17:21 +0000 Subject: [PATCH 1/7] update clang version --- pycode/memilio-generation/memilio/generation/ast.py | 2 +- pycode/memilio-generation/pyproject.toml | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pycode/memilio-generation/memilio/generation/ast.py b/pycode/memilio-generation/memilio/generation/ast.py index 0bae4cb309..6858988c65 100644 --- a/pycode/memilio-generation/memilio/generation/ast.py +++ b/pycode/memilio-generation/memilio/generation/ast.py @@ -84,7 +84,7 @@ def create_ast(self: Self) -> TranslationUnit: file_args = file_args[1:-4] clang_cmd = [ - "clang-18", self.config.source_file, + "clang-21", self.config.source_file, "-std=c++20", '-emit-ast', '-o', '-'] clang_cmd.extend(file_args) diff --git a/pycode/memilio-generation/pyproject.toml b/pycode/memilio-generation/pyproject.toml index 372fe4bc2b..be42958ade 100644 --- a/pycode/memilio-generation/pyproject.toml +++ b/pycode/memilio-generation/pyproject.toml @@ -28,7 +28,7 @@ dependencies = [ [project.optional-dependencies] bindings = [ - "libclang==18.1.1", + "libclang-ng==21.1.8.2", ] dev = [] @@ -43,10 +43,3 @@ memilio-modelgenerator = "memilio.modelgenerator.cli:main" cmake.version = ">=3.13" wheel.packages = ["memilio"] build-dir = "../build/memilio-generation" - -[tool.setuptools] -include-package-data = true - -[tool.setuptools.package-data] -"memilio.generation" = ["generation/*.json", "generation/*.txt", "generation/README.md"] -"memilio.modelgenerator" = ["templates/*.jinja2"] From 311bd2eed51afeacdfb84514ac95ee1bf6226a9a Mon Sep 17 00:00:00 2001 From: MaxBetz <104758467+MaxBetzDLR@users.noreply.github.com> Date: Thu, 26 Nov 2026 11:52:18 +0000 Subject: [PATCH 2/7] missing clang update --- pycode/memilio-generation/memilio/generation/utility.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycode/memilio-generation/memilio/generation/utility.py b/pycode/memilio-generation/memilio/generation/utility.py index e925297b42..6451d91e2b 100644 --- a/pycode/memilio-generation/memilio/generation/utility.py +++ b/pycode/memilio-generation/memilio/generation/utility.py @@ -43,7 +43,7 @@ def try_set_libclang_path(path: str) -> None: """ # Check if path was set in config. If not, try to get it with cmd. if (not path or path == 'LIBCLANG_PATH-NOTFOUND'): - clang_cmd = ["clang-18", '-print-file-name='] + clang_cmd = ["clang-21", '-print-file-name='] clang_cmd_result = subprocess.check_output(clang_cmd) path, dirname = os.path.split(clang_cmd_result) while ("llvm" not in str(dirname)): From 11bda399d3c8ac69e80d70bfd6f874845bb2c175 Mon Sep 17 00:00:00 2001 From: MaxBetz <104758467+MaxBetzDLR@users.noreply.github.com> Date: Thu, 3 Dec 2026 09:22:58 +0000 Subject: [PATCH 3/7] update clang in CI action --- .github/actions/test-py/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/test-py/action.yml b/.github/actions/test-py/action.yml index ef71c636cc..69d97cc508 100644 --- a/.github/actions/test-py/action.yml +++ b/.github/actions/test-py/action.yml @@ -20,7 +20,7 @@ runs: run: | sudo apt-get -qq update if [[ "${{ inputs.package }}" == "generation" ]]; then - sudo apt-get -qq -y install python3-pip gnupg clang-18 libclang-18-dev cmake + sudo apt-get -qq -y install python3-pip gnupg clang-21 libclang-21-dev cmake else sudo apt-get -qq -y install python3-pip gnupg fi From 5b9aa9df6c755402894f3ea78a4ae660d3ad36c1 Mon Sep 17 00:00:00 2001 From: MaxBetz <104758467+MaxBetzDLR@users.noreply.github.com> Date: Thu, 3 Dec 2026 09:28:22 +0000 Subject: [PATCH 4/7] Remove temporary fix from ast --- pycode/memilio-generation/memilio/generation/ast.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pycode/memilio-generation/memilio/generation/ast.py b/pycode/memilio-generation/memilio/generation/ast.py index 6858988c65..6e204093c5 100644 --- a/pycode/memilio-generation/memilio/generation/ast.py +++ b/pycode/memilio-generation/memilio/generation/ast.py @@ -29,11 +29,6 @@ from typing import TYPE_CHECKING from memilio.generation import utility -# libstdc++ of gcc >= 15 uses the flag_enum attribute, which is unknown to the python bindings of libclang 18 -try: - CursorKind.from_id(437) -except ValueError: - CursorKind.FLAG_ENUM = CursorKind(437) if TYPE_CHECKING: from memilio.generation import ScannerConfig From a8390af3fc939d9e74edaf91f7c52b0fda6ef3fd Mon Sep 17 00:00:00 2001 From: MaxBetz <104758467+MaxBetzDLR@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:35:46 +0000 Subject: [PATCH 5/7] change to python clang library --- pycode/memilio-generation/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycode/memilio-generation/pyproject.toml b/pycode/memilio-generation/pyproject.toml index be42958ade..18cdeee632 100644 --- a/pycode/memilio-generation/pyproject.toml +++ b/pycode/memilio-generation/pyproject.toml @@ -28,7 +28,7 @@ dependencies = [ [project.optional-dependencies] bindings = [ - "libclang-ng==21.1.8.2", + "clang==21.*", ] dev = [] From 1c2dca4d1975428fe541e141250ad8b15903cda0 Mon Sep 17 00:00:00 2001 From: MaxBetz <104758467+MaxBetzDLR@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:46:28 +0000 Subject: [PATCH 6/7] update CI --- .github/actions/test-py/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/test-py/action.yml b/.github/actions/test-py/action.yml index 69d97cc508..4c5c99f4a6 100644 --- a/.github/actions/test-py/action.yml +++ b/.github/actions/test-py/action.yml @@ -20,7 +20,7 @@ runs: run: | sudo apt-get -qq update if [[ "${{ inputs.package }}" == "generation" ]]; then - sudo apt-get -qq -y install python3-pip gnupg clang-21 libclang-21-dev cmake + sudo apt-get -qq -y install python3-pip gnupg clang-21 libclang1-21 libclang-21-dev cmake else sudo apt-get -qq -y install python3-pip gnupg fi From 917850a9214256b7949d5d9e539a85aab97764d1 Mon Sep 17 00:00:00 2001 From: MaxBetz <104758467+MaxBetzDLR@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:51:05 +0000 Subject: [PATCH 7/7] Update docs --- docs/source/python/m-bindingsgenerator.rst | 4 ++-- docs/source/python/m-generation.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/python/m-bindingsgenerator.rst b/docs/source/python/m-bindingsgenerator.rst index e61aa0c78e..0cea0ec4a2 100644 --- a/docs/source/python/m-bindingsgenerator.rst +++ b/docs/source/python/m-bindingsgenerator.rst @@ -33,9 +33,9 @@ Required Python packages: For a successful build, the development libraries for Python need to be installed, i.e. python3.x-dev. .. warning:: - Generation currently requires specifically version ``18.1.1`` of `libclang.so`, since the function ``create_ast`` in `ast.py `_ generates the abstract syntax tree using `clang-18`. Different versions may lead to unsupported abstractions. + Generation currently requires specifically version ``21`` of `libclang.so`, since the function ``create_ast`` in `ast.py `_ generates the abstract syntax tree using `clang-21`. Different versions may lead to unsupported abstractions. - If you want to try a different version, set your `libclang` version under ``dependencies`` in the `pyproject.toml `_ and change the clang command in ``create_ast`` in `ast.py `_. + If you want to try a different version, set your `clang` version under ``dependencies`` in the `pyproject.toml `_ and change the clang command in ``create_ast`` in `ast.py `_. For installation, see the :doc:`MEmilio Generation ` page. diff --git a/docs/source/python/m-generation.rst b/docs/source/python/m-generation.rst index be0bf60637..59217bbca4 100644 --- a/docs/source/python/m-generation.rst +++ b/docs/source/python/m-generation.rst @@ -21,11 +21,11 @@ Installation # Model Generator only (no libclang required) python -m pip install -e pycode/memilio-generation - # Model Generator + Bindings Generator (installs libclang) + # Model Generator + Bindings Generator (installs python clang) python -m pip install -e "pycode/memilio-generation[bindings]" The Model Generator only requires ``jinja2``, ``pyyaml``, and (on Python < 3.11) ``tomli``. -The Bindings Generator additionally needs ``libclang==18.1.1`` and the +The Bindings Generator additionally needs the python package ``clang==21.*`` and the ``python3.x-dev`` system libraries (see :doc:`m-bindingsgenerator` for details). For the general installation guide, see :ref:`python-package-installation`.