Class confinement for Python snaps
barry at ubuntu.com
Fri Mar 10 15:14:04 UTC 2017
I'm converting ubuntu-image from a devmode snap to a classic snap, but I'm
running into some problems. ubuntu-image is a Python 3 application, and I'm
using snapcraft 2.27.1+17.4 on Zesty.
The first problem I'm having is I think directly related to LP: #1670749. I
ended up reopening this because while Corey found that he ultimately only
needed to set the $PATH environment variable, I still also had to $PYTHONPATH
and I had to make sure the snap versions come before the system versions:
This gets me pretty close, but then I run into my second problem which is that
we depend on pyparted, in Ubuntu as python3-pyparted. This package contains
both Python source and an extension module and to further complicate things,
its tarball is only released on GitHub, not on PyPI, so adding it to
python-packages in the ubuntu-image part doesn't work. Further, it doesn't
help to add python3-parted to stage-packages because it appears that with
classic confinement, none of those Python packages end up in the snap.
I tried to add a scriptlet to copy things over, but that also fails. E.g.:
cp -a ../install/usr/lib/python3/dist-packages/parted ../stage/lib/python3.5/site-packages
cp -a ../install/usr/lib/python3/dist-packages/pyparted-*.egg-info ../stage/lib/python3.5/site-packages
cp: cannot create directory '../stage/lib/python3.5/site-packages': No such file or directory
cp: cannot create regular file '../stage/lib/python3.5/site-packages': No such file or directory
Command '['/bin/sh', '/tmp/tmpfeczxcco', '/tmp/tmp2__1bdau']' returned non-zero exit status 1
This happens because ./stage/ is empty at the point that the install scriptlet
I can think of a couple of approaches that might be useful.
* Allow python-packages specifications to pip install from repositories other
* Allow python-packages to come from git and/or https URLs (I tried this and
it didn't work).
* Integrate dirtbike and wheels into the Python parts building phases.
(dirtbike is a tool that Debian/Ubuntu uses in very limited cases to turn
installed distro packages into .whl files.)
* Provide a scriptlet hook that runs after the normal part installation step.
My current WIP snapcraft.yaml file is here:
I'm going to keep trying a few things, but any suggestions are welcome. I'm
happy to file bugs as needed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 801 bytes
Desc: OpenPGP digital signature
More information about the Snapcraft