feat(solver): Phase 2 — pybind11 bindings and Python solver support #288

Closed
opened 2026-02-19 21:01:43 +00:00 by forbes · 0 comments
Owner

Summary

Expose the KCSolve C++ API to Python via pybind11, add pure-Python solver base class, and build the debug/introspection API.

Scope

Per INTER_SOLVER.md Phase 2:

pybind11 module (kcsolve)

  • Bind all core types: JointTypeId, JointDef, Constraint, SolveContext, SolveResult, etc.
  • kcsolve.available() — list loaded solvers
  • kcsolve.load(solver_id) — get solver instance
  • kcsolve.register(py_solver) — register a Python solver at runtime
  • Pythonic SolveContext builder: ctx.add_part(), ctx.add_constraint()

PySolver base class

  • Python solvers subclass kcsolve.PySolver
  • Must implement: id, name, version, supported_joints(), solve(ctx)
  • Discovered from mods/*/solvers/*.py and <user_macros>/solvers/*.py

Debug / introspection API

  • kcsolve.Debugger(solver, ctx) — step-through iteration with per-step residuals
  • kcsolve.dependency_graph(ctx) — constraint dependency visualization
  • kcsolve.dof_analysis(ctx) — DOF count per part and total

File locations

src/Lib/KCSolve/bindings/
├── kcsolve_py.cpp
└── CMakeLists.txt

Dependencies

  • #287 (Phase 1: C++ API must exist first)

References

  • docs/INTER_SOLVER.md §6
## Summary Expose the KCSolve C++ API to Python via pybind11, add pure-Python solver base class, and build the debug/introspection API. ## Scope Per INTER_SOLVER.md Phase 2: ### pybind11 module (`kcsolve`) - Bind all core types: JointTypeId, JointDef, Constraint, SolveContext, SolveResult, etc. - `kcsolve.available()` — list loaded solvers - `kcsolve.load(solver_id)` — get solver instance - `kcsolve.register(py_solver)` — register a Python solver at runtime - Pythonic SolveContext builder: `ctx.add_part()`, `ctx.add_constraint()` ### PySolver base class - Python solvers subclass `kcsolve.PySolver` - Must implement: `id`, `name`, `version`, `supported_joints()`, `solve(ctx)` - Discovered from `mods/*/solvers/*.py` and `<user_macros>/solvers/*.py` ### Debug / introspection API - `kcsolve.Debugger(solver, ctx)` — step-through iteration with per-step residuals - `kcsolve.dependency_graph(ctx)` — constraint dependency visualization - `kcsolve.dof_analysis(ctx)` — DOF count per part and total ### File locations ``` src/Lib/KCSolve/bindings/ ├── kcsolve_py.cpp └── CMakeLists.txt ``` ## Dependencies - #287 (Phase 1: C++ API must exist first) ## References - docs/INTER_SOLVER.md §6
forbes added the enhancement label 2026-02-19 21:01:43 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/create#288