I am completely new to building packages.
I would like to create a universally installable package for two simple python scripts and include some .png icons.
Does someone have a simple Hello World example that I can use as a simple basis to create my package?
If all you want to do is install scripts and some icons then you can do that with a separate script. AppImages are great but might be a bit overkill for what it sounds like you are wanting to deploy.
What do you mean by a separate script?
I still like the idea to package those simple scripts to make it easier for
absolute Linux beginners to use them.
With AppImage you can bundle even more complex Python applications. For example, the Cura application is using Python and PyQt, and is completely self-standing.
The key is to bundle Python, the Python libraries, and your virtual Python environment inside the AppImage.
https://github.com/probonopd/AppImageKit/wiki/Bundling-Python-apps should get you started. Please feel free to ask here if you get stuck; ideally with your sample application.
If you like, I can write a tiny “hello world” example bundling Python and a Python script inside an AppImage.
I appreciate your help!
I actually set up a Github repository that contains the scripts to give you
a better idea of what I am trying to package:
Hello @orschiro, this
.yml should do the trick:
- deb http://archive.ubuntu.com/ubuntu/ trusty main universe
- wget -c https://github.com/orschiro/dslli/archive/master.zip
- unzip master.zip
- cat > dslli.desktop <<EOF
- [Desktop Entry]
- cp ../dslli-master/* usr/bin/
- cp usr/bin/green.png usr/share/icons/hicolor/24x24/dslli.png
- cp usr/share/icons/hicolor/24x24/dslli.png .
- ( cd usr/bin/ ; ln -s toggle_lid.py dslli )
- chmod a+x usr/bin/toggle_lid.py
To run this, put it into a file called
dslli.yml, download the meta Recipe, then run
bash -ex ./Recipe dslli.yml.
The things in the
script: section are mainly because your repository does not offer a desktop file and does not place files into the usual FHS-like
This is fantastic!
I am very appreciative of your help.
I added all this along with my attribution for your work to the Github repository.
Let me just ask you one question:
The final AppImage executes
However, it does not yet include the other command
Is it better to include the latter into the already existing AppImage or should I create a second AppImage file for the other command?
It depends: If
show_state.py is called by
toggle_lid.py, then you should put both into the same AppImage. If both are executed by the user manually, then each should be its own AppImage.
Oh, and please don’t store the AppImage in git, that’s what the GitHub Releases page is for
This is a great learning experience!
I added the .yml files to the repository and removed all the rest.
However, using this  .yml file, it finishes the building process but fails to run with the following error:
/bin/bash: ../lib/x86_64-linux-gnu/libtinfo.so.5: no version information available (required by /bin/bash)
Traceback (most recent call last):
File "/tmp/.mount_kD8ydv/usr/bin/dslli-indicator", line 7, in <module>
File "/tmp/.mount_kD8ydv/usr/lib/python3/dist-packages/gi/__init__.py", line 83, in require_version
ValueError: Namespace Gtk not available for version 3.0
Do you have any advice for me?
Interesting problem here. There seems to be a library called
libgirepository-1.0.so.1 which contains a hardcoded path to
/usr/lib. I suspect it is hardcoded to search for files like
/usr/lib/girepository-1.0/Gtk-3.0.typelib in the system’s
$PYTHONPATH and the like.
And indeed, the documentation says
Typelibs will be loaded from paths in the environment variable
GI_TYPELIB_PATH and /usr/lib/girepository-1.0/.
Hence, the application is trying to load the typelib file from the system (where it may or may not exist), failing.
We need to find a good way to make it load the file from inside the AppImage instead. As a temporary workaround, we can
It would be much nicer if the library would be changed to make it relocateable, by using relative paths (relative to the
.so) rather than the absolute path
/usr/lib/girepository-1.0/. It would be great if you could submit an upstream feature request. Seems like others are having similar issues too: https://github.com/pyinstaller/pyinstaller/issues/1966
Once again, my sincere thanks for all your help to build my first AppImage!
This forum made the difference for me.
In the future, I would recommend AppImage over Snap or Flatpak.