Plugin development: managing Python dependencies

Posted on
Thu May 12, 2016 6:17 am
OjisanSeiuchi offline
User avatar
Posts: 20
Joined: May 06, 2016
Location: London, ON, CANADA

Plugin development: managing Python dependencies

In the process of working on a new plugin, I've bumped up against the difficulty of Python dependencies,

Is there a canonical method for specifying dependencies? For example, I'd like to use to xmltodict to handle XML returned from a web service. While this module is installed on a system-wide basis, there is no guarantee that would be the case for an end-user. There seems to be no 'requirements.txt' capability or the like. How are others approaching this? Many of the existing modules that I've browsed seem to just avoid esoteric dependencies.

Posted on
Thu May 12, 2016 7:26 am
DaveL17 offline
User avatar
Posts: 6759
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Plugin development: managing Python dependencies

OjisanSeiuchi wrote:
In the process of working on a new plugin, I've bumped up against the difficulty of Python dependencies,

Is there a canonical method for specifying dependencies? For example, I'd like to use to xmltodict to handle XML returned from a web service. While this module is installed on a system-wide basis, there is no guarantee that would be the case for an end-user. There seems to be no 'requirements.txt' capability or the like. How are others approaching this? Many of the existing modules that I've browsed seem to just avoid esoteric dependencies.

One way to do it is to place the dependent modules within the plugin itself--within the Server Plugin folder. I do this with a couple of my plugins and use the indigoPluginUpdateChecker module (developed by an Indigo developer) in all of my plugins that are published publicly. Other plugins require the user to install external dependent modules separately. I prefer the former.

The biggest issue that I can see is Python compatibility. Your included modules must be compatible with the Python versions likely to be in service and/or include trap(s) to catch exceptions when that's not the case. Even if it's a simple, "This plugin requires Python 2.6" kind of trap.

Code: Select all
try:
    import foo
except ImportError, e:
    indigo.server.log("Error: %s" % e, isError=True)

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu May 12, 2016 9:20 am
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Plugin development: managing Python dependencies

Python has some built-in capabilities to handle dependent packages (setuptools, pip, etc). However, in terms of Indigo Plugins, we have not done any integration. Plugins don't directly run in a python interpreter but rather they run in a Mac OS X executable which wraps all the communication with the Indigo server around a python instance that it manages. So, to integrate Python dependencies (as in identify and install them) would require non-trivial work for us. It's something we'd like to do eventually, but it's not in any current plans.

What most plugin developers do is to embed the modules in the plugin itself (assuming the module's licensing permits). If the module/library is pure Python, then that's a very simple task (and it looks like xmltodict is both all Python and has a license that would allow you to include it) - just put the python file(s) (or module directory) at the same level as plugin.py.

It gets harder when it's Cython or C or anything that requires compiling. Now that Indigo no longer supports PPC Macs, at least you don't have to figure out how to compile fat binaries, so moving a module that has compiled code might also work (maybe).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat May 14, 2016 4:58 am
OjisanSeiuchi offline
User avatar
Posts: 20
Joined: May 06, 2016
Location: London, ON, CANADA

Re: Plugin development: managing Python dependencies

Thank you both. This is excellent. I'll package dependencies where permissible by the vendor's license.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 8 guests