After some research time, I found a way to do it in CPP but not in python.
The most relevant part of the code dealing with loading PEs from buffer to memory:
void destroy_linput(linput_t* li)
linput_t* create_linput(std::vector< bit7z::...
If someone feels the need to do this programmatically in a non-debug setting, this is the code I would use.
Note #1: There are some shortcut functions of my own GetFuncStart and such that are not included, I'm sure you can work them out. The reference to the Commenter class will just have to be removed.
Note #2: The seemingly extreme measures taken in ...
During debugging IDA does a limited amount of autoanalysis to speed up the debugging experience and not interfere with the process. What you can do is to copy the module to be analyzed to the database, then stop the debugger and let IDA finish the autoanalysis on the saved data. This can be done via the "Analyze module" command in the Modules list.
If you are using CLIthen do something like: ida_typeinf.idc_parse_types("filename.h", idc.PT_FILE). See this file for more options. Also check this link for GUI, they also explained how to setup your header file. Hope this helps.