saiyr / cloze-overlapper

Anki add-on for memorizing lists and enumerations
https://ankiweb.net/shared/info/969733775
Other
6 stars 1 forks source link

No reference to packaging in libaddon/__init__.py leading to startup crash. #2

Closed IAmzColbz closed 1 month ago

IAmzColbz commented 2 months ago

Problem description

Upon installing the addon via the anki-web addons page, restarting Anki led to the startup failing, erroring this addon specifically. I traced back the issue and made a temporary fix, however I don't know if it is a proper way to actually fix it long term.

In order to fix this issue, I edited ./libaddon/anki/configmanager.py

from .._vendor.packaging import version

to -

from packaging import version

I don't know enough about python to know if this is a good fix or not.

Cannot find reference 'packaging' in '__init__.py' so i just pulled in packaging from base which led to the addon starting up perfectly fine on my end.

Checklist

Please replace the space inside the brackets with an x if the following items apply:

If you are using Anki 2.1
Anki 24.06.3 (d678e393) (src) (ao)
Python 3.12.5 Qt 6.7.2 PyQt 6.7.1
Platform: Linux-6.10.6-arch1-1-x86_64-with-glibc2.40

===Add-ons (active)===
(add-on provided name [Add-on folder, installed at, version, is config changed])
Cloze Overlapper for 23x ['1784155610', 2024-02-17T19:53, 'None', '']
Customize Keyboard Shortcuts ['24411424', 2023-11-01T04:17, 'None', '']

===IDs of active AnkiWeb add-ons===
1784155610 24411424

===Add-ons (inactive)===
(add-on provided name [Add-on folder, installed at, version, is config changed])

Please fill in details about your operating system (Windows/macOS/Linux, which version):

Error message (if any)

When loading Cloze Overlapper for 23x:
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/aqt/addons.py", line 247, in loadAddons
    __import__(addon.dir_name)
  File "/home/username/.local/share/Anki2/addons21/1784155610/__init__.py", line 125, in <module>
    initializeAddon()
  File "/home/username/.local/share/Anki2/addons21/1784155610/__init__.py", line 105, in initializeAddon
    from .gui.options_global import initializeOptions
  File "/home/username/.local/share/Anki2/addons21/1784155610/gui/options_global.py", line 46, in <module>
    from ..config import config
  File "/home/username/.local/share/Anki2/addons21/1784155610/config.py", line 42, in <module>
    from .libaddon.anki.configmanager import ConfigManager
  File "/home/username/.local/share/Anki2/addons21/1784155610/libaddon/anki/configmanager.py", line 45, in <module>
    from .._vendor.packaging import version
ModuleNotFoundError: No module named '1784155610.libaddon._vendor.packaging'
saiyr commented 1 month ago

Sorry for the delay. I didn't get a notification for this bug. I'm looking into it, though I haven't been able to reproduce yet.

saiyr commented 1 month ago

My current hypothesis is that there's a difference between Python 3.9 and 3.12. I'm trying to reproduce in a Linux environment, as I thought it might use the system Python version, but for me, it still uses Python 3.9. Did you build from source? If so, does the binary install have the same issue?

saiyr commented 1 month ago

Confirmed my hypothesis. A deprecated interface method was removed in Python 3.12, so I need to use the updated one.

saiyr commented 1 month ago

This should be fixed by v1.0.2.

IAmzColbz commented 1 month ago

Oop, sorry i didn't get a notification either. And yes, once I rebuilt with the patch it worked out of the box. Thank you for your help!

saiyr commented 1 month ago

Great to hear. Thanks for testing it out.