Check out the calibre ebook conversion software to see how to covert to mobi from an oeb/epub. It is the closest thing to what kindlegen does. Similarly, I have some alpha/beta quality python code that will convert from an epub to Kindle KF8 standalone version (not the joint/dual version). This code is experimental but does work. It requires both the lxlm and html5lib python modules be installed. You can also look at the Mobi_Unpack code to see the how Mobis are constructed.