On Apr 13, 2020, at 5:25 AM, Paul Moore <p.f.moore@gmail.com> wrote:
On a related but different note, what is the recommended policy (assuming it's not to use the C API) for embedding Python, and for exposing the embedding app to Python as a C extension? My standard example of this is the Vim interface to Python - see https://github.com/vim/vim/blob/master/src/if_python3.c <https://github.com/vim/vim/blob/master/src/if_python3.c>. I originally wrote this back in the Python 1.5 days, so it's *very* old, and quite likely not how I'd write it now, even using the C API. But what's the recommendation for code like that in the face of these changes, and the suggestion that using 3rd party tools is the normal way to write C extensions?
I’d like to +1 this request for a standard for embedding Python while at the same time exposing the embedding app to Python as a C extension. We do something remarkably similar to Vim here (along with other files in the same directory). https://github.com/nion-software/nionui-tool/blob/master/launcher/PythonStub... <https://github.com/nion-software/nionui-tool/blob/master/launcher/PythonStubs.cpp> I’ve looked into cffi but it seems to only solve a fraction of the problem. Our Qt-based application embeds Python and provides callbacks from Python to our application. It runs on macOS, Linux, and Windows and runs unchanged on Python 3.6, 3.7, and 3.8 since it dynamically links to Python.