Mobileread
Developing plugins (python3)
#1  rigogsilva 05-19-2020, 08:25 PM
I have been looking at the docs on how to build a calibre plugin, but can't find I can't find some detail information.

Do I need to install the whole calibre library? Is there a pip install calibre library? Newby here so, need some more details if anyone can help.

Also, I am trying to this in python3. R.I.P 2.7.

Thank you!!!
Reply 

#2  kovidgoyal 05-19-2020, 09:23 PM
You dont need to install anything other than calibre itself. If you want to use python 3 then install the calibre python 3 betas from https://www.mobileread.com/forums/sh...d.php?t=325721

And see https://manual.calibre-ebook.com/creating_plugins.html
Reply 

#3  rigogsilva 05-19-2020, 11:46 PM
Quote kovidgoyal
You dont need to install anything other than calibre itself. If you want to use python 3 then install the calibre python 3 betas from https://www.mobileread.com/forums/sh...d.php?t=325721

And see https://manual.calibre-ebook.com/creating_plugins.html
Ok, so I have calibre installed. I also created the __init__.py. When I run the command “ calibre-customize -b .” it fails. Do I need to copy the calibre-customize from the applications folder into my plugin folder?

My folder structure is:
/rigo/calibre-plugin
/__init__.py
Reply 

#4  kovidgoyal 05-20-2020, 12:02 AM
fails with what error and a plugin is a directory containing __init__.py and a txt file with the plugins import name
Reply 

#5  kovidgoyal 05-20-2020, 12:04 AM
If you are on macOS, then read the note: https://manual.calibre-ebook.com/generated/en/cli-index.html
Reply 

#6  rigogsilva 05-20-2020, 01:12 PM
Quote kovidgoyal
fails with what error and a plugin is a directory containing __init__.py and a txt file with the plugins import name

rigo$ calibre-customize -b .
bash: calibre-customize: command not found

It can’t access that command. That is why I asked, I needed to move the `calibre-customize` file into the folder where the init file is.

Also, when trying to import calibre in the __init__.py file, it doesn’t really recognize calibre because that wan’t installed as a python library and the folder that has the init file doesn’t really have that `calibre` module. So may be missing something.
Reply 

#7  rigogsilva 05-20-2020, 08:13 PM
the good news is that I can apply the plugin by using the absolute path: "/Applications/calibre.app/Contents/MacOS/calibre-customize -b ." in my directory. That works fine and applies the plugin.

The other issue I am having is when developing the library. My text editor doesn't know that calibre exists so when I write:
from calibre.customize import FileTypePlugin"
I don't get any library hints. Do I need to `pip` install a calibre library to get those hints?
Reply 

#8  kovidgoyal 05-20-2020, 10:04 PM
Depends on how your editor does hinting. You cannot install calibre as library, but you can add the PATh to the calibre source code to PYTHONPATH.
Reply 

Today's Posts | Search this Thread | Login | Register