You are welcome to ask questions here, I will give you pointers. The short answer is calibre uses all custom code I have written over decades to solve this issue. It uses
https://github.com/kovidgoyal/bypy to build python and all other native code dependencies for all three platforms. bypy also contains code to "freeze" python and run it in embedded mode which is used by the various exes calibre ships with. bypy also contains optimizations to sleep up python code loading which is especially slow on windows. However bypy is not really a plug and play finished product. It runs only on linux and does its building inside qemu virtual machines.