Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interoperability with legacy SWIG bindings #1706

Closed
kurt-skewton opened this issue Feb 22, 2019 · 2 comments
Closed

Interoperability with legacy SWIG bindings #1706

kurt-skewton opened this issue Feb 22, 2019 · 2 comments

Comments

@kurt-skewton
Copy link

Hi,

not an issue per se, but a question.

What are the possibilities for having two sets of bindings based on pybind11 and SWIG interoperate? I have a use for a library with existing SWIG bindings, which I would like to extend preferably with pybind11 bindings. I would thus like to be able to pass around SWIG and pybind11 objects both ways.

Is there any scope at all for doing this or this is a deal breaker and a total migration towards pybind11 is required?

Thanks,
Kurt

@eacousineau
Copy link
Contributor

It depends on what CPython internals SWIG is able to expose.

As an example, you can look at projects that have interop with other bindings, like VTK and its Python binding layer (using its rich object model to handle stuff):
https://stackoverflow.com/questions/54871216/pybind11-return-c-class-with-an-existing-python-binding-to-python

Specifically, you'd need something like these type casters:
https://github.com/EricCousineau-TRI/repro/blob/b9e02d6d5a71f6315b80759ba1628b4bb383c0b8/python/vtk_pybind/vtk_pybind.h#L20

Another example are OpenCV + pybind interop. Some examples / discussions:
#538
https://github.com/edmBernard/pybind11_opencv_numpy

@bstaletic
Copy link
Collaborator

Considering there was no follow up, I'm closing this. Reopen if necessary.

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

No branches or pull requests

3 participants