python - Dynamically loading two libpython versions -


i have program embeds both python2 , python3 interpreters. libpython shared libraries dlopen()ed respective commands provide access interpreters , each interpreter maintains own state.

this works fine if user uses pure python modules or builtins. trying load c extension (like termios) complains "undefined symbol: pyexc_typeerror". happens because c extensions aren't linked against libpython. python upstream doesn't think problem.

to around that, can change dlopen() calls in program libpython shared libraries use rtld_global. that, however, trying use both python2 , python3 interpreters in same session of program causes abrt in process of calling py_initialize whichever interpreter invoked second. using 1 of interpreters works fine.

any idea how work when c extensions won't linked against libpython, therefore requiring use of rtld_global?

sorry, won't work way want to. solution ordinarily involve linking each extension versioned libpython symbols; or 1 have namespace-capable linker, such 1 map each library different namespace, rather global one. unfortunately neither of these options applied, you're stuck multi-process model. fork , have 1 process link each version of python. tough bit how share whatever data led require 2 distinct python interpreters in first place. perhaps description of problem led question may find better solution?


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -