08-24-2022, 08:05 AM | #1 |
Member
Posts: 18
Karma: 10
Join Date: Aug 2022
Location: Australia
Device: reMarkable 2
|
Dealing with non-Python Dependencies
Hello!
I'm currently attempting to troubleshoot someone else's plugin for Calibre. The plugin in question is here: https://github.com/naclander/Calibre...-Driver-Plugin At the moment, it looks like certain Rust binaries in the Cryptography module aren't importing correctly due to an 'unknown location'. Code:
ImportError: cannot import name 'asn1' from 'cryptography.hazmat.bindings._rust' (unknown location) Would it be possible to get some help on including non-Python dependencies in a Calibre plugin? |
08-24-2022, 08:16 AM | #2 |
creator of calibre
Posts: 43,977
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The appropriate folders need to be on sys.path before attempting the import.
|
Advert | |
|
08-24-2022, 08:33 AM | #3 |
Member
Posts: 18
Karma: 10
Join Date: Aug 2022
Location: Australia
Device: reMarkable 2
|
|
08-24-2022, 09:28 AM | #4 |
creator of calibre
Posts: 43,977
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The folder that contains the python package you are importing has to be on sys.path if it is and the abi version of the compiled module is a match it will import.
|
08-31-2022, 12:22 AM | #5 |
Junior Member
Posts: 1
Karma: 10
Join Date: Aug 2022
Device: Remarkable2
|
I've posted a workaround on GitHub here. You were right, the path added to sys.path was the path to the zip file.
Having the library somewhere else is not the most elegant solution, is there a better way to do this? Maybe the plugin could decompress the zip file temporarily? Last edited by Kenivia; 08-31-2022 at 12:26 AM. |
Advert | |
|
08-31-2022, 02:12 AM | #6 |
creator of calibre
Posts: 43,977
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Code:
with self: import whatever |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Plugin dependencies | jpwhiting | Development | 9 | 09-10-2021 09:39 AM |
Python 2 to Python 3, Polyglot & Plugins | DaltonST | Calibre | 18 | 04-24-2019 12:10 AM |
Calibre Plugin with External Dependencies | ClashTheBunny | Development | 1 | 06-22-2015 10:41 AM |
Dependencies | Bada Bing | Calibre | 3 | 03-11-2011 07:17 AM |
[Rant] New dependencies for 0.6.11? | Jellby | Calibre | 15 | 10-16-2009 10:17 AM |