Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 05-31-2025, 09:11 AM   #1
suprezg
Junior Member
suprezg began at the beginning.
 
suprezg's Avatar
 
Posts: 4
Karma: 10
Join Date: May 2025
Device: none
Seeking Guidance on Modularizing Calibre's Ebook Viewer and Organizing Source Code

I am currently working on a fork of Calibre and want to separate all code and files related solely to the ebook viewer into a dedicated directory. My goal is to make the viewer runnable as a standalone application by executing main.py from src/calibre/gui2/viewer.

If this separation is not feasible, I would like to know how I can write my own viewer that leverages Calibre’s ebook viewer features, such as read aloud, search, highlights, and bookmarks. Which classes or modules should I study so I can invoke these functionalities from my own code?

Additionally, I have noticed that running python -m src.calibre.gui2.viewer.main results in errors like "polyglot module not found," and even after fixing that, other errors appear. However, running calibre-debug -c "from calibre.gui2.viewer.main import main; main()" works fine and launches the viewer. What does calibre-debug do in the backend to make this work, and how can I replicate this behavior in my own setup?

Are there any tips or sources available for organizing the Calibre source code?

Any guidance or insights would be helpful!!!
suprezg is offline   Reply With Quote
Old 05-31-2025, 10:27 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,250
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You cannot use calibre's viewer code in isolation. It's not designed for that and its not going to ever work like that.
kovidgoyal is offline   Reply With Quote
Old 05-31-2025, 11:14 PM   #3
suprezg
Junior Member
suprezg began at the beginning.
 
suprezg's Avatar
 
Posts: 4
Karma: 10
Join Date: May 2025
Device: none
Hi Kovid, thank you for your reply.

Is there a way to use the bypy utility to create an ebook-viewer.exe without packaging the entire calibre application? Alternatively, can I develop a new viewer that utilizes existing calibre features such as Read Aloud and Search?

Additionally, I’ve noticed that when I try to run certain main.py files using Python directly, they do not work, but when I run them using calibre-debug, they execute successfully. Why does this happen?

Ultimately, my goal is to create a stripped-down version of calibre that consists solely of the ebook viewer.

Any guidance would be greatly appreciated. Thank you!
suprezg is offline   Reply With Quote
Old 06-01-2025, 12:21 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,250
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There is no way to do that. The viewer is not separable in any form from the rest of calibre.
kovidgoyal is offline   Reply With Quote
Old 06-02-2025, 08:08 AM   #5
suprezg
Junior Member
suprezg began at the beginning.
 
suprezg's Avatar
 
Posts: 4
Karma: 10
Join Date: May 2025
Device: none
Hi Kovid,
Thank you for your reply. I really need your help with this. While studying the repository, I noticed that there are many files related to ebook conversion to various formats, the ebook metadata editor, news fetcher, and other features.

I want to create a small app that I can integrate into my project, focusing solely on the ebook viewer. It would be very helpful if you could list the folders that are not related to the ebook viewer and can be safely removed.

Even if the viewer cannot be made completely standalone, I am looking for a stripped-down version without any additional functionalities.

I also noticed that there is an ebook-viewer.exe file. How can I build an executable like this with only ebook viewing capability?

Additionally, please guide me on how to test the application after removing unnecessary files from the source code.

Thank you!
suprezg is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ebook-viewer when running from source ownedbycats Development 9 12-27-2022 07:29 PM
ebook-convert source code faredoon Development 4 12-08-2017 08:15 PM
[old-topic]ebook-viewer: Open source, crossplatform viewer for EPUB, LIT, MOBI, etc kovidgoyal Calibre 68 05-30-2011 08:46 PM
iLiad Is source code of iLiad image viewer available? ericshliao iRex Developer's Corner 1 01-16-2008 02:24 AM


All times are GMT -4. The time now is 03:54 AM.


MobileRead.com is a privately owned, operated and funded community.