Hi Katie,
This is probably as good a list for this as any. :)
On Thu, Feb 13, 2020, 01:31 Katie Lucas via capi-sig <capi-sig@python.org> wrote:
Hello. I'm trying to embed a Py3.8 interpreter into a C++ application to use as the "glue" for all the other components. We've come across some complexities -- revolving around the use of frozen modules and multiple interpreter states
Oh, that sounds quite interesting! What modules are you freezing?
We can get a single interpreter running. We can add our stream objects and
capture the output, we can load our modules (giving the API access) into it and generally everything seems fairly happy in single interp mode.
When we try and run a Py_NewInterpreter() to get us more interps to get encapsulation between multiple scripts, it fails to launch (fails to get filesystem's codec).
Is there some code you could point us at?
The problem seems to be that the frozen modules added
to the launched interpreter are not cached after use. So the cloned interpreter fails to start (it wants either an encoder search path which is null for no filesystem OR to have the encodings module available). The modules don't seem to be being cached because when the import runs them with PyEval_EvalCode, they return nothing.
I suspect this is something I've missed about how to configure the original interpreter, but documentation & use-examples for the new split-phase initialisation are rather hard to find.
It may help you to look at how CPython freezes importlib.
-eric