Question about python modules and how to make them work [script.module.*]
#1
Update and explanations:
  1. The addons are mildly isolated, so dependencies must be explicitly declared. It is not necessary to reinstall the addon if you're developing, updating the addon.xml is enough if you already manually installed the dependency.
  2. The addon.xml/lib structure is not enough for some libraries. In the cases of soupsieve, or mechanize, you actually need the named subdirectory, so ./lib/soupsieve/* and ./lib/mechanize/* (hindsight 20/20, obvious in retrospect, read about python modules & packages for more info).
  3. In the example case at hand with BeautifulSoup4, there is already a pre-made 4.6.3 version on the repo-scripts matrix branch compatible with Python 3.
Hope this helps.


Original posts below

I was testing the latest nightly for Py3 addon compatibility and I incurred in a problem with BeautifulSoup where it required/complained about the need of the module soupsieve. I also had problems with other modules, but let's stick with that for a moment.

I took the module, created the directory structure, the appropriate addon.xml, zipped it together and installed it in Kodi. So far so good. Restarted for good measure, the script is reported as loaded:

log:
NOTICE: ADDON: script.module.soupsieve v1.9.4 installed

Even though it's reported as installed, when bs4 checks for the module it says it's not available, and if I add it manually to my addon it also says that the module is not available:

log:
ImportError: No module named soupsieve

Am I doing something wrong? Is it necessary for the module to be published in the official kodi repos to be used by other modules? I've been trying to find out, sieved through some 25 pages of forum searches, but I couldn't find an answer.
Reply
#2
@mods, I'm afraid I posted this in the Addon-on Support instead of the Addon Development forum, feel free to move it where appropriate.
Reply
#3
we have bs4 4.6.3 in our repo, which doesn't need soupsieve.

 generally speaking, if your addon needs a script.module.*, you'll need to add it as a requirement in your addon.xml file.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#4
(2019-10-15, 19:33)ronie Wrote: we have bs4 4.6.3 in our repo, which doesn't need soupsieve.
Must have missed it, maybe it was the one in the migration branch I read somewhere in these threads. I'll take a look back at it.
(2019-10-15, 19:33)ronie Wrote: generally speaking, if your addon needs a script.module.*, you'll need to add it as a requirement in your addon.xml file.
Just to clarify, is this an issue of inner working/install?

I'm starting with the addon and the the script.module.soupsieve installed. I then updated the addon.xml to notify the import of soupsieve but that doesn't work either. Is the parsing done during install only, or did I built the script.module.soupsieve wrong? While further analyzing the dependencies Kodi is ignoring the inclusion of soupsieve so that might be the answer, I'll have to try reinstalling the addon and see if that fixes the issue.
Reply
#5
Thanks for pointing me in the right direction @ronie, I understand how everything works now. I've updated the original post in case it might help someone else in my position.
Reply
#6
(2019-10-15, 18:09)Varstahl Wrote: The addon.xml/lib structure is not enough for some libraries. In the cases of soupsieve, or mechanize, you actually need the named subdirectory, so ./lib/soupsieve/* and ./lib/mechanize/*

I'd recommend to read about Python modules and packages.
Reply

Logout Mark Read Team Forum Stats Members Help
Question about python modules and how to make them work [script.module.*]0