Importing without requires - possible?
#1
Lets say that my addon needs the requests module. Normally I would specify that requirement in the addon.xml. But lets say I don't want to do that.

Is there any other way to import that module without having to find the folder and adding it to sys.path?
Reply
#2
(2016-05-16, 01:14)Karnagious Wrote: Is there any other way to import that module without having to find the folder and adding it to sys.path?

It's not possible because it contradicts Python import implementation. Python (or rather CPython) must import from sys.path, this is how it works. If a module/package is not in sys.path, it does not exist for Python.

The thing is that earlier, before Kodi 15 Isengard, if I'm not mistaken, all installed addons were added to sys.path so requirements in addon.xml were only needed to auto-install missing dependencies. Since 15.0 this behavior has been changed and now requirements serve both for installing missing dependencies and for adding the necessary modules to sys.path.

So if you don't want to use requirements mechanism of addon.xml then you need to package all dependencies within your addon and add them to sys.path.
Reply
#3
Thanks. It is good to know that the behaviour changed as well. Fits what I thought was the case.
Reply

Logout Mark Read Team Forum Stats Members Help
Importing without requires - possible?0