activitywatch icon indicating copy to clipboard operation
activitywatch copied to clipboard

Build AppImage file with CI

Open pktiuk opened this issue 1 year ago • 1 comments

Closes: https://github.com/ActivityWatch/activitywatch/issues/725

pktiuk avatar Aug 16 '22 20:08 pktiuk

2022-08-16T20:09:13.0620919Z -- Deploying files into AppDir root directory -- 
2022-08-16T20:09:13.0623246Z WARNING: Could not find desktop file in AppDir, cannot create links for AppRun, desktop file and icon in AppDir root 
2022-08-16T20:09:13.0623679Z 
2022-08-16T20:09:13.0624155Z -- Running output plugin: appimage -- 
2022-08-16T20:09:50.0717269Z [appimage/stdout] Found appimagetool: /tmp/.mount_linuxdWzue62/plugins/linuxdeploy-plugin-appimage/usr/bin/appimagetool
2022-08-16T20:09:50.0718707Z [appimage/stderr] Running command: /tmp/.mount_linuxdWzue62/plugins/linuxdeploy-plugin-appimage/usr/bin/appimagetool "activitywatch" "-g"
2022-08-16T20:09:50.0768321Z [appimage/stderr] 
2022-08-16T20:09:50.0797742Z [appimage/stdout] 
2022-08-16T20:09:50.0798393Z [appimage/stdout] WARNING: appstreamcli command is missing, please install it if you want to use AppStream metadata
2022-08-16T20:09:50.0802150Z [appimage/stderr] appimagetool, continuous build (commit 729a1a6), build <local dev build> built on 2022-08-03 00:24:06 UTC
2022-08-16T20:09:50.0802869Z [appimage/stderr] NOTE: Using the output of 'git rev-parse --short HEAD' as the version:
2022-08-16T20:09:50.0803653Z [appimage/stderr]       9f23a1b
2022-08-16T20:09:50.0804120Z [appimage/stderr]       Please set the $VERSION environment variable if this is not intended
2022-08-16T20:09:50.0806774Z [appimage/stderr] Using architecture x86_64
2022-08-16T20:09:50.0807318Z [appimage/stderr] Deleting pre-existing .DirIcon
2022-08-16T20:09:50.0807793Z [appimage/stderr] Creating .DirIcon symlink based on information from desktop file
2022-08-16T20:09:50.0808345Z [appimage/stderr] WARNING: AppStream upstream metadata is missing, please consider creating it
2022-08-16T20:09:50.0808932Z [appimage/stderr]          in usr/share/metainfo/aw-qt.appdata.xml
2022-08-16T20:09:50.0810757Z [appimage/stderr]          Please see https://www.freedesktop.org/software/appstream/docs/chap-Quickstart.html#sect-Quickstart-DesktopApps
2022-08-16T20:09:50.0811611Z [appimage/stderr]          for more information or use the generator at http://output.jsbin.com/qoqukof.
....
2022-08-16T20:09:50.0826928Z [appimage/stderr] Marking the AppImage as executable...
2022-08-16T20:09:50.0827287Z [appimage/stderr] Embedding MD5 digest
2022-08-16T20:09:50.0828077Z [appimage/stdout] /home/runner/work/activitywatch/activitywatch/activitywatch should be packaged as ActivityWatch-9f23a1b-x86_64.AppImage
2022-08-16T20:09:50.0828512Z [appimage/stderr] Success
2022-08-16T20:09:50.0828776Z [appimage/stderr] 
2022-08-16T20:09:50.0829353Z [appimage/stderr] Please consider submitting your AppImage to AppImageHub, the crowd-sourced
2022-08-16T20:09:50.0829946Z [appimage/stderr] central directory of available AppImages, by opening a pull request
2022-08-16T20:09:50.0830450Z [appimage/stderr] at https://github.com/AppImage/appimage.github.io

There are still some minor warnings during build process.

@ErikBjare
Is there any .desktop and .appdata.xml (appstream metadata) file which could be used in this package

pktiuk avatar Aug 16 '22 20:08 pktiuk

This looks great! Sorry for the late reply.

Is there any .desktop and .appdata.xml (appstream metadata) file which could be used in this package

There is a aw-qt/resources/aw-qt.desktop, but it would prob need to be modified (esp the Exec field).

I don't know anything about appdata.xml, would appreciate it if you could look into generating it!

ErikBjare avatar Sep 26 '22 13:09 ErikBjare

This looks great! Sorry for the late reply.

Is there any .desktop and .appdata.xml (appstream metadata) file which could be used in this package

There is a aw-qt/resources/aw-qt.desktop, but it would prob need to be modified (esp the Exec field).

It will be fine. Thanks

I don't know anything about appdata.xml, would appreciate it if you could look into generating it!

They are useful for publishing your app in Linux app stores. It is not necessary now, but it may be useful later. I will add it when I will finish this PR. :)

pktiuk avatar Sep 26 '22 14:09 pktiuk

