robweber / xbmcbackup

Backup Addon for Kodi
MIT License
107 stars 48 forks source link

Dependency on older "future" module breaks python 3.12 compatibility #239

Closed craftyguy closed 2 weeks ago

craftyguy commented 1 month ago

Describe the problem

This addon fails to run on with Python 3.12 because future 0.18.x uses imp, which was removed in Python 3.12. future 1.0 fixes this, see: https://github.com/PythonCharmers/python-future/commit/a6222d2bd54e8ba10e5e22ab42f4d747b51d92f5

    <import addon="script.module.future" version="0.18.2+matrix.1" />

Platform and Kodi version

Alpine Linux 3.20, Kodi 21.0

Link to Debug Log

2024-05-30 01:01:19.668 T:26624   error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'ModuleNotFoundError'>
                                                   Error Contents: No module named 'imp'
                                                   Traceback (most recent call last):
                                                     File "/var/lib/kodi/.kodi/addons/script.xbmcbackup/default.py", line 4, in <module>
                                                       from resources.lib.backup import XbmcBackup
                                                     File "/var/lib/kodi/.kodi/addons/script.xbmcbackup/resources/lib/backup.py", line 10, in <module>
                                                       from . vfs import XBMCFileSystem, DropboxFileSystem, ZipFileSystem
                                                     File "/var/lib/kodi/.kodi/addons/script.xbmcbackup/resources/lib/vfs.py", line 10, in <module>
                                                       from . authorizers import DropboxAuthorizer
                                                     File "/var/lib/kodi/.kodi/addons/script.xbmcbackup/resources/lib/authorizers.py", line 5, in <module>
                                                       import resources.lib.tinyurl as tinyurl
                                                     File "/var/lib/kodi/.kodi/addons/script.xbmcbackup/resources/lib/tinyurl.py", line 3, in <module>
                                                       from future.moves.urllib.request import urlopen
                                                     File "/var/lib/kodi/.kodi/addons/script.module.future/lib/future/moves/__init__.py", line 5, in <module>
                                                       from future.standard_library import import_top_level_modules
                                                     File "/var/lib/kodi/.kodi/addons/script.module.future/lib/future/standard_library/__init__.py", line 65, in <module>
                                                       import imp
                                                   ModuleNotFoundError: No module named 'imp'
                                                   -->End of Python script error report<--
robweber commented 1 month ago

I'll admit I'm not super familiar with how the local OS version of Python interacts with what Kodi is expecting. I generally use Windows (where it's bundled) or a Kodi specialized build like LibreElec. Looking at Kodi's build files it seems that it's expecting Python 3.11 for Omega.

craftyguy commented 1 month ago

Hey thanks for taking a look at this. Yeah I'm not entirely sure either... it seems(?) that kodi is using some bundled future module, the host OS has future-1.0.0 installed but in the output above the backup addon is clearly using something older (since it's trying to pull in imp). I just noticed that if go into kodi and list addon dependencies, it shows this, which is stuck at 0.18.23: https://kodi.tv/addons/omega/script.module.future/

I have no clue who packages(?) that for kodi, it's not in the list of official addons. If you changed your import to bump the version, would kodi fetch a newer version? (I also don't know how dependency resolution stuff in kodi works...)

Looking at Kodi's build files it seems that it's expecting Python 3.11 for Omega.

This also seems kinda strange since Omega advertised python 3.12 support 🙃

craftyguy commented 1 month ago

FYI I went ahead and reported this to Kodi. Even if the actual problem doesn't lie in Kodi, maybe they can clarify how the old future module is being pulled in so this can be reported to the appropriate place.

https://github.com/xbmc/xbmc/issues/25284

craftyguy commented 1 month ago

Should be fixed by https://github.com/xbmc/repo-scripts/pull/2615, IIUC. Does this addon need an update once that patch is merged to use the newer future version too?

robweber commented 1 month ago

Took a look at the PRs involved. The way Kodi works is that it will pull in the most recent version of an addon, so if the futures addon is required (looks like TinyURL uses it) then when it's updated in the main repo it should get downloaded locally to your system. We can leave this open if you want to confirm once it's merged in the addon repo.

craftyguy commented 2 weeks ago

@robweber this addon is now working as expected since the patch in repo-scripts landed 🎉

Thank you so much for the support, and the great addon :)