I posted about these snaps a while back on the mailing list, but thought I’d see if I could get some more exposure on this forum.
I’ve put together some snaps of the Python language runtime intended to be useful as both an ad-hoc interpreter and as a runtime for other snaps. You can install it with the following command:
snap install --edge --classic python36-jamesh
This will install the package using classic confinement, which is probably what you expect if you plan to use it interactively. If you’re only using it as a runtime for other snaps, you can install it without --classic
. You can run the interpreter as python36-jamesh.python3
, or add an alias for the more common name:
snap alias python36-jamesh python3
or if you have other versions of Python 3 on the system, perhaps:
snap alias python36-jamesh python3.6
The package comes with pip3
(which can also be aliased to the common short name), which can install additional packages if invoked with the --user
option. The packages will end up installed in ~/snap/python36-jamesh/common/
.
As mentioned earlier, the package is designed so it can share the Python runtime to other snaps via the content interface, so they don’t have to ship their own copy of the runtime. Here is a sample snapcraft project that demonstrates this here:
Once the package is installed, it will be necessary to connect the runtime:
snap connect hello-world:python3 python36-jamesh:python3
This will cause the runtime to be bind mounted into the application’s $SNAP
directory, allowing it to find the interpreter. Note that it will only see the standard library: anything extra installed via pip3
won’t be visible. This is similar to the isolation you get using virtualenv
.
Python 2 snap
Since the Python 3.6 snap seems to be working out okay, I adapted the packaging to produce a second snap of Python 2.7. It can be installed with:
snap install --edge --classic python2-jamesh
It supports all the same features as the 3.6 snap (aliases, content sharing to other snaps, etc), but I haven’t done as much testing on it.
I welcome feedback about either of these packages.