I am investigating whether it is possible to generate an ebook, say, a Kindle book, programmatically. are there any libraries, open source or proprietary? in particular, for python.
An ebook or epub is just xhtml with some meta info and stuff. Every page is a xhtml file.
Here is a tutorial on How to Make an ePub eBook by Hand.