Commit Graph
27 Commits
Author SHA1 Message Date
guihkx 714558965f ci/linux: update PyInstaller builder to run on Ubuntu 22.04
The Ubuntu 20.04 runner image is expected to be removed from GitHub
Actions on April 1st, 2025.

Source: https://github.com/actions/runner-images/issues/11101
2025-03-24 07:41:34 +01:00
guihkx 5d11b67ad2 pyinstaller: use wildcard matching when excluding binaries 2025-03-24 07:41:34 +01:00
guihkx 01b26cf7b4 linux: pin PyGObject version to <3.51
PyGObject 3.51 (and newer) now requires girepository-2.0 as a build
dependency [1], which is a version we cannot easily install in the
Ubuntu version we use in CI/CD, so the build fails:

=======

$ python3 -m pip install -r requirements.txt
[ ... ]
Collecting PyGObject (from -r requirements.txt (line 4))
  Downloading pygobject-3.52.3.tar.gz (1.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 45.4 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [216 lines of output]
      + meson setup /tmp/pip-install-nayte7bo/pygobject_097c5326983b4ca690e238e49ba4b29c /tmp/pip-install-nayte7bo/pygobject_097c5326983b4ca690e238e49ba4b29c/.mesonpy-sp71efmg -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dtests=false -Dwheel=true --wrap-mode=nofallback --native-file=/tmp/pip-install-nayte7bo/pygobject_097c5326983b4ca690e238e49ba4b29c/.mesonpy-sp71efmg/meson-python-native-file.ini
      The Meson build system
      Version: 1.7.0
      Source dir: /tmp/pip-install-nayte7bo/pygobject_097c5326983b4ca690e238e49ba4b29c
      Build dir: /tmp/pip-install-nayte7bo/pygobject_097c5326983b4ca690e238e49ba4b29c/.mesonpy-sp71efmg
      Build type: native build
      Project name: pygobject
      Project version: 3.52.3
      C compiler for the host machine: cc (gcc 9.4.0 "cc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0")
      C linker for the host machine: cc ld.bfd 2.34
      Host machine cpu family: x86_64
      Host machine cpu: x86_64
      Program python3 found: YES (/opt/hostedtoolcache/Python/3.10.16/x64/bin/python3)
      Found pkg-config: YES (/usr/bin/pkg-config) 1.6.3
      Run-time dependency python found: YES 3.10
      Found CMake: /usr/local/bin/cmake (3.31.6)
      Run-time dependency girepository-2.0 found: NO (tried pkgconfig and cmake)
      Not looking for a fallback subproject for the dependency girepository-2.0 because:
      Use of fallback dependencies is disabled.

      ../meson.build:31:9: ERROR: Dependency 'girepository-2.0' is required but not found.

=======

Unfortunately, girepository-2.0 is only available in Ubuntu 24.10, a
version we can't easily use in GitHub Actions. But even if could, doing
so would also needlessly bump the minimum glibc version requirement for
Linux users, making TDM much less portable.

So, for now, let's pin PyGObject to <3.51.

[1]: https://gitlab.gnome.org/GNOME/pygobject/-/blob/d29f4e65faabf2ba6892a976a0fdfcb2cc3031f7/NEWS#L4-5
2025-03-23 23:24:49 +01:00
guihkx 950f404e47 Remove Python version check for truststore
This follows what was done in commit 2f9467497c.
2024-11-16 20:11:24 +01:00
guihkx 9b44968ef8 ci: add validation job
For now, this job only validates the JSON language files in "lang/",
but in the future, more validation/test steps can be added.
2024-10-25 07:54:52 +02:00
guihkx 49e8db9e22 linux/appimage: install meson and ninja from PyPI
Some systems (e.g. Ubuntu 22.04, which we use to make the AppImage),
have ancient versions of meson and ninja, which is not good when we
have dependencies like PyGObject 3.47+ (and more recently, one of its
transitive dependencies, pycairo 1.27+) requiring a fairly recent
version of meson to be able to be built.

So, instead of relying on whatever meson/ninja version the current
system provides us with to make the AppImage, this change will simply
install up-to-date, official wheels of meson/ninja directly from PyPI.

This also allows us to finally unpin PyGObject's version.
2024-09-11 11:47:05 +02:00
guihkx 27dcc9c280 linux: pin PyGObject version to <3.47
This fixes the broken "Linux (AppImage)" CI job.

PyGObject 3.47 has dropped setuptools in favor of meson-python, which
isn't a problem per se, but they also require meson 0.63.3, which we
don't currently have in the repositories of Ubuntu 20.04, which is
the oldest (yet supported) version we use to build our AppImage
package, in order to increase compatibility with as much Linux distros
as possible.

And since there's no real, compelling reason to upgrade to the latest
version of PyGObject right now, let's just pin it to version <3.46,
until we eventually upgrade the Ubuntu version we use for CI.
2024-04-30 14:14:32 +02:00
guihkx 26c559a27f ci: update actions/download-artifact to v4
This version bump is now needed because of changes from commit
7e2c233674, which ended up breaking
automated uploads to the Releases page.
2024-04-30 14:14:32 +02:00
guihkxandDevilXD dbd3cd82a0 Move ClientType into Twitch class as an attribute
This allows us to use the base URL as specified in ClientInfo for
requests made to Twitch.

Previously, we'd hardcode "www.twitch.tv" as the base URL to make
channel-related requests, but because we're currently spoofing the
mobile client, that would always cause a HTTP redirect to m.twitch.tv.

This change avoids that HTTP redirect, and potentially saves a whopping
150 ms (or more 😱) when making channel-related requests.

Co-authored-by: DevilXD <4180725+DevilXD@users.noreply.github.com>
2024-02-14 14:51:37 +01:00
guihkx 8bc62dcec1 readme: mention glibc 2.35 requirement for the AppImage 2024-01-22 23:29:38 +01:00
guihkx 3897a8bccf ci/linux: build AppImage on Ubuntu 22.04 (Python 3.10)
Ubuntu 20.04 only has Python 3.8, and because the 'truststore'
dependency requires at least Python 3.10, the AppImage package would
need to bundle CA certificates from 'certifi' to make HTTPS requests
work at all, which is quite an ugly workaround.

Unfortunately, as a side effect, building on Ubuntu 22.04 increases the
minimum required version of glibc from 2.31 to 2.35.
2024-01-22 23:29:38 +01:00
guihkx 6e5fee7103 linux/appimage: generate byte-code files and package them
This makes the app start slightly faster, as byte-code files won't need
to be generated every time users run the app.

https://docs.python.org/3.10/library/compileall.html
2024-01-22 23:29:38 +01:00
guihkx 81d4e7bc3c linux/pyinstaller: exclude unneeded libraries
Excluding these Linux libraries doesn't seem to cause any side-effects
at runtime (they're also not present in the AppImage).

And the benefit of this, is a reduction of 15 MiB in the final size of
the Linux binary, which should also slightly reduce the app's startup
time (but don't quote me on that). :)
2023-11-19 13:59:35 +01:00
guihkx ff7fccbeff readme: recommend the AppImage package for Linux users
The list of benefits over the PyInstaller package isn't extensive, but
IMO it's more than enough to be the "recommended choice".
2023-11-16 20:36:25 +01:00
guihkx 51560b319c ci/linux: build Appimage for amd64
While it's theoretically possible to package for other CPU
architectures via QEMU, doing so will take more work and testing...
2023-11-16 20:36:25 +01:00
guihkx a31fa375c9 linux: add support for AppImage packages
AppImage is a more flexible packaging solution for Linux than what
PyInstaller currently offers.

Some of the benefits are:

- Ability to ship the app with predefined environment variables
(solving issues like #321)
- Improved integration with the desktop environment (if you're using
go-appimage[1] or libappimage[2])
- Much lighter in size (~27 MB difference)

To actually make the AppImage, I'm using appimage-builder[3], which
makes the process a bit easier.

For more details about the AppImage technology, check out their
website[4].

[1] https://github.com/probonopd/go-appimage
[2] https://github.com/AppImageCommunity/libappimage
[3] https://appimage-builder.readthedocs.io/en/latest/index.html
[4] https://appimage.org/
2023-11-16 20:36:25 +01:00
guihkxandDevilXD dbbf5206fb readme: add notes about the linux build
Co-authored-by: DevilXD <bartosz.peszek@gmail.com>
2023-06-11 16:58:18 +02:00
guihkx 1a49b3836f ci/linux: bundle an up to date version of libXft
This fixes the following error when you launch the app with an emoji
font installed (e.g. Noto Emoji):

X Error of failed request:  BadLength (poly request too large or internal Xlib length error)
  Major opcode of failed request:  139 (RENDER)
  Minor opcode of failed request:  20 (RenderAddGlyphs)
  Serial number of failed request:  277
  Current serial number in output stream:  300

This has been fixed[1] in libXft 2.3.5[2], but unfortunately Ubuntu
20.04 (which we currently use in the Linux CI workflow), still has
version 2.3.3, so we have to build it ourselves.

[1] https://gitlab.freedesktop.org/xorg/lib/libxft/-/merge_requests/12
[2] https://lists.freedesktop.org/archives/xorg-announce/2022-September/003209.html
2023-06-11 16:58:18 +02:00
guihkx 332c8c4ea2 ci: provide development builds for Linux 2023-06-11 16:58:18 +02:00
guihkxandDevilXD ed8c598180 pyinstaller: avoid bundling icon and themes on Linux
This greatly reduces the final size of the UPX-compressed binary, from
78.7 MiB to 54.9 MiB (a 23.8 MiB difference)!

Co-authored-by: DevilXD <bartosz.peszek@gmail.com>
2023-06-11 16:58:18 +02:00
guihkxandDevilXD 5162e5c553 linux: fix URLs not opening in PyInstaller package
Because PyInstaller modifies the LD_LIBRARY_PATH environment variable
to make things work correctly on Linux, when we try to launch any
subprocess (such as the web browser), that modified variable gets
picked up as well, causing things to go south.

To work around this Linux-only problem, we have to:

1. Save the current value of LD_LIBRARY_PATH
2. Move the value of LD_LIBRARY_PATH_ORIG to LD_LIBRARY_PATH
3. Launch subprocess
4. Restore the saved LD_LIBRARY_PATH again

Reference:

https://pyinstaller.org/en/stable/runtime-information.html#ld-library-path-libpath-considerations

Co-authored-by: DevilXD <bartosz.peszek@gmail.com>
2023-06-11 16:58:18 +02:00
guihkx e31dcd85b4 linux: add truststore as a dependency
Because Linux distributions don't have an 'universal' path for the
system certificate store, bundling libssl built on distro A might not
work on distro B, because distros tend to change path to the
certificate store at build time.

This means that creating a PyInstaller package on Ubuntu will include
the libssl built there, and if you try to run this package on a
different distro (e.g. Arch Linux), any attempt to create an SSL
connection will fail, because Arch Linux has a different path for the
certificate store than Ubuntu.

This issue is usually worked around by bundling certificates with the
app (usually using certifi), and then pointing the SSL_CERT_FILE
environment to it.

However, truststore seems to be a better alternative, since it tries to
use the certificate store from the system instead.

The list of benefits are listed on the project's page on GitHub:

https://github.com/sethmlarson/truststore
2023-06-11 16:58:18 +02:00
guihkx 7c1e7b0af1 linux: add PyGObject as a dependency
This dependency is required for proper support of the AppIndicator
backend from pystray:

https://github.com/moses-palmer/pystray/blob/v0.19.4/docs/faq.rst#how-do-i-use-pystray-in-a-virtualenv-on-linux
2023-06-11 16:58:18 +02:00
guihkx 82653fcc20 tk: also hook into WM_DELETE_WINDOW to quit the app
Makes the app exit correctly on Linux when the main window is closed.
2023-06-11 16:58:18 +02:00
guihkx 726082a157 tk: set classPath upon instantiation
This fixes an issue on Linux (more specifically, on GNOME Shell 44),
where the window would be identified as "Tk".
2023-06-11 16:58:18 +02:00
guihkxandDevilXD f8c0dba1ee Use icon.visible to show or hide the tray icon on all systems
On Linux, pystray's icon.stop() currently doesn't work well with the
AppIndicator backend.

So, instead of destroying the icon when the user restores from tray
(only to later re-create it when the user minimizes to tray again), we
have the option to control the icon's visibility instead! Luckily, that
works on Windows too!

Note that for this change to work properly on Linux, we need to switch
to the master version of pystray, because we need this specific fix:

https://github.com/moses-palmer/pystray/commit/5943ed4e19be48224cf39b70444de8ffe22c23ce

After pystray releases a version newer than 0.19.4, we can switch back.

Co-authored-by: DevilXD <bartosz.peszek@gmail.com>
2023-06-11 16:58:18 +02:00
guihkx 9b5d3d8a76 Provide development builds via GitHub Actions
Makes it easier for people to test bug fixes or new features.
2023-05-20 09:19:13 +02:00