From 38d159c723676681a86fc262947fb45457384480 Mon Sep 17 00:00:00 2001 From: Pitonic Date: Thu, 19 Mar 2026 00:58:35 +0300 Subject: [PATCH] feat: Tray fix --- .github/workflows/build.yml | 23 +++++++++++------------ packaging/linux.spec | 24 ++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8d1662e..fc811e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -225,28 +225,27 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.12" - cache: "pip" - - name: Install system dependencies run: | sudo apt-get update sudo apt-get install -y \ - libgirepository1.0-dev \ + python3-venv \ + python3-dev \ + python3-gi \ gir1.2-ayatanaappindicator3-0.1 \ python3-tk - - name: Install dependencies - run: pip install ".[linux]" + - name: Create venv with system site-packages + run: python3 -m venv --system-site-packages .venv - - name: Install pyinstaller - run: pip install "pyinstaller==6.13.0" + - name: Install dependencies + run: | + .venv/bin/pip install --upgrade pip + .venv/bin/pip install ".[linux]" + .venv/bin/pip install "pyinstaller==6.13.0" - name: Build binary with PyInstaller - run: pyinstaller packaging/linux.spec --noconfirm + run: .venv/bin/pyinstaller packaging/linux.spec --noconfirm - name: Upload artifact uses: actions/upload-artifact@v4 diff --git a/packaging/linux.spec b/packaging/linux.spec index 86e3deb..ab27315 100644 --- a/packaging/linux.spec +++ b/packaging/linux.spec @@ -2,6 +2,9 @@ import sys import os +import glob + +from PyInstaller.utils.hooks import collect_submodules, collect_data_files block_cipher = None @@ -9,11 +12,21 @@ block_cipher = None import customtkinter ctk_path = os.path.dirname(customtkinter.__file__) +# Collect gi (PyGObject) submodules and data so pystray._appindicator works +gi_hiddenimports = collect_submodules('gi') +gi_datas = collect_data_files('gi') + +# Collect GObject typelib files from the system +typelib_dirs = glob.glob('/usr/lib/*/girepository-1.0') +typelib_datas = [] +for d in typelib_dirs: + typelib_datas.append((d, 'gi_typelibs')) + a = Analysis( [os.path.join(os.path.dirname(SPEC), os.pardir, 'linux.py')], pathex=[], binaries=[], - datas=[(ctk_path, 'customtkinter/')], + datas=[(ctk_path, 'customtkinter/')] + gi_datas + typelib_datas, hiddenimports=[ 'pystray._appindicator', 'PIL._tkinter_finder', @@ -22,7 +35,14 @@ a = Analysis( 'cryptography.hazmat.primitives.ciphers.algorithms', 'cryptography.hazmat.primitives.ciphers.modes', 'cryptography.hazmat.backends.openssl', - ], + 'gi', + '_gi', + 'gi.repository.GLib', + 'gi.repository.GObject', + 'gi.repository.Gtk', + 'gi.repository.Gdk', + 'gi.repository.AyatanaAppIndicator3', + ] + gi_hiddenimports, hookspath=[], hooksconfig={}, runtime_hooks=[],