diff --git a/.github/workflows/pyinstaller-linux.yml b/.github/workflows/pyinstaller-linux.yml index 142df08..08b6e29 100644 --- a/.github/workflows/pyinstaller-linux.yml +++ b/.github/workflows/pyinstaller-linux.yml @@ -21,7 +21,7 @@ jobs: run: pip install . - name: Build with PyInstaller # pyinstaller doesn't find the GTK libraries after caching? - run: LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu pyinstaller yafi.spec + run: LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu pyinstaller yafi.spec -- --onefile working-directory: pyinstaller - name: Upload PyInstaller Artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/pyinstaller-windows.yml b/.github/workflows/pyinstaller-windows.yml index 9b2bfb2..b0b415c 100644 --- a/.github/workflows/pyinstaller-windows.yml +++ b/.github/workflows/pyinstaller-windows.yml @@ -23,7 +23,7 @@ jobs: - name: Download GTK4 Gvsbuild zip if: steps.cache-gtk4.outputs.cache-hit != 'true' - run: Start-BitsTransfer -Source https://github.com/wingtk/gvsbuild/releases/download/2025.8.0/GTK4_Gvsbuild_2025.8.0_x64.zip -Destination Gvsbuild.zip + run: Start-BitsTransfer -Source https://github.com/wingtk/gvsbuild/releases/download/2025.9.0/GTK4_Gvsbuild_2025.9.0_x64.zip -Destination Gvsbuild.zip - name: Extract Gvsbuild zip if: steps.cache-gtk4.outputs.cache-hit != 'true' @@ -41,12 +41,22 @@ jobs: - name: Build YAFI via Pip run: pip install . - - name: Build with PyInstaller + - name: Build with PyInstaller (ZIP) run: python -m PyInstaller yafi.spec working-directory: pyinstaller - - name: Upload PyInstaller Artifact + - name: Upload PyInstaller Artifact (ZIP) + uses: actions/upload-artifact@v4 + with: + path: pyinstaller/dist/YAFI/* + name: yafi-windows-${{ github.sha }} + + - name: Build with PyInstaller (Standalone) + run: python -m PyInstaller yafi.spec --noconfirm -- --onefile + working-directory: pyinstaller + + - name: Upload PyInstaller Artifact (Standalone) uses: actions/upload-artifact@v4 with: path: pyinstaller/dist/YAFI.exe - name: yafi-windows-${{ github.sha }} + name: yafi-windows-standalone-${{ github.sha }} diff --git a/pyinstaller/yafi.spec b/pyinstaller/yafi.spec index d4cc38d..1ed3ff0 100755 --- a/pyinstaller/yafi.spec +++ b/pyinstaller/yafi.spec @@ -1,11 +1,15 @@ # -*- mode: python ; coding: utf-8 -*- from PyInstaller.utils.hooks import collect_data_files import os +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("--onefile", action="store_true") +options = parser.parse_args() datas = [('LpcCrOSEC.bin', '.')] if os.name == 'nt' and os.path.exists('LpcCrOSEC.bin') else [] datas += collect_data_files('yafi') - a = Analysis( ['entrypoint.py'], pathex=[], @@ -20,25 +24,35 @@ a = Analysis( optimize=2, ) pyz = PYZ(a.pure) -splash = Splash( - 'splash.png', - binaries=a.binaries, - datas=a.datas, - text_pos=(4, 480), - # Text doesn't scale on Linux, but does on Windows - text_size=12 if os.name == 'nt' else 6, - minify_script=True, - always_on_top=True, + +if options.onefile: + splash = Splash( + 'splash.png', + binaries=a.binaries, + datas=a.datas, + text_pos=(4, 480), + # Text doesn't scale on Linux, but does on Windows + text_size=12 if os.name == 'nt' else 6, + minify_script=True, + always_on_top=True, + ) + +exe_args = ( + [ + a.scripts, + a.binaries, + a.datas, + splash, + splash.binaries, + ] + if options.onefile + else [a.scripts] ) exe = EXE( pyz, - a.scripts, - a.binaries, - a.datas, - splash, - splash.binaries, - [], + *exe_args, + exclude_binaries=not options.onefile, name='YAFI', debug=False, bootloader_ignore_signals=False, @@ -54,3 +68,14 @@ exe = EXE( entitlements_file=None, icon=['yafi.ico'], ) + +if not options.onefile: + coll = COLLECT( + exe, + a.binaries, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='YAFI', + ) diff --git a/yafi/main.py b/yafi/main.py index 495b362..91ca9cb 100644 --- a/yafi/main.py +++ b/yafi/main.py @@ -18,6 +18,7 @@ # # SPDX-License-Identifier: GPL-2.0-or-later +import os import sys import traceback import threading @@ -67,7 +68,8 @@ class YafiApplication(Adw.Application): self.win = YafiWindow(application=self) # Update the splash screen - if getattr(sys, 'frozen', False): + splash = getattr(sys, 'frozen', False) and '_PYI_SPLASH_IPC' in os.environ + if splash: import pyi_splash pyi_splash.update_text("Detecting EC") @@ -87,13 +89,13 @@ class YafiApplication(Adw.Application): ) self.show_error("EC Initalisation Error", message) - if getattr(sys, 'frozen', False): + if splash: pyi_splash.close() self.win.present() return - if getattr(sys, 'frozen', False): + if splash: pyi_splash.update_text("Building Interface") self.change_page(self.win.content, ThermalsPage()) @@ -123,7 +125,7 @@ class YafiApplication(Adw.Application): self.win.navbar.connect("row-activated", lambda box, row: switch_page(row.get_index())) - if getattr(sys, 'frozen', False): + if splash: pyi_splash.close() self.win.present()