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={},