2

I wrote a python package on a Debian-machine that I am trying to port over to Ubuntu Core (it comes preloaded on the hardware I want to use). On Debian, I was able to simply pull my code from git and do python3 -m mypackage "somearg". On Core, I would like to try to implement this as a snap since that method appears to be strongly preferred.

I figured out how to install the classic snap to get the snapcraft build tool. I created a snap and linked my git repository. Then I installed my snap locally, but it doesn't create any binaries.

I presume this is because I didn't create any instructions to do that. I need to somewhere supply a command that says the thing to do with all this source code is to run it with a certain python command.

How do I tell me snapcraft to turn my python package into a binary that runs that package (and pass an argument)?

1 Answer 1

0
  1. Declare an app within snapcraft.yaml

    ...
    apps:
      ...
      your-app:
        command: app-launcher
    ...
    
  2. Then app-launcher can be just simple shell script

    #!/bin/sh
    python3 -m mypackage $@
    
    #if some arguments have space in some arguments use command below
    #python3 -m mypackage $1 $2 $3 $4 $5 ...
    

To call command by user:

your-app:app-launcher "somearg"

References:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .