Feature/adr 003 pybind11#24
Conversation
| while explicitly having reduced compatibility with `std` and third party modules. | ||
| It is not header-only and requires linking to a shared or static library. | ||
|
|
||
| [ ] Listed all seriously considered alternatives |
There was a problem hiding this comment.
would we consider Cython an Option here? Some of our cpp2python interfaces are built with it (eckit, mir)
|
+1, for adoption of pybind11. As a matter of fact, I've spent a couple of afternoons and converted ecflow's python extension from Boost.python to pybind11 (the result is still in a local branch, since the CI runners don't have pybind11). The result is quite admirable, and the support for std type allowed to simplify parts of the existing implementation. |
7c419b4 to
6141180
Compare
6141180 to
fad5245
Compare
| * call C functions: python code can now call C functions and manipulate C data | ||
| structures as if they were native Python objects | ||
|
|
||
| Using CFFI usally requires to write a certain amount of wrapping code to hide |
There was a problem hiding this comment.
I would go beyond this. It typically requires a 2-layer python interface.
One layer that uses the C-interface, and one layer on top to make it more pythonic.
| ## Decision | ||
|
|
||
| The decision is to use Pybind11 for C++ bindings (see [analysis](#analysis)). | ||
| Developers should follow the [design guidline](#design-guidlines). |
There was a problem hiding this comment.
Where we do not need/envisage fortran bindings.
15a19f8 to
79a8854
Compare
oiffrig
left a comment
There was a problem hiding this comment.
While I understand and share the enthusiasm around PyBind11, I am not sure I am convinced it is a better alternative than Cython.
| to call C functions and use C data types. With CFFI it is possible to | ||
|
|
||
| * Extract C declarations from your to-be-wrapped API, note that this is a | ||
| preprocessing step because CFFI cannot parse C or C++ header files. |
There was a problem hiding this comment.
Not true. CFFI does pars C header files. But is quite restricted on what it can parse.
| [here](https://pybind11.readthedocs.io/en/stable/advanced/cast/overview.html#conversion-table). | ||
| * Allows exchanging wrapped types across bindings, see [module local | ||
| bindings](https://pybind11.readthedocs.io/en/stable/advanced/classes.html#module-local-class-bindings) | ||
| * Allows setting call policies that affect object lifetimes. These policies allow to |
There was a problem hiding this comment.
"These policies enable the definition of dependencies ..." or similar. "allow to" is bad English.
simondsmart
left a comment
There was a problem hiding this comment.
Looking good. I'm happy.
c00f23f to
09c914a
Compare
tlmquintino
left a comment
There was a problem hiding this comment.
minor comments. needs a References section.
| ## Status | ||
|
|
||
| [**Proposed** | <s>Accepted</s> | <s>Deprecated</s> | <s>Superseded by [ADR-XXX]</s>] | ||
|
|
There was a problem hiding this comment.
Remember to change to Accepted before merging.
| [bindings](https://github.com/ecmwf/multio/blob/feature/multiom-cpp-python/src/pymars2grib_bindings/pymars2grib_bindings.cc), | ||
| [python | ||
| wrapper)(https://github.com/ecmwf/multio/tree/feature/multiom-cpp-python/src/pymars2grib) | ||
|
|
There was a problem hiding this comment.
there is a References section missing (see template).
I would suggest to add references to other similar discussions that you may or not have used, e.g:
45edae9 to
61659a8
Compare
| * Automatically translates C++ exceptions to matching Python exceptions, see | ||
| [details](https://pybind11.readthedocs.io/en/stable/advanced/exceptions.html). | ||
| This includes the ability to register custom type conversions that map domain specific | ||
| exceptions, e.g. `eckit::Exception` to `eckit.Excpeption`. |
There was a problem hiding this comment.
| exceptions, e.g. `eckit::Exception` to `eckit.Excpeption`. | |
| exceptions, e.g. `eckit::Exception` to `eckit.Exception`. |
Co-authored-by: Kai Kratz <kai.kratz@ecmwf.int> Co-authored-by: Tobias Kremer <tobias.kremer@ecmwf.int>
61659a8 to
974f1ee
Compare
Description
Contributor Declaration
By opening this pull request, I affirm the following: