From fa469a79fc915df47815008b9336719c7c0091f7 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 24 Nov 2025 12:11:12 +0000 Subject: [PATCH] fix build process: use absolute paths for icon folder in PyInstaller configuration to prevent runtime errors --- build.py | 4 +++- nice_uploader.spec | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index a2b823a..96cc0ef 100644 --- a/build.py +++ b/build.py @@ -23,7 +23,9 @@ def build(build: bool = True, copy: bool = True, test: bool = False, dest: str | if test: print("Building Windows test one-file bundle with PyInstaller") # On Windows use ';' as add-data separator (src;dest) - add_data_args = ["--add-data", "icon;icon"] + # Use absolute path for the icon folder so PyInstaller can find it + icon_src = str(project_root / "icon") + add_data_args = ["--add-data", f"{icon_src};icon"] # Try to include dicognito package data (release_notes.md) which # PyInstaller may miss. This prevents runtime FileNotFoundError for diff --git a/nice_uploader.spec b/nice_uploader.spec index 801c014..b2a9751 100644 --- a/nice_uploader.spec +++ b/nice_uploader.spec @@ -1,11 +1,16 @@ # -*- mode: python ; coding: utf-8 -*- +import os +from pathlib import Path + +here = Path(__file__).resolve().parent +project_root = here a = Analysis( ['nice.py'], - pathex=[], + pathex=[str(project_root)], binaries=[], - datas=[('icon', 'icon'), ('icon/icon1.png', 'icon')], + datas=[(str(project_root / 'icon'), 'icon'), (str(project_root / 'icon' / 'icon1.png'), 'icon')], hiddenimports=['bs4', 'requests', 'nicegui', 'pynng'], hookspath=[], hooksconfig={},