diff --git a/.github/actions/test-py/action.yml b/.github/actions/test-py/action.yml index ef71c636cc..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-18 libclang-18-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 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`. diff --git a/pycode/memilio-generation/memilio/generation/ast.py b/pycode/memilio-generation/memilio/generation/ast.py index 0bae4cb309..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 @@ -84,7 +79,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/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)): diff --git a/pycode/memilio-generation/pyproject.toml b/pycode/memilio-generation/pyproject.toml index 372fe4bc2b..18cdeee632 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", + "clang==21.*", ] 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"]