Everything is packed, but i have one final problem to overcome.

Traceback (most recent call last):
  File "PyInstaller/loader/pyimod02_importers.py", line 298, in get_code
  File "PyInstaller/loader/pyimod01_archive.py", line 291, in extract
  File "PyInstaller/loader/pyimod01_archive.py", line 87, in __enter__
ConnectionAbortedError: [Errno 103] Software caused connection abort: '/tmp/.mount_ActiviFn6gM2/aw-watcher-window/aw-watcher-window'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "aw_watcher_window/__main__.py", line 1, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "aw_watcher_window/__init__.py", line 3, in <module>
Traceback (most recent call last):
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "PyInstaller/loader/pyimod02_importers.py", line 298, in get_code
  File "aw_watcher_window/main.py", line 8, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "PyInstaller/loader/pyimod01_archive.py", line 291, in extract
  File "aw_core/__init__.py", line 12, in <module>
  File "PyInstaller/loader/pyimod01_archive.py", line 87, in __enter__
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "aw_core/models.py", line 1, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 482, in exec_module
  File "PyInstaller/loader/pyimod02_importers.py", line 300, in get_code
ImportError: Loader FrozenImporter cannot handle module json
[26439] Failed to execute script '__main__' due to unhandled exception!
OSError: [Errno 107] Transport endpoint is not connected: '/tmp/.mount_ActiviFn6gM2/aw-watcher-afk/aw-watcher-afk'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "aw_watcher_afk/__main__.py", line 3, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "aw_watcher_afk/__init__.py", line 1, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "aw_watcher_afk/__main__.py", line 3, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "aw_watcher_afk/afk.py", line 9, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "aw_client/__init__.py", line 1, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "aw_client/client.py", line 11, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "requests/__init__.py", line 43, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "urllib3/__init__.py", line 11, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 499, in exec_module
  File "urllib3/exceptions.py", line 3, in <module>
  File "urllib3/packages/six.py", line 234, in create_module
  File "urllib3/packages/six.py", line 209, in load_module
  File "urllib3/packages/six.py", line 118, in _resolve
  File "urllib3/packages/six.py", line 87, in _import_module
  File "PyInstaller/loader/pyimod02_importers.py", line 482, in exec_module
  File "PyInstaller/loader/pyimod02_importers.py", line 300, in get_code
ImportError: Loader FrozenImporter cannot handle module http.client
[26438] Failed to execute script '__main__' due to unhandled exception!

@ErikBjare
Could you tell me, what app tries to do in this place? It would help me debug this problem.

pktiuk avatar Sep 26 '22 15:09 pktiuk

@pktiuk I'm not sure, looks like somehow the pyinstaller-produced files can't import some modules? I googled around a bit, but didn't find anything immediately obvious.

How does the tree of the produced AppImage look?

ErikBjare avatar Sep 26 '22 16:09 ErikBjare

Could be related to https://github.com/pyinstaller/pyinstaller/issues/6856

ErikBjare avatar Sep 26 '22 16:09 ErikBjare

It appears, that the same binaries work properly before they are put into AppImage, so I guess it is caused by some missconfig/bug of AppImage tools.
I will report ask in AppImage's forum. https://discourse.appimage.org/t/broken-network-handling-in-python-application/2833

We'll see.

pktiuk avatar Sep 26 '22 16:09 pktiuk

https://github.com/ActivityWatch/activitywatch/issues/725#issue-1181055533

I have managed to create an appimage. I can provide a script here for you to build one.

@guysoft
Are you sure the package you built back then worked properly?

pktiuk avatar Sep 29 '22 11:09 pktiuk

@ErikBjare

How does the tree of the produced AppImage look?

Sorry I overlooked this question

Content
pawel@pop-os:/tmp/.mount_Activi9xkffz$ ls
activitywatch.png                    libgudev-1.0.so.0                  libsystemd.so.0
AppRun                               libicudata.so.56                   libthai.so.0
aw-qt                                libicudata.so.66                   libtinfo.so.6
aw-qt.desktop                        libicui18n.so.56                   libudev.so.1
aw-server                            libicui18n.so.66                   libuuid.so.1
aw-server-rust                       libicuuc.so.56                     libwacom.so.2
aw-watcher-afk                       libicuuc.so.66                     libwayland-client.so.0
aw-watcher-window                    libinput.so.10                     libwayland-cursor.so.0
base_library.zip                     libk5crypto.so.3                   libwayland-egl.so.1
importlib_metadata-4.12.0.dist-info  libkeyutils.so.1                   libX11.so.6
jsonschema-4.7.2.dist-info           libkrb5.so.3                       libX11-xcb.so.1
libatk-1.0.so.0                      libkrb5support.so.0                libXau.so.6
libatk-bridge-2.0.so.0               liblz4.so.1                        libxcb-glx.so.0
libatspi.so.0                        liblzma.so.5                       libxcb-icccm.so.4
libblkid.so.1                        libmount.so.1                      libxcb-image.so.0
libbsd.so.0                          libmtdev.so.1                      libxcb-keysyms.so.1
libbz2.so.1.0                        libpango-1.0.so.0                  libxcb-randr.so.0
libcairo-gobject.so.2                libpangocairo-1.0.so.0             libxcb-render.so.0
libcairo.so.2                        libpangoft2-1.0.so.0               libxcb-render-util.so.0
libcom_err.so.2                      libpcre2-16.so.0                   libxcb-shape.so.0
libcrypto.so.1.1                     libpcre2-8.so.0                    libxcb-shm.so.0
libdatrie.so.1                       libpcre.so.3                       libxcb-sync.so.1
libdbus-1.so.3                       libpixman-1.so.0                   libxcb-util.so.1
libdouble-conversion.so.3            libpng16.so.16                     libxcb-xfixes.so.0
lib-dynload                          libpython3.8.so.1.0                libxcb-xinerama.so.0
libepoxy.so.0                        libQt5Core.so.5                    libxcb-xkb.so.1
libevdev.so.2                        libQt5DBus.so.5                    libXcomposite.so.1
libexpat.so.1                        libQt5EglFSDeviceIntegration.so.5  libXcursor.so.1
libffi.so.7                          libQt5EglFsKmsSupport.so.5         libXdamage.so.1
libfribidi.so.0                      libQt5Gui.so.5                     libXdmcp.so.6
libgcc_s.so.1                        libQt5Network.so.5                 libXext.so.6
libgcrypt.so.20                      libQt5QmlModels.so.5               libXfixes.so.3
libgdk-3.so.0                        libQt5Qml.so.5                     libXinerama.so.1
libgdk_pixbuf-2.0.so.0               libQt5Quick.so.5                   libXi.so.6
libgio-2.0.so.0                      libQt5Svg.so.5                     libxkbcommon.so.0
libglib-2.0.so.0                     libQt5WaylandClient.so.5           libxkbcommon-x11.so.0
libgmodule-2.0.so.0                  libQt5WebSockets.so.5              libXrandr.so.2
libgobject-2.0.so.0                  libQt5Widgets.so.5                 libXrender.so.1
libgpg-error.so.0                    libQt5XcbQpa.so.5                  libz.so.1
libgraphite2.so.3                    libreadline.so.8                   markupsafe
libgssapi_krb5.so.2                  libselinux.so.1           

         PyQt5
libgthread-2.0.so.0                  libssl.so.1.1                      usr
libgtk-3.so.0                        libstdc++.so.6

and content of usr looks like this

└── usr
  ├── bin
  │   └── aw-qt
  ├── lib
  └── share
      ├── applications
      │   └── aw-qt.desktop
      └── icons
          └── hicolor
              ├── 512x512
              │   └── apps
              │       └── activitywatch.png
              └── scalable
                  └── apps

Full tree aw-tree.txt


Do you list manually python packages you pack together with activitywatch?

File "aw_core/models.py", line 1, in <module> ///THIS LINE: import json
  File "PyInstaller/loader/pyimod02_importers.py", line 482, in exec_module
  File "PyInstaller/loader/pyimod02_importers.py", line 300, in get_code
ImportError: Loader FrozenImporter cannot handle module json
[26439] Failed to execute script '__main__' due to unhandled exception!
OSError: [Errno 107] Transport endpoint is not connected: '/tmp/.mount_ActiviFn6gM2/aw-watcher-afk/aw-watcher-afk'

Maybe this error is caused by not packing json package?

pktiuk avatar Oct 01 '22 16:10 pktiuk

I don't know why, but everything works now.

It was built here https://github.com/pktiuk/activitywatch/actions/runs/3207458858

You can test it if you want.

pktiuk avatar Oct 07 '22 20:10 pktiuk

@pktiuk it worked and I've been using my appimage, however there was a minor bug that if you make it load on startup it opened multiple instances of the server which caused a mess, I guess that could be fixed in general in the application so it makes sure no more than one service is running.

guysoft avatar Oct 18 '22 14:10 guysoft

however there was a minor bug that if you make it load on startup it opened multiple instances of the server which caused a mess,

@guysoft
In my case I don't have any problems with launching activitywatch AppImage on startup. I use it in this state since around a month and there are no problems so far.

pktiuk avatar Oct 29 '22 12:10 pktiuk

@ErikBjare
What is this PR waiting for?

pktiuk avatar Oct 29 '22 12:10 pktiuk

@pktiuk Just want to test it on my own Linux machine, adding it to next week's TODOs :)

ErikBjare avatar Oct 29 '22 12:10 ErikBjare

Alright, I never got around to testing it last week, and this week I won't have access to a Linux machine, but I'm going to go ahead and merge this anyway. Will test it more extensively together with #823 before I make the next release.

Huge thanks for this @pktiuk, great work getting this done! ❤️ 🚀

ErikBjare avatar Nov 05 '22 11:11 ErikBjare