Multiple Add-ons with a common utility library

I am looking into splitting up a huge multi purpose Add-on into a set of smaller more focused Add-ons. However there is a number of utility functions (collected in a python file utils.py) that we use all over the place. So, when we split up the Add-on then we have to make utils.py available on each of the new Add-ons as well.

It appears to me that the most reliable method is to not install one common module, but just install a separate copy of it into each of the splitted Add-ons. This would also make it possible that a user can treat the Add-ons completely independent from each other.

However, from a user point of view there is a Basis Add-on and a couple of task oriented “sub” Add-ons. So it looks like a reasonable way might be to force the user to always install the Basis Addon first, and reject any installation of a “sub” Add-on if either the Basis Addon is not installed or has an incompatible version.

Are there any other more elegant, or more appropriate options ?

Your solution sounds ok to me.

Another one would be to install your utils.py in one of the shared folders that can be found in blender/2.8/python , lib in particular

Unfortunately Blender python does not seem to come with Pypi (standard part of cpython 3.5 which is the official version of blender 2.79 and most popular by far python package manager) but its relatively easy to fetch source code from github or other online repos via request module as is illustrated in this example

https://gist.github.com/kilon/41b5277ab6a7fa06481ba0345249a40c

In my example I dont actually save the source code to a file because I use it just to check the version. it something I was playing with for implementing my own automatic updates mechanism. I think however you get the idea.

So this approach could be used to have a single addon and let your user decide what feature he wants installed. After he makes the choice the addon will automatically install those features distributed as libraries possible in seperate online repos or same repo but different branches.

Of course automatic updates and installs can be a security concern and you have to make sure that your code is not easy to be exploited.

So far, having to deal with a similar problem I came up with this solution:

use get-pip.py with blender python to provide setuptools/pip
use python -m pip install to make the wanted it available in Blender.
for modules not available to install , I’m simply using blender python to run the setup.py install command.

My2c
L.