Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13951

How to embed python into a standalone C++ application? (i.e. do not rely on Libs folder on disk)

$
0
0

I'm trying to embed python into my C++ application, but also make it standalone, i.e. do not rely on python dependencies on a disk, like Libs folder with standard library scripts, but still be able to use them. I can find a way to store all the the scripts from Libs in the binary by myself and load them into the memory after running the program, but the problem is that I don't know how to "load" them into python interpreter directly from memory, either from text or binary (compiled) scripts, without dropping them on disk, how pyinstaller does (it extracts all compiled scripts into temp system dir).

I'm wondering if there is any kind of callback in cpython that allows a user to override import keyword and general modules import logic so I could import a module from memory instead of loading it from disk. I couldn't find anything like that on google. Maybe you know if there is such feature?

Thanks in advance!


Viewing all articles
Browse latest Browse all 13951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>