Next step in creating a Snap

I’ve done this tutorial:

tutorials.ubuntu.com – 31 Aug 161
Create your first snap | Ubuntu tutorials

We are going to use snapcraft to walk you through the creation of your first snap and main snapcraft concepts.

I’ve now edited the .yaml file to fit my app. It fails with:

subprocess.CalledProcessError: Command ‘[’/bin/sh’, ‘/tmp/tmp6hqswmw3’, ‘autoreconf’, ‘-i’]’ returned non-zero exit status 1.

I imagine this is because I’ve no idea what I need to do to make the app install, except that I probably need to do something at the point where plugin: appears

parts:
  myapp:
    source: /home/me/myapp.tar.xz
    plugin: autotools #?????

All the app consists of are a Glade GUI, two Python scripts, a data file and 3 images. It depends on Python3 and another application. Is it something to do with ‘make’ or is that a compiler? I need a tutorial on this really, can you recommend one?

If your app is python, then you likely need the python plugin which uses a package’s setup.py file in combo with Python’s setuptools module. Some python packages don’t include such a file which means they’ll not work with the python plugin as easily (or not at all, I am not sure), so you’ll possibly need to use the nil plugin and script the build manually.

If your package uses setuptools, then it’s easier:

parts:
  my-part:
    source: /home/me/myapp.tar.xz
    plugin: python
    python-version: 3
    requirements: requirements.txt # if you have such a file, otherwise
    python-packages:
    - pypack1
    - ...

Reference for the available python plugin options are at https://docs.snapcraft.io/reference/plugins/python and all the available plugins are at https://docs.snapcraft.io/reference/plugins/

If your package uses setuptools, then it’s easier:

I’ve tried editing ‘parts:’ as you suggest, it errors due to my lack of understanding of what’s required.

Reference for the available python plugin options are at:

I think that is a step too far for me. I need a much more basic introduction - a simple explanation of what needs doing first. My app only needs copying in to a suitable directory, so what needs doing must be stuff to satisfy the sytem that I don’t know about.

For simply copying into the snap you can use the dump plugin which will take the directory specified in source and put it directly into your snap. Bear in mind that you will need to add stage-packages for any Ubuntu repository packages containing libraries, executables and other things that your app might need. One stage-package you’ll need is python or python3 itself:

parts:
  my-app:
    source: . # the directory in which you executed `snapcraft`
    plugin: dump
    stage-packages:
    - python3
    - python3-yaml # just an example to show multiple packages in use

Stage packages are the names of the package as listed in the Ubuntu Repository, which you can see with packages.ubuntu.com, apt search, apt-file (if you have it installed, which allows you to search by installed files’ names e.g. /usr/bin/python3), and dpkg -l (shows you your currently-installed packages).

I’ve created a test yaml:

name: testit # you probably want to 'snapcraft register ’
version: ‘0.1’ # just for humans, typically ‘1.2+git’ or ‘1.3.2’
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
This is my-snap’s description.
grade: devel # must be ‘stable’ to release into candidate/stable channels
confinement: devmode # use ‘strict’ once you have the right plugs and slots

apps:
testit:
command: bin/testit

parts:
testit:
source: /home/chris/testit/mine
plugin: dump
stage-packages:
- python3
- geda # some random package I don’t need, just to test the process.

and a very simple Python program:

#! /usr/bin/python3

print (“testit is running”)

But it fails with this error message:

.
.
.
File “/usr/lib/python3/dist-packages/snapcraft/internal/meta.py”, line 365, in _wrap_exe
with open(exepath, ‘rb’) as exefile:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/chris/testit/prime/bin/testit’

There is no /home/chris/testit/prime/bin. Is there a tutorial anywhere that would explain what I need to do to make this work?

That error means that the file listed in command: was not there so the snap won’t have worked if it was finalised and you had installed it so snapcraft gave the error to let you know.

What does your source tree look like? i.e. can you list all the paths within /home/chris/testit please? The directories parts, stage and prime can be ignored for now if they exist.

