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 08-24-2022, 08:05 AM   #1
Mikowmer
Member
Mikowmer began at the beginning.
 
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)
The abi3.so binary files for those specific submodules are present. However, when the plugin is being loaded, those binaries are ignored.


Would it be possible to get some help on including non-Python dependencies in a Calibre plugin?
Mikowmer is offline   Reply With Quote
Old 08-24-2022, 08:16 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: 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.
kovidgoyal is offline   Reply With Quote
Advert
Old 08-24-2022, 08:33 AM   #3
Mikowmer
Member
Mikowmer began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Aug 2022
Location: Australia
Device: reMarkable 2
Quote:
Originally Posted by kovidgoyal View Post
The appropriate folders need to be on sys.path before attempting the import.
... Meaning?

Is that the appropriate folders for the module, or the non-Python code?
Mikowmer is offline   Reply With Quote
Old 08-24-2022, 09:28 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: 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.
kovidgoyal is offline   Reply With Quote
Old 08-31-2022, 12:22 AM   #5
Kenivia
Junior Member
Kenivia began at the beginning.
 
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.
Kenivia is offline   Reply With Quote
Advert
Old 08-31-2022, 02:12 AM   #6
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: 43,977
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Code:
with self:
   import whatever
see the __enter__ method of the Plugin base class
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

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


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


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