Need snapcraft.yaml review

Hi!

I have a project which is packaged as a snap. I need to get the snapcraft.yaml in that project reviewed, mostly I have a few questions that I have added in that file.

question 1: Can I access RasbperryPi GPIO in a confined snap ?
reference: https://github.com/om26er/wamp-pigpio/blob/ce3503a745ac9924e7306a9dc7243a2e56f56424/snap/snapcraft.yaml#L8

question 2: I had to export PYTHONPATH in the snap environment for my code to actually work, am I doing something wrong ?
reference: https://github.com/om26er/wamp-pigpio/blob/ce3503a745ac9924e7306a9dc7243a2e56f56424/snap/snapcraft.yaml#L18

question 3: How to have a configure hook without a plug ?
reference: https://github.com/om26er/wamp-pigpio/blob/ce3503a745ac9924e7306a9dc7243a2e56f56424/snap/snapcraft.yaml#L41

Some quick feedback:

  1. Yes, there is a gpio interface, so stricts snaps can use those
  2. Potentially, yes. The python part probably does that automatically, though.
  3. In theory you only need to plug into the network if you actually use the network. What failure are you observing when the plug is missing?

In all images except for the stable channel we have:

ogra@pi3:~$ snap interfaces|grep gpio
pi3:bcm-gpio-0            -
pi3:bcm-gpio-1            -
pi3:bcm-gpio-10           -
pi3:bcm-gpio-11           -
pi3:bcm-gpio-12           -
pi3:bcm-gpio-13           -
pi3:bcm-gpio-14           -
pi3:bcm-gpio-15           -
pi3:bcm-gpio-16           -
pi3:bcm-gpio-17           -
pi3:bcm-gpio-18           -
pi3:bcm-gpio-19           -
pi3:bcm-gpio-2            -
pi3:bcm-gpio-20           -
pi3:bcm-gpio-21           -
pi3:bcm-gpio-22           -
pi3:bcm-gpio-23           -
pi3:bcm-gpio-24           -
pi3:bcm-gpio-25           -
pi3:bcm-gpio-26           -
pi3:bcm-gpio-27           -
pi3:bcm-gpio-3            -
pi3:bcm-gpio-4            -
pi3:bcm-gpio-5            -
pi3:bcm-gpio-6            -
pi3:bcm-gpio-7            -
pi3:bcm-gpio-8            -
pi3:bcm-gpio-9            -

This will land in stable once gadget updates are properly implemented. For now use a beta, edge or candidate image to access RasbperryPi GPIO interfaces. The naming of the interfaces follows the mapping of https://pinout.xyz/#

On 2, PYTHONPATH should not be needed, it is dynamically assessed from the python being called in shebang which in your case it is hardcoded to #!/usr/bin/python3 and since the runner part is not driven by the python plugin it does not get adapted appropriately.

That said, that part shouldn’t really be needed if in setup.py you used either a scripts entry or moved to console_scripts/entry_points.

Seems that was it, I had to change my setup.py and I was able to remove the export of PYTHONPATH.

Is that interface also available on Raspberrry Pi 2 ? I just flashed the candidate image from http://cdimage.ubuntu.com/ubuntu-core/16/candidate/current/ then ran snap refresh but still the interfaces that I see are:

om26er@localhost:~$ snap interfaces
Slot                      Plug
:account-control          -
:alsa                     -
:autopilot-introspection  -
:bluetooth-control        -
:browser-support          -
:camera                   -
:classic-support          -
:core-support             core:core-support-plug
:dcdbas-control           -
:docker-support           -
:firewall-control         -
:framebuffer              -
:fuse-support             -
:hardware-observe         -
:hardware-random-control  -
:hardware-random-observe  -
:home                     -
:io-ports-control         -
:joystick                 -
:kernel-module-control    -
:kubernetes-support       -
:log-observe              -
:lxd-support              -
:mount-observe            -
:netlink-audit            -
:netlink-connector        -
:network                  -
:network-bind             -
:network-control          -
:network-observe          -
:network-setup-control    -
:network-setup-observe    -
:opengl                   -
:openvswitch-support      -
:physical-memory-control  -
:physical-memory-observe  -
:ppp                      -
:process-control          -
:raw-usb                  -
:removable-media          -
:shutdown                 -
:snapd-control            -
:system-observe           -
:system-trace             -
:time-control             -
:timeserver-control       -
:timezone-control         -
:tpm                      -
:uhid                     -

try http://cdimage.ubuntu.com/ubuntu-core/16/edge/current/ or http://people.canonical.com/~ogra/snappy/all-snaps/daily/current/