Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potentially incompatible with Python 3.12? #1006

Closed
Mikaela opened this issue Oct 12, 2023 · 8 comments
Closed

Potentially incompatible with Python 3.12? #1006

Mikaela opened this issue Oct 12, 2023 · 8 comments

Comments

@Mikaela
Copy link

Mikaela commented Oct 12, 2023

I am on Fedora 39 (beta) which ships with Python 3.12.0 and fanficfare (4.28.0) keeps being disabled in Calibre (6.21).

When I run calibre in terminal, I see:

Failed to initialize plugin: SmartDevice App Interface (0, 0, 1)
Failed to initialize plugin: <class 'calibre.devices.smart_device_app.driver.SMART_DEVICE_APP'>
calibre_plugins.fanficfare_plugin.fff_plugin:1103: SyntaxWarning: invalid escape sequence '\.'
Traceback (most recent call last):
  File "/usr/lib64/calibre/calibre/gui2/ui.py", line 139, in __init__
    ac = self.init_iaction(action)
         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/calibre/calibre/gui2/ui.py", line 157, in init_iaction
    ac = action.load_actual_plugin(self)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.fanficfare_plugin.__init__", line 121, in load_actual_plugin
    return InterfaceActionBase.load_actual_plugin(self,gui)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/calibre/calibre/customize/__init__.py", line 646, in load_actual_plugin
    ac = getattr(importlib.import_module(mod), cls)(gui,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
  File "/usr/lib64/calibre/calibre/customize/zipplugin.py", line 205, in exec_module
    exec(compiled, module.__dict__)
  File "calibre_plugins.fanficfare_plugin.fff_plugin", line 79, in <module>
    from fanficfare import adapters, exceptions
  File "/home/mikaela/.config/calibre/plugins/FanFicFare.zip/fanficfare/adapters/__init__.py", line 24, in <module>
    from ..six.moves.urllib.parse import urlparse
ModuleNotFoundError: No module named 'fanficfare.six.moves'
@JimmXinu
Copy link
Owner

I will look into that, but I don't support FFF plugin on vendored versions of Calibre, only the official calibre releases.

@JimmXinu
Copy link
Owner

I'll look into the SyntaxWarning: invalid escape sequence '\.' warning, which I expect is not uncommon in FFF.

The actual error is ModuleNotFoundError: No module named 'fanficfare.six.moves' which is, as far as I can tell, caused by a broken vendored Calibre version.

@natrys
Copy link

natrys commented Oct 12, 2023

@JimmXinu I am hitting this too. Installed in a fresh venv of 3.12, without calibre. The problem is probably not calibre, you are vendoring six.py here except it's an old version:

https://github.com/JimmXinu/FanFicFare/blob/main/fanficfare/six.py

I have replaced that file with newer version, and it seems to work now. But maybe you shouldn't vendor this?

@JimmXinu
Copy link
Owner

@natrys 's comment did lead me to investigate further and they are right; there's a load issue and updating six does address it. Thanks for pointing that out.

(FFF includes six because older versions of Calibre include an even older version of six.)

I've uploaded test versions in the usual places.

@gramer23
Copy link

It turns out that on Python 3.12, configparser's readfp() method was renamed to read_file(). If anyone else has the problem where every download fails because it can't find readfp, simply renaming every occurrence fixes every error. There are two calls in fff_util.py and two others in fanficfare/cli.py. (I'm talking about the paths inside the plugin's zip, since that's probably the easiest place to edit the files without repackaging.)

I guess this might be useful for even the official version when Calibre also moves on. Until then, this is a good workaround for those who can't or don't want to install a Python 3.11 interpreter just to download some stories.

@JimmXinu
Copy link
Owner

There's also one in jobs.py.

This issue is only with Calibre and Python 3.12. Which is technically outside what I support. But it's a relatively easy fix. Test version up.

@gramer23
Copy link

gramer23 commented Oct 13, 2023 via email

@JimmXinu
Copy link
Owner

In jobs.py it's contingent on settings.

I'm going to close this, but you can reopen it if you find more 3.12 issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants