Hello World Example?

Dear all,

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?

Yours,

Robert

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.

Dear Michael,

Thank you!

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.

Yours,

Robert

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.

2 Likes

Dear @probono,

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:

Yours,

Robert

Hello @orschiro, this .yml should do the trick:

app: dslli

ingredients:
  dist: trusty
  sources: 
    - deb http://archive.ubuntu.com/ubuntu/ trusty main universe
  packages:
    - python3-minimal
  script:
    - wget -c https://github.com/orschiro/dslli/archive/master.zip
    - unzip master.zip

script:
  - cat > dslli.desktop <<EOF
  - [Desktop Entry]
  - Type=Application
  - Name=dslli
  - Icon=dslli
  - Exec=dslli
  - Categories=Utility;
  - EOF
  - 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 /usr/... structure.

2 Likes

Dear @probono,

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. :slight_smile:

Let me just ask you one question:

The final AppImage executes toggle_lid.py.

However, it does not yet include the other command show_state.py.

Is it better to include the latter into the already existing AppImage or should I create a second AppImage file for the other command?

Yours,

Robert

1 Like

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 :slight_smile:

1 Like

Dear @probono,

Thank you!

This is a great learning experience! :slight_smile:

I added the .yml files to the repository and removed all the rest.

However, using this [1] .yml file, it finishes the building process but fails to run with the following error:

orschiro@x230:~/dslli/AppImageCompile/AppImage/showstate/out$ ./dslli-indicator-.glibc2.17-x86_64.AppImage 
/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>
    gi.require_version('Gtk', '3.0')
  File "/tmp/.mount_kD8ydv/usr/lib/python3/dist-packages/gi/__init__.py", line 83, in require_version
    (namespace, version))
ValueError: Namespace Gtk not available for version 3.0

Do you have any advice for me?

Yours,

Robert

[1] https://github.com/orschiro/dslli/blob/master/show_state.yml

1 Like

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 /usr, ignoring $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: Freezing a PyGI app · Issue #1966 · pyinstaller/pyinstaller · GitHub

1 Like

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. :slight_smile:

1 Like