Simple Python snapcraft.yml

Can someone explain in detail how do I complete this snapcraft.yaml:
https://gist.github.com/wieczorek1990/4143227ebcd377b2ceccb69abaedb16d
for my project to successfully build?


The project is basically a Makefile, one sh file and one Python file and a readme.

I would read up on using the make plugins.

The python plugin is used when your app uses a setup.py.

It does:

  • import python modules with a requirements.txt
  • build a python project that has a setup.py
  • install packages straight from pip

So in this case you are likely going to have to add the various stage and build packages (dependencies). I had a look at your repo, and there are no deps listed, so I assume it is just python itself?

Actually - looking at what your makefile does - itā€™s current form will not work for a snap as you hardcode paths that are in system locations. And looking at what you make file actually doesā€¦ I would just use hte dump plugin and move the commands into the yaml itself.

Yes, itā€™s just Python. The Bash script is just an alias.

Thanks for reply. Will try.

Ok, here is a working build. But it is currently in devel/devmode. So I have not worked on the confinement aspects.

name: gitl
version: '1.0'
summary: Git loop
description: Git loop inspired by gitsh.
grade: devel
confinement: devmode

parts:
  gitl:
    plugin: dump
    source: https://github.com/wieczorek1990/gitl.git
    source-type: git
    prepare: |
      chmod +x gitl.py
    organize:
      gitl.py: bin/gitl.py
    stage-packages:
      - python3

apps:
  gitl:
    command: bin/gitl.py

I dropped the makefile, ignored the alias and just exposed the script as the same name as your alias.

Clarification - I know there is additional work to be done. I know there is an execution issue once the snap is installed. If you have not figured it out, Iā€™ll watch out here and circle back later (heading out hte door).

For reference the error is:

/snap/gitl/x1/command-gitl.wrapper: 6: exec: /snap/gitl/x1/bin/gitl.py: not found

So I have an error in my yaml.

1 Like

Yeah strange.

exec /snap/gitl/$x/bin/gitl.py

works as expected, maybe thatā€™s a shell issue?

EDIT:
Can you clarify why adding stage-packages is necessary?

EDIT 2:
Iā€™ve changed the repository layout to have bin in /.

EDIT 3:
Figured out the state-packages is just for dependency.

EDIT 4:
Iā€™m on Fedora.

Well thatā€™s good to know that is supporting for you. My shell ā€œshouldnā€™tā€ matter. Hmmm. Gears turningā€¦

Turned out that the state-packages uses different python that is 3.5 which is available during ā€˜snap runā€™.
Now Iā€™m trying to figure out how to load user .gitconfig during ā€˜snap runā€™. ā€˜snap run --shell $appā€™ was helpful.

What version do you need? It is based on the repos for 16.04 (base snap core image)

3.5 is OK.
If the snap runs in sandbox how do I pass the user dotfiles?

Is there a way to prevent HOME being overwriteen by snap?

Iā€™m out on my mobile, but traditionally snaps cannot access dot files (by design) even with the home plugin enabled. Are these dotfiles config for your app? Or something else?

Found the app plug home.