Kodi Community Forum

Full Version: Are addons run in isolation?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
A quick question, is it safe to assume that addons are run in isolation? That is, I can't pollute the namespace of another addon with the contents of my /src/ or /lib/ and vice versa.

Looking at sys.path this seems to be the case*, but I can't find any explicit mention of such an addon invoking policy.

If addons are run in isolation then I could bundle my own addon dependencies, removing the need wrap standard python packages (a chore).

I'm running Kodi 19.3 (19.3.0) Git:20211024-49a04cd6a7 on Ubuntu 20.04

(* apart from the fact that sys.path also contains  .local/lib/python3.8/site-packages and /usr/local/lib/python3.8/dist-packages and so on, so there's opportunity for some quirk behaviour there perhaps)
Addons don't share the same namespace, so on that count you'd be fine.  But if you submit an addon to the main repo with a dependency bundled, it'll get denied with a note that you need to wrap the dependency and submit it separately.  If addons include their own dependencies in the bundle, you could end up with a user who has downloaded 9 different versions of the same package.
Quote:If addons include their own dependencies in the bundle, you could end up with a user who has downloaded 9 different versions of the same package.

Doesn't the same thing happen already even when packages are wrapped for kodi? One addon will have <import addon="script.module.popularpackage" version="1.2.3" /> another has <import addon="script.module.popularpackage" version="2.3.4" />

But yes I take the point that if you have 9 addons using script.module.popularpackage==1.2.3 you would have 9 directories containing exactly the same code.

It might be cool if addon developers could specify their requirements in a more pythonic way, without the chore of having to wrap other peoples code for kodi (which feels icky to me).
(2022-04-01, 13:31)powlo Wrote: [ -> ]
Quote:If addons include their own dependencies in the bundle, you could end up with a user who has downloaded 9 different versions of the same package.

Doesn't the same thing happen already even when packages are wrapped for kodi? One addon will have <import addon="script.module.popularpackage" version="1.2.3" /> another has <import addon="script.module.popularpackage" version="2.3.4" />
The version in the import refers to a minimum version required, not a specific version.  This is used mostly if you are importing a package and know you need at least a certain version because of capabilities or syntax or something like that.  The repo for each Kodi version only has one version of the bundle.
Ah I see. I guess because the dependency sphere is so small, breaking changes are a rarity. But it's possibly a vicious circle; if an author does introduce breaking changes, then all the dependants would get angry and stop using it. But making a package that caters to all and everything is hard, so nobody will bother.