Skip to content

feat: Update Python bindings for CFD C library v0.2.0#27

Merged
shaia merged 6 commits intomasterfrom
feat/v0.2.0-python-bindings
Mar 5, 2026
Merged

feat: Update Python bindings for CFD C library v0.2.0#27
shaia merged 6 commits intomasterfrom
feat/v0.2.0-python-bindings

Conversation

@shaia
Copy link
Copy Markdown
Owner

@shaia shaia commented Mar 5, 2026

Add bindings for all new v0.2.0 APIs: library lifecycle (init/finalize), version info, Poisson solver (6 functions + 22 constants), GPU device management (4 functions), logging callbacks, new boundary condition types (BC_TYPE_SYMMETRY, 3D edges), new status codes, and 3D grid/VTK support. Complete type stubs in init.pyi for all 51 bound functions and ~65 exported constants. Add CFDLimitExceededError and CFDNotFoundError exception classes.

Add bindings for all new v0.2.0 APIs: library lifecycle (init/finalize),
version info, Poisson solver (6 functions + 22 constants), GPU device
management (4 functions), logging callbacks, new boundary condition
types (BC_TYPE_SYMMETRY, 3D edges), new status codes, and 3D grid/VTK
support. Complete type stubs in __init__.pyi for all 51 bound functions
and ~65 exported constants. Add CFDLimitExceededError and
CFDNotFoundError exception classes.
@shaia shaia requested a review from Copilot March 5, 2026 09:44
@shaia shaia self-assigned this Mar 5, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Python package bindings to align with the CFD C library v0.2.0 API surface (new lifecycle/version APIs, Poisson + GPU helpers, logging callback support, new constants/status codes, and 3D/VTI/VTK-related updates).

Changes:

  • Extend the C extension (src/cfd_python.c) with v0.2.0 APIs (init/finalize/version, Poisson backend helpers, GPU device/config helpers, logging callback) and 3D-aware grid/VTK plumbing.
  • Simplify extension loading by auto-discovering public symbols via dir() in cfd_python/_loader.py.
  • Add new Python exception types and expand type stubs/constants for v0.2.0 in cfd_python/_exceptions.py, cfd_python/__init__.py, and cfd_python/__init__.pyi.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/cfd_python.c Adds v0.2.0 bindings (lifecycle/version, Poisson, GPU, logging) and updates grid/VTK helpers for 3D parameters/constants.
cfd_python/_loader.py Replaces curated export list with automatic discovery of public C-extension symbols; separates dynamic SOLVER_* constants.
cfd_python/_exceptions.py Introduces new exception classes and maps new status codes to exceptions.
cfd_python/__init__.pyi Expands type stubs for new v0.2.0 functions/constants and 3D-capable signatures.
cfd_python/__init__.py Updates docs and exported symbol list (__all__) for new v0.2.0 APIs/constants/exceptions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

shaia added 5 commits March 5, 2026 12:01
The Python bindings now target v0.2.0 APIs (3D grid, Poisson solver,
GPU management, logging) which don't exist in v0.1.6 headers.
Manual PyTuple construction didn't check PyLong_FromLong/
PyUnicode_FromString return values, risking segfault on allocation
failure. PyObject_CallFunction handles this internally and also
guards against NULL message pointers.
Without cleanup, the Python callback object leaks for the
interpreter lifetime. Add cfd_python_free to unregister the
C callback and release the Python reference.
…lues

Hardcoded 0x10/0x20 could drift if the C library changes the enum.
Use BC_EDGE_FRONT/BC_EDGE_BACK from boundary_conditions.h directly.
This constant doesn't exist in the v0.2.0 C extension (it was added
post-tag). Including it in exports breaks `from cfd_python import *`.
@shaia shaia merged commit 88408f1 into master Mar 5, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants