flathub / net.ankiweb.Anki

https://flathub.org/apps/details/net.ankiweb.Anki
20 stars 13 forks source link

Addons aren't working with current Anki of Flathub #11

Closed aldevel closed 5 years ago

aldevel commented 5 years ago

My Flatpak version is 1.0.1 on KDE neon 5.13 built on Ubuntu 18.04 LTS

Although I tried only two addons, it seems current Flatpak's Anki won't work with them, AwesomeTTS for anki 2.1 and Night mode: https://ankiweb.net/shared/info/1496166067 https://ankiweb.net/shared/info/900455869 Both gives the result "ignored late bridge cmd domDone" in terminal. After this I downloaded Anki directly and that works with the same AwesomeTTS and Night mode addons above.

There is a gui popup windows with some explanation too. Results with Night mode addon:

When loading 'Night Mode':
Traceback (most recent call last):
  File "/app/share/anki/aqt/addons.py", line 60, in loadAddons
    __import__(dir)
  File "/home/user/.var/app/net.ankiweb.Anki/data/Anki2/addons21/1496166067/__init__.py", line 1, in <module>
    from .night_mode import NightMode
  File "/home/user/.var/app/net.ankiweb.Anki/data/Anki2/addons21/1496166067/night_mode.py", line 248
    html = f"<script>{javascript}</script>" + html
 -----------------------------^------------------------------
SyntaxError: invalid syntax

Result with AwesomeTTS addon:

When loading 'AwesomeTTS for Anki 21':
Traceback (most recent call last):
  File "/app/share/anki/aqt/addons.py", line 60, in loadAddons
    __import__(dir)
  File "/home/user/.var/app/net.ankiweb.Anki/data/Anki2/addons21/900455869/__init__.py", line 33, in <module>
    from . import conversion as to, gui, paths, service
  File "/home/user/.var/app/net.ankiweb.Anki/data/Anki2/addons21/900455869/gui/__init__.py", line 23, in <module>
    from .common import (
  File "/home/user/.var/app/net.ankiweb.Anki/data/Anki2/addons21/900455869/gui/common.py", line 37
    ICON_FILE = f'{ICONS}/speaker.png
--------------------------^------------------------
SyntaxError: invalid syntax
jurf commented 5 years ago

Hm, I tried this and got different output for Night Mode:

When loading 'Night Mode':
Traceback (most recent call last):
  File "/app/share/anki/aqt/addons.py", line 60, in loadAddons
    __import__(dir)
  File "/home/jurf/.var/app/net.ankiweb.Anki/data/Anki2/addons21/1496166067/__init__.py", line 1, in <module>
    from .night_mode import NightMode
  File "/home/jurf/.var/app/net.ankiweb.Anki/data/Anki2/addons21/1496166067/night_mode.py", line 46, in <module>
    from .actions_and_settings import *
  File "/home/jurf/.var/app/net.ankiweb.Anki/data/Anki2/addons21/1496166067/actions_and_settings.py", line 7, in <module>
    from .internals import Setting, MenuAction, alert
  File "/home/jurf/.var/app/net.ankiweb.Anki/data/Anki2/addons21/1496166067/internals.py", line 228
    raise Exception(f'Asked to wrap "{key}" but target of {name} not defined')
                                                                            ^
SyntaxError: invalid syntax

However I have no idea what could be wrong. The syntax error generally means the wrong Python version is being used to run the code, but from a brief code scan it should be Python 3 code, so that shouldn’t be a problem…

dsd commented 5 years ago

f-strings are not supported in the old version of Python3 in the KDE runtime.

@nedrichards what's the latest on having a new KDE runtime available based on the freedesktop 18.08 runtime?

Over the last few days commits were made in Anki git upstream to allow execution on newer Qt versions so we are one step closer there...

jurf commented 5 years ago

@dsd Alex said ‘novemberish’ when I asked on IRC some time back, and Qt 5.12 is due to be released ~29th November so some time after that. That will be the first KDE runtime on 18.08.

jurf commented 5 years ago

But I don’t see a reason not to bundle Python 3.6 until then. Here’s the build recipe for fd.o 18.08.

dsd commented 5 years ago

Maybe, but this would only work if anki does not use any other py3.6 code present in the runtime (otherwise you would have to rebuild that too).

aldevel commented 5 years ago

Thanks for the responses! I don't know what's going on with Anki scripts however I know that python packages with f-string support are installed on my system. Why is it able to call an incompatible version of python? Anyway, is it possible to get Anki use the correct python version?

jurf commented 5 years ago

Anki uses the python inside that sandbox. That’s how Flatpak works. Unfortunately we didn’t have a compatible Python at disposition (or we’d have to build it ourselves, which is a PITA). That is now fixed however with 2497e91d32384de1ffb78a8714278c7cec22fba6. Please try if they work now. :slightly_smiling_face:

Edit: i.e. the new version will be available once this has finished.

aldevel commented 5 years ago

My mobo just died two weeks ago so I wasn't able to check on this issue, I mean I don't really know since when it's fixed however it's now sure Flatpak's Anki works on my current, updated KDE neon 5.14, awesome. Thank you so much guys keeping me updated related to this case, for me it's interesting only I was the single person with this issue and regarding to that, I assume I have to close this case. Please reopen it if I was wrong about that. Thanks again for making Anki available on Flatpak!!