2023-10-17

Snapcraft python builds - how to get it to pack - path doesn’t exist error?

So I am newer to Snapcraft, however I have been having this issue, despite following examples and tutorials so I figured I would ask here.

Machine setup: So I am on a windows machine, running ubuntu in a VM to compile the snap. Sadly work has not given me a ubuntu dev machine. Our deployments are on linux machines (hence the need for a snap), but they gave me a windows machine.

Snap Problem: Have a file (main.py) that is normally launched as “python3 -m main” and we want to make it into a snap.

So far I have this as my snap:

name: asdf
version: '4.0.0'
summary: asdf
description: |
    qweradsf - blah-etc...
grade: devel
confinement: devmode
base: core22

parts:
  py-dep:
    plugin: python
    source: .
    python-packages:
      - pyserial
      - ftputil

apps:
  asdf:
    command: usr/bin/python -m main
    environment:
      PYTHONPATH: $SNAP/usr/lib/python3/dist-packages:${SNAP}/usr/local/lib

For the command part I have tried all the combinations below

command: usr/bin/python -m main
command: /usr/bin/python -m main
command: /bin/python -m main
(also tried the above eith /usr/lib/python path)
command: python -m main
command: python3 -m main

When it goes to pack the snap file, I will get the error that the first argument - usr, bin, python, python3 - path doesn’t exist. Also tried adding PYTHONPATH. Nothing seems to work.

How do I call this python code? Do I need a source? Examples I saw didn’t use a source for the plugin (just had the . ), so I have been leaving that part mostly alone.



No comments:

Post a Comment