--- description: Update Python bindings when Rust source changes --- # Update Python Bindings This workflow automates the process of updating the PyO3 Python bindings when the underlying Rust core (`crates/components`, `crates/solver`, etc.) changes. Since the Python bindings use local Cargo workspace dependencies, changes to the Rust core structure (like adding a new struct field to a Component, or changing a method signature) will cause the Python wrapper to fail compilation until the wrapper's `#[pyclass]` and `#[pymethods]` are updated to match. Follow these steps to migrate and recompile the bindings: 1. **Identify Rust Core Changes:** Review the recent Git history or modifications in the `crates/` directory to identify what component structs, enums, or functions have changed their public API. 2. **Update PyO3 Wrappers:** Modify the corresponding wrapper classes in `bindings/python/src/` (e.g., `components.rs`, `solver.rs`, `types.rs`) to reflect the new API. - Adjust `#[pyclass]` fields and `#[new]` constructors if struct definitions changed. - Update `#[pymethods]` if function signatures or return types changed. 3. **Register New Types:** If new components or types were added to the core, create new wrappers for them and register them in the `#[pymodule]` definition in `bindings/python/src/lib.rs`. // turbo-all 4. **Recompile Bindings:** Run the MATURIN build process. ```bash cd bindings/python source .venv/bin/activate maturin develop --release ``` 5. **Run Tests:** Execute the Python test suite to ensure the bindings still work correctly and the API behavior is intact. ```bash cd bindings/python source .venv/bin/activate pytest tests/ -v ``` 6. **Fix Errors:** If there are any Rust compilation errors (due to mismatched types) or Python test failures, fix them iteratively.