This is a python based snap currently working with strict confinement.
It provides optional access to several other binaries that are then called from within python. These cannot be packaged with the snap unfortunately as they use separate academic licenses meaning I can’t distribute them myself. For example this software: http://www.cbs.dtu.dk/cgi-bin/nph-sw_request?netMHCpan
As I understand it classic confinement is the only way to allow the snap to access such external tools. Is this correct?
Does epitopepredict function without the other binaries present?
Yes it will work without them. These are optional tools but potential users would expect them to be available. Other tools are in the form of python packages that are all inside the snap and not a problem. I thought perhaps if there was a way to instruct the user to put these external programs in their home folder they might be made accessible with an alias or command added to the path? I would prefer not to use classic if at all possible.
Typically the snap publisher would ship the binaries it needs with the snap so that all users of the snap have what is expected. Put another way, if your snap doesn’t ship them, (at least some) users of your snap will be missing functionality that, as you say, they expect. This is true of whether the snap is classic or not (with classic, they may not have the tools on their system).
That said, I understand your (valid) concern with licensing and agree it would be be best to avoid classic entirely. If for a moment we consider the situation where the snap is classic but the tools are not installed, it seems for the best usability your snap would want to detect that and instruct the user to install the tools in the locations the snap expects. AFAICS, this isn’t significantly different from strict mode-- the snap can detect that the extra tools aren’t needed and then tell the user what to do.
Assuming the tools need to be found in PATH, I suggest exploring an approach along the lines of having the snap set its PATH to
PATH=$PATH:$SNAP_USER_COMMON/bin and prompt when the tools directory doesn’t exist. Eg:
if [ ! -d "$optpath" ]; then
echo "Created '$optpath'. Please install any additional tools here."
Does an approach like this address your need for classic?
Thanks, this appears to be the right approach. It works with a simple example at least. Though it would be a bit more convenient if the path to the users original home directory was also exposed to the developer (see Accessing home directory with home interface). Just that slight bit more confusing asking people to put a tool in /home/user/snap/testapp/common/.
Also it seems that if the snap is removed and then re-installed $SNAP_USER_COMMON is cleared, so it would remove whatever someone placed there. Is that correct.
Anyway in python you can do something like this:
toolspath = os.environ['SNAP_USER_COMMON']
#or use actual home
#toolspath = os.path.join('/home', os.environ['USER'])
binpath = os.path.join(toolspath, 'bin')
print ('you should install external tools in %s' %toolspath)
os.environ["PATH"] += os.pathsep + binpath