Leseratte10 / acsm-calibre-plugin

Calibre plugin for ACSM->EPUB and ACSM->PDF conversion.
https://www.mobileread.com/forums/showthread.php?t=341975
GNU General Public License v3.0
695 stars 24 forks source link

The library libcrypto could not be found #68

Open freekvh opened 1 year ago

freekvh commented 1 year ago

Bug description

calibre, version 6.17.0 ERROR: Install plugin failed: A problem occurred while installing this plugin. This plugin will now be uninstalled. Please post the error message in details below into the forum thread for this plugin and restart calibre.

Traceback (most recent call last): File "/nix/store/jcwka24y0k09y494zh20achv414fi0l3-calibre-6.17.0/lib/calibre/calibre/customize/ui.py", line 710, in initialize_plugin p.initialize() File "calibre_plugins.deacsm.init", line 226, in initialize from libadobe import createDeviceKeyFile, update_account_path, sendHTTPRequest File "/tmp/calibre_6.17.0_tmp_i3rbcmnq/lrk5x84g.zip/libadobe.py", line 59, in from oscrypto import keys File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/keys.py", line 5, in from ._asymmetric import parse_certificate, parse_private, parse_public File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 27, in from .kdf import pbkdf1, pbkdf2, pkcs12_kdf File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/kdf.py", line 9, in from .util import rand_bytes File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/util.py", line 14, in from ._openssl.util import rand_bytes File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/util.py", line 6, in from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto.py", line 24, in from ._libcrypto_ctypes import ( File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto_ctypes.py", line 28, in raise LibraryNotFoundError('The library libcrypto could not be found') oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/nix/store/jcwka24y0k09y494zh20achv414fi0l3-calibre-6.17.0/lib/calibre/calibre/gui2/dialogs/plugin_updater.py", line 729, in _install_clicked plugin = add_plugin(zip_path) File "/nix/store/jcwka24y0k09y494zh20achv414fi0l3-calibre-6.17.0/lib/calibre/calibre/customize/ui.py", line 520, in add_plugin plugin = initialize_plugin(plugin, path_to_zip_file, PluginInstallationType.EXTERNAL) File "/nix/store/jcwka24y0k09y494zh20achv414fi0l3-calibre-6.17.0/lib/calibre/calibre/customize/ui.py", line 715, in initializeplugin raise InvalidPlugin((('Initialization of plugin %s failed with traceback:') calibre.customize.InvalidPlugin: Initialization of plugin Traceback (most recent call last): File "/nix/store/jcwka24y0k09y494zh20achv414fi0l3-calibre-6.17.0/lib/calibre/calibre/customize/ui.py", line 710, in initialize_plugin p.initialize() File "calibre_plugins.deacsm.init", line 226, in initialize from libadobe import createDeviceKeyFile, update_account_path, sendHTTPRequest File "/tmp/calibre_6.17.0_tmp_i3rbcmnq/lrk5x84g.zip/libadobe.py", line 59, in from oscrypto import keys File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/keys.py", line 5, in from ._asymmetric import parse_certificate, parse_private, parse_public File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 27, in from .kdf import pbkdf1, pbkdf2, pkcs12_kdf File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/kdf.py", line 9, in from .util import rand_bytes File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/util.py", line 14, in from ._openssl.util import rand_bytes File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/util.py", line 6, in from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto.py", line 24, in from ._libcrypto_ctypes import ( File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto_ctypes.py", line 28, in raise LibraryNotFoundError('The library libcrypto could not be found') oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found failed with traceback: Traceback (most recent call last): File "/nix/store/jcwka24y0k09y494zh20achv414fi0l3-calibre-6.17.0/lib/calibre/calibre/customize/ui.py", line 710, in initialize_plugin p.initialize() File "calibre_plugins.deacsm.init", line 226, in initialize from libadobe import createDeviceKeyFile, update_account_path, sendHTTPRequest File "/tmp/calibre_6.17.0_tmp_i3rbcmnq/lrk5x84g.zip/libadobe.py", line 59, in from oscrypto import keys File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/keys.py", line 5, in from ._asymmetric import parse_certificate, parse_private, parse_public File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 27, in from .kdf import pbkdf1, pbkdf2, pkcs12_kdf File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/kdf.py", line 9, in from .util import rand_bytes File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/util.py", line 14, in from ._openssl.util import rand_bytes File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/util.py", line 6, in from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto.py", line 24, in from ._libcrypto_ctypes import ( File "/home/myname/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto_ctypes.py", line 28, in raise LibraryNotFoundError('The library libcrypto could not be found') oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found

Operating system

Linux

Which version of Calibre are you running?

6.17.0

Which version of the ACSM Input plugin are you running?

0.0.16

Import type

No response

Further information

I'm on NixOS, I tried installing OpenSSL, but it seems deprecated. Not sure what else to try. For the record, I bought a book, site says it's an epub but it turns out to be some URLLINK.acsm file. Came here to find a solution to read my book :)

iacchi commented 1 year ago

I'm having a similar issue on Linux Debian Sid. I made sure the python3-oscryto package was installed. Unlike freekvh, who's getting a "The library libcrypto could not be found" error, I'm getting the error "Error detecting the version of libcrypto". Here's the complete error stack:

calibre, version 6.28.1
ERRORE: Installazione del Plugin fallita: Si è verificato un problema durante l'installazione di questo plugin. Il plugin sarà ora disinstallato. Per favore, riporta il messaggio di errore che segue nella discussione del forum relativa al plugin e riavvia calibre.

Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 710, in initialize_plugin
    p.initialize()
  File "calibre_plugins.deacsm.__init__", line 226, in initialize
    from libadobe import createDeviceKeyFile, update_account_path, sendHTTPRequest
  File "/tmp/calibre_6.28.1_tmp_8zcmk_tb/_ccj8qdd.zip/libadobe.py", line 59, in <module>
    from oscrypto import keys
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/keys.py", line 5, in <module>
    from ._asymmetric import parse_certificate, parse_private, parse_public
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 27, in <module>
    from .kdf import pbkdf1, pbkdf2, pkcs12_kdf
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/kdf.py", line 9, in <module>
    from .util import rand_bytes
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/util.py", line 14, in <module>
    from ._openssl.util import rand_bytes
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/util.py", line 6, in <module>
    from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto.py", line 24, in <module>
    from ._libcrypto_ctypes import (
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto_ctypes.py", line 47, in <module>
    raise LibraryNotFoundError('Error detecting the version of libcrypto')
oscrypto.errors.LibraryNotFoundError: Error detecting the version of libcrypto

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/gui2/dialogs/plugin_updater.py", line 729, in _install_clicked
    plugin = add_plugin(zip_path)
             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/calibre/calibre/customize/ui.py", line 520, in add_plugin
    plugin = initialize_plugin(plugin, path_to_zip_file, PluginInstallationType.EXTERNAL)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/calibre/calibre/customize/ui.py", line 715, in initialize_plugin
    raise InvalidPlugin((_('Initialization of plugin %s failed with traceback:')
calibre.customize.InvalidPlugin: Inizializzazione del plugin Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 710, in initialize_plugin
    p.initialize()
  File "calibre_plugins.deacsm.__init__", line 226, in initialize
    from libadobe import createDeviceKeyFile, update_account_path, sendHTTPRequest
  File "/tmp/calibre_6.28.1_tmp_8zcmk_tb/_ccj8qdd.zip/libadobe.py", line 59, in <module>
    from oscrypto import keys
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/keys.py", line 5, in <module>
    from ._asymmetric import parse_certificate, parse_private, parse_public
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 27, in <module>
    from .kdf import pbkdf1, pbkdf2, pkcs12_kdf
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/kdf.py", line 9, in <module>
    from .util import rand_bytes
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/util.py", line 14, in <module>
    from ._openssl.util import rand_bytes
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/util.py", line 6, in <module>
    from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto.py", line 24, in <module>
    from ._libcrypto_ctypes import (
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto_ctypes.py", line 47, in <module>
    raise LibraryNotFoundError('Error detecting the version of libcrypto')
oscrypto.errors.LibraryNotFoundError: Error detecting the version of libcrypto
 non riuscita con messaggio:
Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 710, in initialize_plugin
    p.initialize()
  File "calibre_plugins.deacsm.__init__", line 226, in initialize
    from libadobe import createDeviceKeyFile, update_account_path, sendHTTPRequest
  File "/tmp/calibre_6.28.1_tmp_8zcmk_tb/_ccj8qdd.zip/libadobe.py", line 59, in <module>
    from oscrypto import keys
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/keys.py", line 5, in <module>
    from ._asymmetric import parse_certificate, parse_private, parse_public
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 27, in <module>
    from .kdf import pbkdf1, pbkdf2, pkcs12_kdf
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/kdf.py", line 9, in <module>
    from .util import rand_bytes
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/util.py", line 14, in <module>
    from ._openssl.util import rand_bytes
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/util.py", line 6, in <module>
    from ._libcrypto import libcrypto, libcrypto_version_info, handle_openssl_error
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto.py", line 24, in <module>
    from ._libcrypto_ctypes import (
  File "/home/iacopo/.config/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_openssl/_libcrypto_ctypes.py", line 47, in <module>
    raise LibraryNotFoundError('Error detecting the version of libcrypto')
oscrypto.errors.LibraryNotFoundError: Error detecting the version of libcrypto
iacchi commented 1 year ago

I just realised now that there's a bugfix version downloadable from the mobileread forum: https://www.mobileread.com/forums/showpost.php?p=4157570&postcount=2 maybe it's worth mentioning it here on github as well? One needs to remove the plugin folder from the calibre data folder before attempting to install the bugfix version.

ezracelli commented 1 year ago

@freekvh I had the exact same issue, also on NixOS! I'm using an override to tell the custom oscrypto included by this plugin where to find libcrypto:

pkgs.calibre.overrideAttrs (attrs: {
  preFixup = (
    builtins.replaceStrings
      [
        ''
          --prefix PYTHONPATH : $PYTHONPATH \
        ''
      ]
      [
        ''
          --prefix LD_LIBRARY_PATH : ${pkgs.libressl.out}/lib \
          --prefix PYTHONPATH : $PYTHONPATH \
        ''
      ]
      attrs.preFixup
  );
})

I had to use libressl instead of openssl. When I tried openssl, I got the (different) "Error detecting the version of libcrypto" error mentioned above, but libressl worked fine.

WARNING: This will build calibre from scratch on your system, since Nix's cache doesn't include this customization. Builds in about 30 seconds on my desktop machine, but YMMV

Leseratte10 commented 1 year ago

Yeah, I should really get around to releasing 0.1.0 with all this fixed. The latest beta version here on Github ( https://github.com/Leseratte10/acsm-calibre-plugin/suites/15775400817/artifacts/900357147 ) also has this bugfix included so that one should work as well. This is the same bug as in #67. All that needs to be done is download the latest alpha version from the Github Actions page which contains a fixed oscrypto version.

mtill commented 1 year ago

Hi @Leseratte10 , I'm also facing this issue. Unfortunately, the Link you provided ( https://github.com/Leseratte10/acsm-calibre-plugin/suites/15775400817/artifacts/900357147 ) seems to be broken ?

Best regards and thank you very much for all your efforts mtill

Leseratte10 commented 1 year ago

The link is working fine, but only for users logged in on Github - sadly Github doesn't allow making these links public.

johunb commented 1 year ago

Using Calibre 6.29. If I use fixed plugin from here [https://www.mobileread.com/forums/showpost.php?p=4157570&postcount=2], I get this error: calibre, version 6.29.0 ERROR: Unhandled exception: InvalidPlugin:Initialization of plugin Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs' failed with traceback: Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

calibre 6.29 embedded-python: True Linux-6.5.0-kali3-amd64-x86_64-with-glibc2.37 Linux ('64bit', 'ELF') ('Linux', '6.5.0-kali3-amd64', '#1 SMP PREEMPT_DYNAMIC Debian 6.5.6-1kali1 (2023-10-09)') Python 3.10.1 Interface language: None Successfully initialized third party plugins: DeDRM (10, 0, 3) && Obok DeDRM (10, 0, 3) Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "calibre/gui2/preferences/plugins.py", line 325, in add_plugin File "calibre/customize/ui.py", line 520, in add_plugin File "calibre/customize/ui.py", line 715, in initialize_plugin calibre.customize.InvalidPlugin: Initialization of plugin Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs' failed with traceback: Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

If I use this link: [ https://github.com/Leseratte10/acsm-calibre-plugin/suites/15775400817/artifacts/900357147 I get a download calibre-plugins.zip with same error loading as above

johunb commented 1 year ago

calibre-migration.plugin.zip causes:

calibre, version 6.29.0 ERROR: Unhandled exception: InvalidPlugin:Initialization of plugin Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs' failed with traceback: Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

calibre 6.29 embedded-python: True Linux-6.5.0-kali3-amd64-x86_64-with-glibc2.37 Linux ('64bit', 'ELF') ('Linux', '6.5.0-kali3-amd64', '#1 SMP PREEMPT_DYNAMIC Debian 6.5.6-1kali1 (2023-10-09)') Python 3.10.1 Interface language: None Successfully initialized third party plugins: DeDRM (10, 0, 3) && Obok DeDRM (10, 0, 3) Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "calibre/gui2/preferences/plugins.py", line 325, in add_plugin File "calibre/customize/ui.py", line 520, in add_plugin File "calibre/customize/ui.py", line 715, in initialize_plugin calibre.customize.InvalidPlugin: Initialization of plugin Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs' failed with traceback: Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

calibre-plugin.zip causes: calibre, version 6.29.0 ERROR: Unhandled exception: InvalidPlugin:Initialization of plugin Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs' failed with traceback: Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

calibre 6.29 embedded-python: True Linux-6.5.0-kali3-amd64-x86_64-with-glibc2.37 Linux ('64bit', 'ELF') ('Linux', '6.5.0-kali3-amd64', '#1 SMP PREEMPT_DYNAMIC Debian 6.5.6-1kali1 (2023-10-09)') Python 3.10.1 Interface language: None Successfully initialized third party plugins: DeDRM (10, 0, 3) && Obok DeDRM (10, 0, 3) Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "calibre/gui2/preferences/plugins.py", line 325, in add_plugin File "calibre/customize/ui.py", line 520, in add_plugin File "calibre/customize/ui.py", line 715, in initialize_plugin calibre.customize.InvalidPlugin: Initialization of plugin Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs' failed with traceback: Traceback (most recent call last): File "calibre/customize/ui.py", line 710, in initialize_plugin File "calibre_plugins.deacsm.init", line 232, in initialize deacsmprefs = prefs.DeACSM_Prefs() AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

johunb commented 1 year ago

Thank you for your help!

twhitehead commented 11 months ago

Just a note that I worked around both it not being found and the version issue by editing the the _libcryptoctypes.py file in the directory calibre had unpacked the plugin. Changed

if libcrypto_path is None:
    libcrypto_path = get_library('crypto', 'libcrypto.dylib', '42')
if not libcrypto_path:
    raise LibraryNotFoundError('The library libcrypto could not be found')

libcrypto = CDLL(libcrypto_path, use_errno=True)

to

#libcrypto_path = _backend_config().get('libcrypto_path')
#if libcrypto_path is None:
#    libcrypto_path = get_library('crypto', 'libcrypto.dylib', '42')
#if not libcrypto_path:
#    raise LibraryNotFoundError('The library libcrypto could not be found')

libcrypto = CDLL('libcrypto.so.3', use_errno=True)

as just regular loading locates this fine (memory says that I saw this was already loaded at runtime, but I am unable to duplicate that now, however, it still loads fine). And further down there was a

if not version_match:
    version_match = re.search('(?<=LibreSSL )(\\d\\.\\d(\\.\\d)?)\\b', version_string)
if not version_match:
    raise LibraryNotFoundError('Error detecting the version of libcrypto')

which obviously needs \\d+ if your crpyto version string has any components > 9 (i.e., more than one digit long). With those two changes it all just worked.

Leseratte10 commented 11 months ago

Interesting, thanks for that patch. I don't know that much about library loading so I can't comment on the 1st change too much (I will need to look into that), but the 2nd change is something that I did for Linux as well a while ago (after openssl 3.0.10 came out) so I'll add that patch for the Mac library as well.

twhitehead commented 11 months ago

No problem. I did it again just now and updated the comment to have the correct library loading line (libcrypto.so.3).

Had read through the code, and the commented code is ultimately using the ctypes library location function find_library. It is pretty over the top, invoking gcc to try and locate the library it links against when you do a -lcrypto. To quote the reference

On Linux, find_library() tries to run external programs (/sbin/ldconfig, gcc, objdump and ld) to find the library file. It returns the filename of the library file.

Anyway, figured it made much more sense to just try and load it and let the system do its standard library loading location searching. Only item is that you do need the major version number. Wouldn't be hard to loop down trying versions from 3, or even 4 or 5, though.

ToxicFrog commented 11 months ago

I ran into the same problem (also on nixos), and the fixed version from github actions has timed out and is no longer available even when logged in. So here was my quick and dirty approach to getting a working install:

This gets a working plugin zip, but it also needs a bit of fiddling to properly find libcrypto. nix-shell on its own isn't enough, because then whatever it does to hunt down the library finds libcrypto.so.50 but the actual call to dlopen() can't. So:

and now it works, and I've successfully activated it with an anonymous ADE account.

zoof commented 11 months ago

The link is working fine, but only for users logged in on Github - sadly Github doesn't allow making these links public.

The link is definitely dead now. New link?

Leseratte10 commented 11 months ago

I've updated the included oscrypto version again, maybe that already fixes some of the issues.

Before I add the CDLL code patch by @twhitehead (if it's still needed with the new version) I need to test that some more to make sure it doesn't break any OS and/or older Calibre versions.

In case the link expires again I've also attached the current build of the plugin (64aaca3fbea10bd6e16534df4d4409e623b73abd) here: calibre-plugin.zip

zoof commented 11 months ago

Now working on Debian Bookworm.

reedstrm commented 9 months ago

Just a bump to encourage making a release - I love the fact that I no longer need to maintain Wine only to run ADE to download library books!

NathanFuller commented 6 months ago

@Leseratte10 thanks for all the work you've put into this! I tried installing the attached build from your comment above and got the error message below. Please advise?

calibre, version 6.13.0
ERROR: Unhandled exception: <b>InvalidPlugin</b>:Initialization of plugin Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 677, in initialize_plugin
    p.initialize()
  File "calibre_plugins.deacsm.__init__", line 232, in initialize
    deacsmprefs = prefs.DeACSM_Prefs()
                  ^^^^^^^^^^^^^^^^^^
AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'
 failed with traceback:
Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 677, in initialize_plugin
    p.initialize()
  File "calibre_plugins.deacsm.__init__", line 232, in initialize
    deacsmprefs = prefs.DeACSM_Prefs()
                  ^^^^^^^^^^^^^^^^^^
AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

calibre 6.13  embedded-python: False
Linux-6.1.0-18-amd64-x86_64-with-glibc2.36 Linux ('64bit', 'ELF')
('Linux', '6.1.0-18-amd64', '#1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01)')
Python 3.11.2
Interface language: None
Successfully initialized third party plugins: DeDRM (10, 0, 3) && Obok DeDRM (10, 0, 3)
Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 677, in initialize_plugin
    p.initialize()
  File "calibre_plugins.deacsm.__init__", line 232, in initialize
    deacsmprefs = prefs.DeACSM_Prefs()
                  ^^^^^^^^^^^^^^^^^^
AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/gui2/preferences/plugins.py", line 325, in add_plugin
    plugin = add_plugin(path)
             ^^^^^^^^^^^^^^^^
  File "/usr/lib/calibre/calibre/customize/ui.py", line 487, in add_plugin
    plugin = initialize_plugin(plugin, path_to_zip_file, PluginInstallationType.EXTERNAL)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/calibre/calibre/customize/ui.py", line 682, in initialize_plugin
    raise InvalidPlugin((_('Initialization of plugin %s failed with traceback:')
calibre.customize.InvalidPlugin: Initialization of plugin Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 677, in initialize_plugin
    p.initialize()
  File "calibre_plugins.deacsm.__init__", line 232, in initialize
    deacsmprefs = prefs.DeACSM_Prefs()
                  ^^^^^^^^^^^^^^^^^^
AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'
 failed with traceback:
Traceback (most recent call last):
  File "/usr/lib/calibre/calibre/customize/ui.py", line 677, in initialize_plugin
    p.initialize()
  File "calibre_plugins.deacsm.__init__", line 232, in initialize
    deacsmprefs = prefs.DeACSM_Prefs()
                  ^^^^^^^^^^^^^^^^^^
AttributeError: module 'calibre_plugins.deacsm.prefs' has no attribute 'DeACSM_Prefs'
ThePinkUnicorn6 commented 5 months ago

@NathanFuller I had the same issue and have been able to fix it by going to ~/.config/calibre/plugins and deleting the ACSMInput folder. This removes the remnants of deACSM, and when you try installing again it should just work.

nydragon commented 5 months ago

Hey, I opened a PR that will allow overriding the libssl and libcrypto locations.

If this PR goes through, anyone on NixOS can use this snippet:

```nix (pkgs.calibre.overrideAttrs (old: { postInstall = '' wrapProgram $out/bin/calibre \ --set-default ACSM_LIBCRYPTO ${pkgs.openssl.out}/lib/libcrypto.so \ --set-default ACSM_LIBSSL ${pkgs.openssl.out}/lib/libssl.so ''; })) ```

onatbas commented 1 month ago

I am facing these similar issues on a Mac, too.

The link above doesn't seem to lead to any build I can download. It looks like a Calibre plugin isn't simply a zip archive of the code as I've run into multiple issues. Can someone point me in the right direction as to how to make the master branch (or whichever branch) into a proper Calibre package?

FWIW, here's my trace. This repeats multiple times.


calibre 6.29  embedded-python: True
macOS-14.4.1-arm64-arm-64bit Darwin ('64bit', '')
('Darwin', '23.4.0', 'Darwin Kernel Version 23.4.0: Fri Mar 15 00:19:22 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8112')
Python 3.10.1
OSX: ('14.4.1', ('', '', ''), 'arm64')
Interface language: None
Successfully initialized third party plugins: DeDRM (10, 0, 9) && Count Pages (1, 13, 4) && EpubMerge (2, 16, 0) && EpubSplit (3, 6, 0) && Extract ISBN (1, 6, 0) && Goodreads (1, 7, 9) && Goodreads Sync (1, 16, 3) && KOReader Sync (0, 6, 4) && KoboTouchExtended (3, 6, 6)
Traceback (most recent call last):
  File "calibre/customize/ui.py", line 710, in initialize_plugin
  File "calibre_plugins.deacsm.__init__", line 226, in initialize
    from libadobe import createDeviceKeyFile, update_account_path, sendHTTPRequest
  File "/Users/otb/Downloads/DeACSM_0.0.16.zip/libadobe.py", line 59, in <module>
    from oscrypto import keys
  File "/Users/otb/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/keys.py", line 5, in <module>
    from ._asymmetric import parse_certificate, parse_private, parse_public
  File "/Users/otb/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/_asymmetric.py", line 27, in <module>
    from .kdf import pbkdf1, pbkdf2, pkcs12_kdf
  File "/Users/otb/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/kdf.py", line 9, in <module>
    from .util import rand_bytes
  File "/Users/otb/Library/Preferences/calibre/plugins/DeACSM/modules/oscrypto/oscrypto/util.py", line 10, in <module>
    from ._mac.util import rand_bytes
ModuleNotFoundError: No module named 'oscrypto._mac.util'
nydragon commented 1 month ago

You should be able to get a zip by running bundle-calibre-plugin.sh

tokiWren commented 3 weeks ago

@NathanFuller I had the same issue and have been able to fix it by going to ~/.config/calibre/plugins and deleting the ACSMInput folder. This removes the remnants of deACSM, and when you try installing again it should just work.

I'm experiencing the same error stack, and this workaround didn't work for me. It just returns the same error whether or not there is the DeACSM folder.