Converting snap from plugin: ['dump'] to ['python']


#1

I had a working snap built with the ‘dump’ plugin.

Now I’m trying to switch that over to the ‘python’ plugin and struggling to solve for the following error when running snapcraft cleanbuild:

Failed to generate snap metadata: The specified command 'bin/sp' defined in the app {'command': 'bin/sp'} does not exist or is not executable.
Ensure that 'bin/sp' is relative to the prime directory.

Simplified snap/snapcraft.yaml

name: scout-plane
version: beta1
summary: ScoutPlane
description: Support log downloader, analysis, prep, and isolation tool                                          

grade: devel
confinement: devmode

apps:
  scout-plane:
    command: bin/sp

parts:
  scout-plane:
    source: .
    plugin: python
    python-version: python3
    python-packages:
      - paramiko
      - pylxd

Truncated directory layout:

root@scoutplane-dev:~/sp# tree .
.
├── LICENSE
├── README.md
├── bin
│   ├── lxdhelper.py
│   └── sp
├── snap
│   └── snapcraft.yaml
├── snapit
└── tests
    ├── 
    .... truncated....
3 directories, 10 files

File Permissions:
-rwxr-xr-x 1 root root 7882 Dec 5 17:50 sp


#2

If you’re using the python plugin, you should have a Python-style setup.py file that describes how to build and install your app. If you’ve just got a simple Python script, it could be as simple as this:

import setuptools

setuptools.setup(
    name="scoutplane",
    version="1.0",
    scripts=[
        "bin/sp",
    ],
)

You might also need modules=['lxdhelper'] to have the helper module installed. Check the Python packaging guide for more details.


#3

Thank you! That’s the lead I needed.