Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/test-py/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/source/python/m-bindingsgenerator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-generation/memilio/generation/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 <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-generation/memilio/generation/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 <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-generation/pyproject.toml>`_ and change the clang command in ``create_ast`` in `ast.py <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-generation/memilio/generation/ast.py>`_.
If you want to try a different version, set your `clang` version under ``dependencies`` in the `pyproject.toml <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-generation/pyproject.toml>`_ and change the clang command in ``create_ast`` in `ast.py <https://github.com/SciCompMod/memilio/blob/main/pycode/memilio-generation/memilio/generation/ast.py>`_.

For installation, see the :doc:`MEmilio Generation <m-generation>` page.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/python/m-generation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
7 changes: 1 addition & 6 deletions pycode/memilio-generation/memilio/generation/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pycode/memilio-generation/memilio/generation/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
9 changes: 1 addition & 8 deletions pycode/memilio-generation/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies = [

[project.optional-dependencies]
bindings = [
"libclang==18.1.1",
"clang==21.*",
]
dev = []

Expand All @@ -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"]
Loading