Repository: ipc-sim/ipc-toolkit (language: python)

Issue:
Segfault on Python versions >=3.9
**Describe the bug**
CollisionMesh constructor segfaults on Python versions >=3.9.

**To Reproduce**
I used pyenv to get python versions 3.8.19 and 3.9.19 and ran the same test file (below) with both.  Python 3.8.19 raised no errors while 3.9.19 gave a segfault.

```python
from numpy import array
import ipctk

points = array([[-0.5, 0.5], [0.5, 0.5], [0.5, -0.5]])
edges = array([[0, 1], [1, 2], [2, 0]])
faces = array([[0, 1, 2]])

mesh = ipctk.CollisionMesh(points, edges, faces)
```

**Environment:**
 Tested on both Debian Sid and macOS Monterey 12.2.1 with both raising the same issue

**Additional context**
I haven't tested any other functions, but I assume that there might be other issues as well.


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml
index 17def9a66..af3092c93 100644
--- a/.github/workflows/clang-format-check.yml
+++ b/.github/workflows/clang-format-check.yml
@@ -1,6 +1,12 @@
 name: clang-format Check
 on:
   push:
+    paths:
+      - '.github/workflows/clang-format-check.yml'
+      - '.clang-format'
+      - 'src/**'
+      - 'tests/src/**'
+      - 'python/src/**'
   pull_request:
     paths:
       - '.github/workflows/clang-format-check.yml'
diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml
index ccf2c772e..a48fa4956 100644
--- a/.github/workflows/python.yml
+++ b/.github/workflows/python.yml
@@ -23,7 +23,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [ubuntu-latest, macos-latest, windows-latest]
-        python-version: ["3.10"]
+        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
         include:
           - os: ubuntu-latest
             name: Linux
@@ -65,8 +65,7 @@ jobs:
         uses: actions/cache@v3.0.11
         with:
           path: ${{ env.CACHE_PATH }}
-          key: ${{ runner.os }}-Python-cache
-          restore-keys: ${{ runner.os }}-Release-cache
+          key: ${{ runner.os }}-Python${{ matrix.python-version }}-cache
 
       - name: Prepare Ccache
         run: |
diff --git a/cmake/recipes/pybind11.cmake b/cmake/recipes/pybind11.cmake
index 747696283..6d9c46eaa 100644
--- a/cmake/recipes/pybind11.cmake
+++ b/cmake/recipes/pybind11.cmake
@@ -26,4 +26,4 @@ find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
 set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
 
 include(CPM)
-CPMAddPackage("gh:pybind/pybind11@2.11.1")
+CPMAddPackage("gh:pybind/pybind11@2.13.1")


Test patch:
diff --git a/python/tests/find_ipctk.py b/python/tests/find_ipctk.py
index bd87945a3..b3197cc04 100644
--- a/python/tests/find_ipctk.py
+++ b/python/tests/find_ipctk.py
@@ -11,9 +11,10 @@
         repo_root / "build" / "debug" / "python",
     ]
     for path in possible_paths:
-        if path.exists():
+        if path.exists() and len(list(path.glob("ipctk.*"))) > 0:
             sys.path.append(str(path))
             break
     else:
         raise ImportError("Could not find the ipctk module")
+    print(f"Using found ipctk module at {path}")
     import ipctk  # Try again
diff --git a/python/tests/test_ipc.py b/python/tests/test_ipc.py
index ea34bdce3..0f7388adf 100644
--- a/python/tests/test_ipc.py
+++ b/python/tests/test_ipc.py
@@ -30,7 +30,7 @@ def check_ipc_derivatives(broad_phase_method, use_convergent_formulation, mesh_n
     assert np.linalg.norm(grad_b) > 1e-8
     assert np.allclose(grad_b, fgrad_b)
 
-    hess_b = B.hessian(collisions, mesh, vertices).A
+    hess_b = B.hessian(collisions, mesh, vertices).toarray()
     fhess_b = utils.finite_jacobian(
         vertices.flatten(), lambda x: B.gradient(collisions, mesh, x.reshape(vertices.shape)))