I can create my python based snap but when it tries to run I get the error:
/snap/grabbag/x1/bin/python: can’t open file ‘/var/snap/grabbag/x1/grabbag.py’: [Errno 2] No such file or directory
Here is my snapcraft.yaml. After it builds I can unsquash it and I see the grabbag.py file in its toplevel ‘bin’ folder along with activate files, a few pip files, python shortcuts and a wheel file.
When it installs grabbag.py is in ‘/snap/grabbag/x1/bin’.
‘var/snap/grabbag/x1’ is empty.
What am I doing wrong?
When I set parts/grabbag/plugin to “dump” I’d get the grabbag file in ‘bin’ but then I’d get an exec error or that python couldn’t be found. Setting parts/grabbag/plugin to “python” generates a snap that runs but without the grabbag.py file so to that end I added ‘parts/main/plugin’ and set it to dump.
I’m still learning to navigate the .yaml structure. At some point in the past, this used to work but little changes here and there…
My original issue is that the system was looking for “/var/snap/grabbag/x1/grabbag.py” and not finding it. I wasn’t sure why it was looking there instead of “/snap/grabbag/bin” where I placed the file.
As you pointed out my command was incorrect.
Your number 2 option didn’t work for me (still nothing in /var/snap/grabbag/x1). I’m not sure how to view errors from “snap try” but the host system I will install this on later today has better logging.
Your number 1 option worked and when I went “snap try” I looked in “/var/snap/grabbag/x1” and my application was writing the logs I was expecting and they are still updating. Yay!
Thank you again!
Any immediate pointers on getting pycryptodome to install? What I was doing wasn’t working (once my file started messing up I manually placed the .py file in “/var…” to get it to run and saw errors).
I’m going to start here plugs and hooks and then go from there if it fails.
Maybe because the snap defined as a daemon, I remember that the daemon is started from this path, but I’m not sure.
I just found that the documentation for snap seems to have been completely rebuilt, I searched but couldn’t find any documentation for the details of daemon, which was available before.
I would recommend not using stage-packages to install python libraries.
For example, your snap base is core22, the versions of these stage-packages are the versions when ubuntu22.04 was released, and they will not be updated in the future, which may cause problems.
You should use python-packages, which will be pulled from the pypi repository directly.
This python3 package is not necessary. When your plugin set to python, snap will bring the python interpreter by default, and the version of python3 depends on the base keyword.
Its been quite a few years since I tried to deploy a python app in snapcraft. I gave up due to the difficulties and bizarre lack of clear documentation. There are numerous unresolved forum threads if one cares to search. Flatpack’s support of Python is no better, possibly worse.
Have things changed over the years? Is there a clear guide? Ideally a guide would cover being able to choose the Python version (regardless of core os), incl. deploy Python gui apps too like wxpython etc.