I expect that you have a single python file as your starting point for your application, so your command could read like this:

apps:
  testit:
    command: python3 testit.py

I purposely include the python3 to ensure that the system knows what to do with testit.py as the “shebang” line (the line at the top starting with #! will be incorrect for snaps if it has one.

Yey! It’s Snapped. I’m encouraged to continue…

The next stage fails with

chris@Dell-DXP051:~/testit$ testit
python3: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25’ not found (required by python3)

I would have thought that everything Python needed would have been included by having

stage-packages:

  • python3

It seems not, and » Ubuntu » Packages » artful » python doesn’t contain libc.so or GLIBC. Have I guessed incorrectly what it wrong?

LibC is provided by the Core snap that virtually every snap uses as it’s base. The version of libc in the core snap is older than the version the python build you used is compiled against so python complains and dies. You really need to be building snaps using an LXD container with snapcraft cleanbuild to ensure you get the right environment for your build.

To get lxd running:

sudo snap install lxd
sudo lxd init # accept all the default settings
sudo adduser your-username lxd

You will need to logout and back in for the group assignment to take hold.

Have done that plus snapcraft clean, snapcraft, snapcraft install, snap list

chris@Dell-DXP051:~/testit$ snap list
Name Version Rev Developer Notes
classic 16.04 26 canonical devmode
core 16-2.30 3887 canonical core
hello 2.10 x6 -
lxd 2.21 5522 canonical -
testit 0.1 x2 devmode

chris@Dell-DXP051:~/testit$ testit
python3: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25’ not found (required by python3)

So it doesn’t seem to make any difference.

this should have been:

snapcraft clean, snapcraft cleanbuild, snap install …

I’m doing that and snapcraft cleanbuild got:

subprocess.CalledProcessError: Command ‘[‘lxc’, ‘exec’, ‘local:snapcraft-overly-square-tahr’, ‘–’, ‘sh’, ‘-c’, ‘cd /root/build_testit; snapcraft snap --output testit_0.1_amd64.snap’]’ returned non-zero exit status 1.

I’m wondering whether I need to login to lxd or something. I’m only following instructions with that as I don’t know anything about it.

There should be more to that error message. Please go further back in the logs to find more of the message. There should be some output from python (snapcraft) which includes a backtrace. The backtrace itself isn’t too helpful but within it is the actual important message which will explain the true situation.

I just cut out the last sentence. The whole lot is here:

chris@Dell-DXP051:~/testit$ snapcraft cleanbuild
Creating snapcraft-oddly-wired-bobcat
Starting snapcraft-oddly-wired-bobcat
Setting up container with project assets
./
./parts/
./snap/
./snap/snapcraft.yaml
./snap/.snapcraft/
./snap/.snapcraft/state
./mine/
./mine/testit.py
./output.txt
Waiting for a network connection…
Network connection established
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [7532 kB]
Get:6 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [435 kB]
Get:7 http://security.ubuntu.com/ubuntu xenial-security/main Translation-en [189 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [200 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [102 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3208 B]
Get:11 http://security.ubuntu.com/ubuntu xenial-security/multiverse Translation-en [1408 B]
Get:12 http://archive.ubuntu.com/ubuntu xenial/universe Translation-en [4354 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [144 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial/multiverse Translation-en [106 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [710 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [295 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [580 kB]
Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [234 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [16.2 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse Translation-en [8052 B]
Get:21 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [4840 B]
Get:22 http://archive.ubuntu.com/ubuntu xenial-backports/main Translation-en [3220 B]
Get:23 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [6628 B]
Get:24 http://archive.ubuntu.com/ubuntu xenial-backports/universe Translation-en [3768 B]
Fetched 15.2 MB in 9s (1570 kB/s)
Reading package lists… Done
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following package was automatically installed and is no longer required:
libfreetype6
Use ‘apt autoremove’ to remove it.
The following additional packages will be installed:
libarchive13 libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libsodium18 libxslt1.1 python python-cffi-backend python-chardet python-cryptography python-enum34 python-idna
python-ipaddress python-minimal python-ndg-httpsclient python-openssl python-pkg-resources python-pyasn1 python-requests python-six python-urllib3 python2.7 python2.7-minimal
python3-bs4 python3-click python3-colorama python3-html5lib python3-jsonschema python3-libarchive-c python3-libnacl python3-lxml python3-magic python3-petname python3-progressbar
python3-pymacaroons python3-pysha3 python3-requests-toolbelt python3-requests-unixsocket python3-simplejson python3-tabulate python3-xdg xdelta3
Suggested packages:
lrzip python-doc python-tk python-cryptography-doc python-cryptography-vectors python-enum34-doc python-openssl-doc python-openssl-dbg python-setuptools doc-base python-ntlm
python2.7-doc binutils binfmt-support python3-genshi python3-lxml-dbg python-lxml-doc python-pysha3-doc
The following NEW packages will be installed:
libarchive13 libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libsodium18 libxslt1.1 python python-cffi-backend python-chardet python-cryptography python-enum34 python-idna
python-ipaddress python-minimal python-ndg-httpsclient python-openssl python-pkg-resources python-pyasn1 python-requests python-six python-urllib3 python2.7 python2.7-minimal
python3-bs4 python3-click python3-colorama python3-html5lib python3-jsonschema python3-libarchive-c python3-libnacl python3-lxml python3-magic python3-petname python3-progressbar
python3-pymacaroons python3-pysha3 python3-requests-toolbelt python3-requests-unixsocket python3-simplejson python3-tabulate python3-xdg snapcraft xdelta3
0 upgraded, 43 newly installed, 0 to remove and 4 not upgraded.
Need to get 6776 kB of archives.
After this operation, 29.8 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-minimal amd64 2.7.12-1ubuntu0~16.04.3 [340 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7-minimal amd64 2.7.12-1ubuntu0~16.04.3 [1261 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-minimal amd64 2.7.11-1 [28.2 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpython2.7-stdlib amd64 2.7.12-1ubuntu0~16.04.3 [1880 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python2.7 amd64 2.7.12-1ubuntu0~16.04.3 [224 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 libpython-stdlib amd64 2.7.11-1 [7656 B]
Get:7 http://archive.ubuntu.com/ubuntu xenial/main amd64 python amd64 2.7.11-1 [137 kB]
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libarchive13 amd64 3.1.2-11ubuntu0.16.04.3 [262 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libsodium18 amd64 1.0.8-5 [144 kB]
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libxslt1.1 amd64 1.1.28-2.1ubuntu0.1 [145 kB]
Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-cffi-backend amd64 1.5.2-1ubuntu1 [58.1 kB]
Get:12 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-pkg-resources all 20.7.0-1 [108 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-chardet all 2.3.0-2 [96.3 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-enum34 all 1.1.2-1 [35.8 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-idna all 2.0-3 [35.1 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-ipaddress all 1.0.16-1 [18.0 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-pyasn1 all 0.1.9-1 [45.1 kB]
Get:18 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-six all 1.10.0-3 [10.9 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python-cryptography amd64 1.2.3-1ubuntu0.1 [199 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-openssl all 0.15.1-2build1 [84.1 kB]
Get:21 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-ndg-httpsclient all 0.4.0-3 [25.1 kB]
Get:22 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python-urllib3 all 1.13.1-2ubuntu0.16.04.1 [57.2 kB]
Get:23 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-requests all 2.9.1-3 [55.6 kB]
Get:24 http://archive.ubuntu.com/ubuntu xenial/main amd64 python3-bs4 all 4.4.1-1 [64.1 kB]
Get:25 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-colorama all 0.3.7-1 [14.9 kB]
Get:26 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-click all 6.2-2ubuntu1 [56.2 kB]
Get:27 http://archive.ubuntu.com/ubuntu xenial/main amd64 python3-html5lib all 0.999-4 [79.3 kB]
Get:28 http://archive.ubuntu.com/ubuntu xenial/main amd64 python3-jsonschema all 2.5.1-4 [30.3 kB]
Get:29 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python3-libnacl all 1.4.5-0ubuntu1 [9576 B]
Get:30 http://archive.ubuntu.com/ubuntu xenial/main amd64 python3-lxml amd64 3.5.0-1build1 [811 kB]
Get:31 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python3-petname all 2.0-0ubuntu1~16.04 [10.7 kB]
Get:32 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-progressbar all 2.3-2 [9570 B]
Get:33 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python3-pymacaroons all 0.9.2-0ubuntu1 [9942 B]
Get:34 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python3-pysha3 amd64 1.0.0-0ubuntu1~ubuntu16.04.1 [39.6 kB]
Get:35 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-requests-toolbelt all 0.6.0-2 [31.6 kB]
Get:36 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-requests-unixsocket all 0.1.5-0ubuntu4 [6560 B]
Get:37 http://archive.ubuntu.com/ubuntu xenial/main amd64 python3-simplejson amd64 3.8.1-1ubuntu2 [48.6 kB]
Get:38 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-tabulate all 0.7.5-1 [23.8 kB]
Get:39 http://archive.ubuntu.com/ubuntu xenial/main amd64 python3-xdg all 0.25-4 [31.5 kB]
Get:40 http://archive.ubuntu.com/ubuntu xenial/universe amd64 xdelta3 amd64 3.0.8-dfsg-1ubuntu2 [67.1 kB]
Get:41 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python3-libarchive-c all 2.1-3 [9546 B]
Get:42 http://archive.ubuntu.com/ubuntu xenial/main amd64 python3-magic all 1:5.25-2ubuntu1 [5438 B]
Get:43 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 snapcraft all 2.35 [160 kB]
Fetched 6776 kB in 2s (2299 kB/s)
Extracting templates from packages: 100%
Selecting previously unselected package libpython2.7-minimal:amd64.
(Reading database … 25537 files and directories currently installed.)
Preparing to unpack …/libpython2.7-minimal_2.7.12-1ubuntu0~16.04.3_amd64.deb …
Unpacking libpython2.7-minimal:amd64 (2.7.12-1ubuntu0~16.04.3) …
Selecting previously unselected package python2.7-minimal.
Preparing to unpack …/python2.7-minimal_2.7.12-1ubuntu0~16.04.3_amd64.deb …
Unpacking python2.7-minimal (2.7.12-1ubuntu0~16.04.3) …
Selecting previously unselected package python-minimal.
Preparing to unpack …/python-minimal_2.7.11-1_amd64.deb …
Unpacking python-minimal (2.7.11-1) …
Selecting previously unselected package libpython2.7-stdlib:amd64.
Preparing to unpack …/libpython2.7-stdlib_2.7.12-1ubuntu0~16.04.3_amd64.deb …
Unpacking libpython2.7-stdlib:amd64 (2.7.12-1ubuntu0~16.04.3) …
Selecting previously unselected package python2.7.
Preparing to unpack …/python2.7_2.7.12-1ubuntu0~16.04.3_amd64.deb …
Unpacking python2.7 (2.7.12-1ubuntu0~16.04.3) …
Selecting previously unselected package libpython-stdlib:amd64.
Preparing to unpack …/libpython-stdlib_2.7.11-1_amd64.deb …
Unpacking libpython-stdlib:amd64 (2.7.11-1) …
Processing triggers for man-db (2.7.5-1) …
Processing triggers for mime-support (3.59ubuntu1) …
Setting up libpython2.7-minimal:amd64 (2.7.12-1ubuntu0~16.04.3) …
Setting up python2.7-minimal (2.7.12-1ubuntu0~16.04.3) …
Linking and byte-compiling packages for runtime python2.7…
Setting up python-minimal (2.7.11-1) …
Selecting previously unselected package python.
(Reading database … 26283 files and directories currently installed.)
Preparing to unpack …/python_2.7.11-1_amd64.deb …
Unpacking python (2.7.11-1) …
Selecting previously unselected package libarchive13:amd64.
Preparing to unpack …/libarchive13_3.1.2-11ubuntu0.16.04.3_amd64.deb …
Unpacking libarchive13:amd64 (3.1.2-11ubuntu0.16.04.3) …
Selecting previously unselected package libsodium18:amd64.
Preparing to unpack …/libsodium18_1.0.8-5_amd64.deb …
Unpacking libsodium18:amd64 (1.0.8-5) …
Selecting previously unselected package libxslt1.1:amd64.
Preparing to unpack …/libxslt1.1_1.1.28-2.1ubuntu0.1_amd64.deb …
Unpacking libxslt1.1:amd64 (1.1.28-2.1ubuntu0.1) …
Selecting previously unselected package python-cffi-backend.
Preparing to unpack …/python-cffi-backend_1.5.2-1ubuntu1_amd64.deb …
Unpacking python-cffi-backend (1.5.2-1ubuntu1) …
Selecting previously unselected package python-pkg-resources.
Preparing to unpack …/python-pkg-resources_20.7.0-1_all.deb …
Unpacking python-pkg-resources (20.7.0-1) …
Selecting previously unselected package python-chardet.
Preparing to unpack …/python-chardet_2.3.0-2_all.deb …
Unpacking python-chardet (2.3.0-2) …
Selecting previously unselected package python-enum34.
Preparing to unpack …/python-enum34_1.1.2-1_all.deb …
Unpacking python-enum34 (1.1.2-1) …
Selecting previously unselected package python-idna.
Preparing to unpack …/python-idna_2.0-3_all.deb …
Unpacking python-idna (2.0-3) …
Selecting previously unselected package python-ipaddress.
Preparing to unpack …/python-ipaddress_1.0.16-1_all.deb …
Unpacking python-ipaddress (1.0.16-1) …
Selecting previously unselected package python-pyasn1.
Preparing to unpack …/python-pyasn1_0.1.9-1_all.deb …
Unpacking python-pyasn1 (0.1.9-1) …
Selecting previously unselected package python-six.
Preparing to unpack …/python-six_1.10.0-3_all.deb …
Unpacking python-six (1.10.0-3) …
Selecting previously unselected package python-cryptography.
Preparing to unpack …/python-cryptography_1.2.3-1ubuntu0.1_amd64.deb …
Unpacking python-cryptography (1.2.3-1ubuntu0.1) …
Selecting previously unselected package python-openssl.
Preparing to unpack …/python-openssl_0.15.1-2build1_all.deb …
Unpacking python-openssl (0.15.1-2build1) …
Selecting previously unselected package python-ndg-httpsclient.
Preparing to unpack …/python-ndg-httpsclient_0.4.0-3_all.deb …
Unpacking python-ndg-httpsclient (0.4.0-3) …
Selecting previously unselected package python-urllib3.
Preparing to unpack …/python-urllib3_1.13.1-2ubuntu0.16.04.1_all.deb …
Unpacking python-urllib3 (1.13.1-2ubuntu0.16.04.1) …
Selecting previously unselected package python-requests.
Preparing to unpack …/python-requests_2.9.1-3_all.deb …
Unpacking python-requests (2.9.1-3) …
Selecting previously unselected package python3-bs4.
Preparing to unpack …/python3-bs4_4.4.1-1_all.deb …
Unpacking python3-bs4 (4.4.1-1) …
Selecting previously unselected package python3-colorama.
Preparing to unpack …/python3-colorama_0.3.7-1_all.deb …
Unpacking python3-colorama (0.3.7-1) …
Selecting previously unselected package python3-click.
Preparing to unpack …/python3-click_6.2-2ubuntu1_all.deb …
Unpacking python3-click (6.2-2ubuntu1) …
Selecting previously unselected package python3-html5lib.
Preparing to unpack …/python3-html5lib_0.999-4_all.deb …
Unpacking python3-html5lib (0.999-4) …
Selecting previously unselected package python3-jsonschema.
Preparing to unpack …/python3-jsonschema_2.5.1-4_all.deb …
Unpacking python3-jsonschema (2.5.1-4) …
Selecting previously unselected package python3-libnacl.
Preparing to unpack …/python3-libnacl_1.4.5-0ubuntu1_all.deb …
Unpacking python3-libnacl (1.4.5-0ubuntu1) …
Selecting previously unselected package python3-lxml.
Preparing to unpack …/python3-lxml_3.5.0-1build1_amd64.deb …
Unpacking python3-lxml (3.5.0-1build1) …
Selecting previously unselected package python3-petname.
Preparing to unpack …/python3-petname_2.0-0ubuntu1~16.04_all.deb …
Unpacking python3-petname (2.0-0ubuntu1~16.04) …
Selecting previously unselected package python3-progressbar.
Preparing to unpack …/python3-progressbar_2.3-2_all.deb …
Unpacking python3-progressbar (2.3-2) …
Selecting previously unselected package python3-pymacaroons.
Preparing to unpack …/python3-pymacaroons_0.9.2-0ubuntu1_all.deb …
Unpacking python3-pymacaroons (0.9.2-0ubuntu1) …
Selecting previously unselected package python3-pysha3.
Preparing to unpack …/python3-pysha3_1.0.0-0ubuntu1~ubuntu16.04.1_amd64.deb …
Unpacking python3-pysha3 (1.0.0-0ubuntu1~ubuntu16.04.1) …
Selecting previously unselected package python3-requests-toolbelt.
Preparing to unpack …/python3-requests-toolbelt_0.6.0-2_all.deb …
Unpacking python3-requests-toolbelt (0.6.0-2) …
Selecting previously unselected package python3-requests-unixsocket.
Preparing to unpack …/python3-requests-unixsocket_0.1.5-0ubuntu4_all.deb …
Unpacking python3-requests-unixsocket (0.1.5-0ubuntu4) …
Selecting previously unselected package python3-simplejson.
Preparing to unpack …/python3-simplejson_3.8.1-1ubuntu2_amd64.deb …
Unpacking python3-simplejson (3.8.1-1ubuntu2) …
Selecting previously unselected package python3-tabulate.
Preparing to unpack …/python3-tabulate_0.7.5-1_all.deb …
Unpacking python3-tabulate (0.7.5-1) …
Selecting previously unselected package python3-xdg.
Preparing to unpack …/python3-xdg_0.25-4_all.deb …
Unpacking python3-xdg (0.25-4) …
Selecting previously unselected package xdelta3.
Preparing to unpack …/xdelta3_3.0.8-dfsg-1ubuntu2_amd64.deb …
Unpacking xdelta3 (3.0.8-dfsg-1ubuntu2) …
Selecting previously unselected package python3-libarchive-c.
Preparing to unpack …/python3-libarchive-c_2.1-3_all.deb …
Unpacking python3-libarchive-c (2.1-3) …
Selecting previously unselected package python3-magic.
Preparing to unpack …/python3-magic_1%3a5.25-2ubuntu1_all.deb …
Unpacking python3-magic (1:5.25-2ubuntu1) …
Selecting previously unselected package snapcraft.
Preparing to unpack …/snapcraft_2.35_all.deb …
Unpacking snapcraft (2.35) …
Processing triggers for man-db (2.7.5-1) …
Processing triggers for libc-bin (2.23-0ubuntu10) …
Setting up libpython2.7-stdlib:amd64 (2.7.12-1ubuntu0~16.04.3) …
Setting up python2.7 (2.7.12-1ubuntu0~16.04.3) …
Setting up libpython-stdlib:amd64 (2.7.11-1) …
Setting up python (2.7.11-1) …
Setting up libarchive13:amd64 (3.1.2-11ubuntu0.16.04.3) …
Setting up libsodium18:amd64 (1.0.8-5) …
Setting up libxslt1.1:amd64 (1.1.28-2.1ubuntu0.1) …
Setting up python-cffi-backend (1.5.2-1ubuntu1) …
Setting up python-pkg-resources (20.7.0-1) …
Setting up python-chardet (2.3.0-2) …
Setting up python-enum34 (1.1.2-1) …
Setting up python-idna (2.0-3) …
Setting up python-ipaddress (1.0.16-1) …
Setting up python-pyasn1 (0.1.9-1) …
Setting up python-six (1.10.0-3) …
Setting up python-cryptography (1.2.3-1ubuntu0.1) …
Setting up python-openssl (0.15.1-2build1) …
Setting up python-ndg-httpsclient (0.4.0-3) …
Setting up python-urllib3 (1.13.1-2ubuntu0.16.04.1) …
Setting up python-requests (2.9.1-3) …
Setting up python3-bs4 (4.4.1-1) …
Setting up python3-colorama (0.3.7-1) …
Setting up python3-click (6.2-2ubuntu1) …
Setting up python3-html5lib (0.999-4) …
Setting up python3-jsonschema (2.5.1-4) …
update-alternatives: using /usr/bin/python3-jsonschema to provide /usr/bin/jsonschema (jsonschema) in auto mode
Setting up python3-libnacl (1.4.5-0ubuntu1) …
Setting up python3-lxml (3.5.0-1build1) …
Setting up python3-petname (2.0-0ubuntu1~16.04) …
Setting up python3-progressbar (2.3-2) …
Setting up python3-pymacaroons (0.9.2-0ubuntu1) …
Setting up python3-pysha3 (1.0.0-0ubuntu1~ubuntu16.04.1) …
Setting up python3-requests-toolbelt (0.6.0-2) …
Setting up python3-requests-unixsocket (0.1.5-0ubuntu4) …
Setting up python3-simplejson (3.8.1-1ubuntu2) …
Setting up python3-tabulate (0.7.5-1) …
Setting up python3-xdg (0.25-4) …
Setting up xdelta3 (3.0.8-dfsg-1ubuntu2) …
Setting up python3-libarchive-c (2.1-3) …
Setting up python3-magic (1:5.25-2ubuntu1) …
Setting up snapcraft (2.35) …
Processing triggers for libc-bin (2.23-0ubuntu10) …
Traceback (most recent call last):
File “/usr/bin/snapcraft”, line 9, in
load_entry_point(‘snapcraft==2.35’, ‘console_scripts’, ‘snapcraft’)()
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 542, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 2569, in load_entry_point
return ep.load()
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 2229, in load
return self.resolve()
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 2235, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/usr/lib/python3/dist-packages/snapcraft/cli/main.py”, line 19, in
run(prog_name=‘snapcraft’)
File “/usr/lib/python3/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/lib/python3/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/lib/python3/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/lib/python3/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/lib/python3/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py”, line 140, in snap
project_options, directory=directory, output=output)
File “/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_packer.py”, line 45, in snap
execute(‘prime’, project_options)
File “/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py”, line 61, in execute
config = snapcraft.internal.load_config(project_options)
File “/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/init.py”, line 24, in load_config
return Config(project_options)
File “/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_config.py”, line 125, in init
snapcraft_yaml=self.snapcraft_yaml_path)
File “/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_parts_config.py”, line 55, in init
self._process_parts()
File “/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_parts_config.py”, line 85, in _process_parts
self.load_part(part_name, plugin_name, properties)
File “/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_parts_config.py”, line 194, in load_part
grammar_processor=grammar_processor)
File “/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/init.py”, line 87, in init
self._part_properties)
File “/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/init.py”, line 103, in _get_source_handler
properties[‘source’], source_type=properties[‘source-type’])
File “/usr/lib/python3/dist-packages/snapcraft/internal/sources/init.py”, line 161, in get_source_handler
source_type = _get_source_type_from_uri(source)
File “/usr/lib/python3/dist-packages/snapcraft/internal/sources/init.py”, line 191, in _get_source_type_from_uri
raise ValueError(‘local source ({}) is not a directory’.format(source))
ValueError: local source (/home/chris/testit/mine) is not a directory
Stopping local:snapcraft-oddly-wired-bobcat
Traceback (most recent call last):
File “/usr/bin/snapcraft”, line 11, in
load_entry_point(‘snapcraft==2.34+17.10’, ‘console_scripts’, ‘snapcraft’)()
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 564, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 2662, in load_entry_point
return ep.load()
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 2316, in load
return self.resolve()
File “/usr/lib/python3/dist-packages/pkg_resources/init.py”, line 2322, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/usr/lib/python3/dist-packages/snapcraft/cli/main.py”, line 19, in
run(prog_name=‘snapcraft’)
File “/usr/lib/python3/dist-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/lib/python3/dist-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/lib/python3/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/lib/python3/dist-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/lib/python3/dist-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py”, line 188, in cleanbuild
lifecycle.cleanbuild(project_options, remote)
File “/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py”, line 326, in cleanbuild
metadata=config.get_metadata(), remote=remote).execute()
File “/usr/lib/python3/dist-packages/snapcraft/internal/lxd.py”, line 164, in execute
raise e
File “/usr/lib/python3/dist-packages/snapcraft/internal/lxd.py”, line 158, in execute
self._container_run(command, cwd=self._project_folder)
File “/usr/lib/python3/dist-packages/snapcraft/internal/lxd.py”, line 113, in _container_run
check_call([‘lxc’, ‘exec’, self._container_name, ‘–’] + cmd)
File “/usr/lib/python3.6/subprocess.py”, line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘lxc’, ‘exec’, ‘local:snapcraft-oddly-wired-bobcat’, ‘–’, ‘sh’, ‘-c’, ‘cd /root/build_testit; snapcraft snap --output testit_0.1_amd64.snap’]’ returned non-zero exit status 1.

this is the actual error …

could you show your current snapcraft.yaml too that causes this error ?

The only change since post5 is the command.

name: testit # you probably want to 'snapcraft register ’
version: ‘0.1’ # just for humans, typically ‘1.2+git’ or ‘1.3.2’
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
This is my-snap’s description. You have a paragraph or two to tell the
most important story about your snap. Keep it under 100 words though,
we live in tweetspace and your description wants to look good in the snap
store.

grade: devel # must be ‘stable’ to release into candidate/stable channels
confinement: devmode # use ‘strict’ once you have the right plugs and slots

apps:
testit:
command: python3 testit.py

parts:
testit:
source: /home/chris/testit/mine
plugin: dump
stage-packages:
- python3
- geda # some random package I don’t need, just to test the process.

if the directory you run snapcraft in is actually /home/chris/testit/mine anyway, try setting “source: .” instead

Is using ‘cleanbuild’ what brings LXD into action? I have abandoned having a separate directory for the source files and put them in /home/chris/testit and used ‘.’ as suggested. It has now snapped and installed successfully, when I type ‘testit’ in the terminal the output is:

chris@Dell-DXP051:~/testit$ testit
Thanks daniel and ogra!
chris@Dell-DXP051:~/testit$

That looks right to me…

I have now tried it with my app. Amazing! It has snapped and installed first time. Some things missing, but I can work on that myself I think.

3 Likes

The Snap doesn’t run though:

chris@DXP051:~$ snap run myapp
python3: can’t open file ‘myapp.py’: [Errno 2] No such file or directory
chris@DXP051:~$

The .yaml has

apps:
myapp:
command: python3 myapp.py

Why doesn’t it find it?

You need to pass the full path into python, else it will look for myapp.py in whatever location you call myapp from (outside the snap):

apps:
  myapp:
    command: python3 $SNAP/myapp.py