Quote:
Originally Posted by fake-name
I'm interested in extending the duplicate finding plugin to do aproximate text/cover matches. I've done both outside of calibre in the past in python successfully.
However, to do so, there are substantial library dependencies:
For text similarity (in a reasonable timeframe), I need a MinHashLSH implementation. I've used datasketch ( https://github.com/ekzhu/datasketch) previously, which has a hard dependency on numpy (and I'd really like scipy, as MinHashLSH can use scipy for speeding up the initialization there).
For Image similarity, a DCT based p-hash works very well. I can use a pure python DCT implementation, but scipy provides convenent DCT functions, and I need it anyways for MinHashLSH.
What's the correct way for working on plugins like this? From what I've read there's no way to specify that your plugin has external dependencies (requirements.txt, etc...). Vendoring (and packaging) versions of all the packages for every platform is prohibitive.
|
Hi mate,
I had a similar problem trying to create my first plugin for calibre, and my solution was "simple" but effective ( Happy idea )
U can try this...
1º Add a folder with the library you needs to use in your project.
2º Import any library to unzip files like "import zipfile"
3º Extrat this folder in calibre plugin folder
(Example code ### unzip.py ###)
Code:
from calibre.utils.config import config_dir
UNZIP_PATH = Path(config_dir).joinpath("plugins/YOUR_PLUGIN_NAME")
UNZIP_M_PATH = Path(config_dir).joinpath("plugins/YOUR_PLUGIN_NAME/your_library_folder_name")
if Path.is_dir(UNZIP_M_PATH):
print('This library folder already exists on your system')
else:
for file in archive.namelist():
if file.startswith('your_library_folder_name'):
archive.extract(file, UNZIP_PATH)
4º Import your custom estracted libs from calibre/plugins folder
(example code for import your custom libs on main.py or whatever file.py)
Code:
import os
from calibre_plugins.YOUR_PLUGIN_NAME.unzip import UNZIP_PATH
sys.path.append(UNZIP_PATH)
os.chdir(UNZIP_PATH)
FROM your_library_folder_name import what_you_need
You can see the code on my plugin AudioBook_Duration on this forum.
AudioBook_Duration
I think it can be useful for you to use external libraries.