From 68a4db02da2ef156c33769afe10eaec390a3ab77 Mon Sep 17 00:00:00 2001 From: Kwabena N Amponsah Date: Wed, 13 Nov 2024 12:40:45 +0000 Subject: [PATCH 1/5] #12 Stabilise class sorting --- cppwg/info/module_info.py | 4 +--- cppwg/writers/module_writer.py | 8 ++++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cppwg/info/module_info.py b/cppwg/info/module_info.py index 552ac28..7b0d6a3 100644 --- a/cppwg/info/module_info.py +++ b/cppwg/info/module_info.py @@ -173,9 +173,7 @@ def compare(a: CppClassInfo, b: CppClassInfo) -> int: cache[(b, a)] = 0 return 0 - self.class_collection.sort( - key=lambda x: (os.path.dirname(x.source_file_path), x.name) - ) + self.class_collection.sort(key=lambda x: x.name) i = 0 n = len(self.class_collection) diff --git a/cppwg/writers/module_writer.py b/cppwg/writers/module_writer.py index 0edb345..50fca41 100644 --- a/cppwg/writers/module_writer.py +++ b/cppwg/writers/module_writer.py @@ -62,10 +62,14 @@ def write_module_wrapper(self) -> None: Example output: ``` - #include #include "Foo.cppwg.hpp" + #include + #include "Foo.cppwg.hpp" + #include "Bar.cppwg.hpp" - PYBIND11_MODULE(_packagename_modulename, m) { + PYBIND11_MODULE(_packagename_modulename, m) + { register_Foo_class(m); + register_Bar_class(m); } ``` """ From 6994fbd96903a24f1a213de978431743ab2431db Mon Sep 17 00:00:00 2001 From: Kwabena N Amponsah Date: Wed, 13 Nov 2024 12:45:50 +0000 Subject: [PATCH 2/5] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index be70715..697dfd6 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,6 @@ r = Rectangle(4, 5) ## Tips -- Use `examples/shapes` as a starting point. -- See the [pybind11 docs](https://pybind11.readthedocs.io/) for help on pybind11 +- Use `examples/shapes` or `examples/cells` as a starting point. +- See the [pybind11 documentation](https://pybind11.readthedocs.io/) for help on pybind11 wrapper code. From 6253c1180fc5d9475d7260060c377641198e1e19 Mon Sep 17 00:00:00 2001 From: Kwabena N Amponsah Date: Wed, 13 Nov 2024 12:46:19 +0000 Subject: [PATCH 3/5] Update version --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 4bafa3a..2022a7a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = cppwg -version = 0.3.1 +version = 0.3.3 author = Chaste Developers author_email = chaste-users@maillist.ox.ac.uk description = An automatic Python wrapper generator for C++ code From c3ff48d1ed412d7aa49b5c9368a8c772ef6d2441 Mon Sep 17 00:00:00 2001 From: Kwabena N Amponsah Date: Wed, 13 Nov 2024 12:51:27 +0000 Subject: [PATCH 4/5] #12 Apply stable sort to cells example --- .../cells/dynamic/wrappers/all/_pycells_all.main.cppwg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/cells/dynamic/wrappers/all/_pycells_all.main.cppwg.cpp b/examples/cells/dynamic/wrappers/all/_pycells_all.main.cppwg.cpp index 0bcd915..c504ec2 100644 --- a/examples/cells/dynamic/wrappers/all/_pycells_all.main.cppwg.cpp +++ b/examples/cells/dynamic/wrappers/all/_pycells_all.main.cppwg.cpp @@ -6,11 +6,11 @@ #include "Node_3.cppwg.hpp" #include "AbstractMesh_2_2.cppwg.hpp" #include "AbstractMesh_3_3.cppwg.hpp" +#include "PetscUtils.cppwg.hpp" #include "PottsMesh_2.cppwg.hpp" #include "PottsMesh_3.cppwg.hpp" #include "MeshFactory_PottsMesh_2.cppwg.hpp" #include "MeshFactory_PottsMesh_3.cppwg.hpp" -#include "PetscUtils.cppwg.hpp" #include "Scene_2.cppwg.hpp" #include "Scene_3.cppwg.hpp" @@ -23,11 +23,11 @@ PYBIND11_MODULE(_pycells_all, m) register_Node_3_class(m); register_AbstractMesh_2_2_class(m); register_AbstractMesh_3_3_class(m); + register_PetscUtils_class(m); register_PottsMesh_2_class(m); register_PottsMesh_3_class(m); register_MeshFactory_PottsMesh_2_class(m); register_MeshFactory_PottsMesh_3_class(m); - register_PetscUtils_class(m); register_Scene_2_class(m); register_Scene_3_class(m); } From b1ec7522b1c26d7dc2d70b62a141bb6916002a7c Mon Sep 17 00:00:00 2001 From: Kwabena N Amponsah Date: Wed, 13 Nov 2024 12:53:34 +0000 Subject: [PATCH 5/5] #12 Fix linting --- cppwg/info/module_info.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cppwg/info/module_info.py b/cppwg/info/module_info.py index 7b0d6a3..5596ac5 100644 --- a/cppwg/info/module_info.py +++ b/cppwg/info/module_info.py @@ -1,6 +1,5 @@ """Module information structure.""" -import os from pathlib import Path from typing import Any, Dict, List, Optional