diff --git a/.gitignore b/.gitignore index ef5516b..93e4555 100644 --- a/.gitignore +++ b/.gitignore @@ -24,12 +24,14 @@ src/* docs/* !docs/*.py -# Allow assets folder, but only .svg, .png, and .ico files +# Allow assets folder, but only .svg, .png, .rc and .ico files !assets/ assets/* !assets/*.svg !assets/*.png !assets/*.ico +!assets/*.rc +!assets/*.res # Allow .github folder and its contents !.github/ diff --git a/assets/icon.RES b/assets/icon.RES new file mode 100644 index 0000000..6627e35 Binary files /dev/null and b/assets/icon.RES differ diff --git a/assets/icon.rc b/assets/icon.rc new file mode 100644 index 0000000..1fa8fd7 --- /dev/null +++ b/assets/icon.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON "favicon.ico" \ No newline at end of file diff --git a/build_fast.bat b/build_fast.bat new file mode 100644 index 0000000..d1cab2c --- /dev/null +++ b/build_fast.bat @@ -0,0 +1,26 @@ +@echo off + +if "%1"=="" ( + echo Usage: build_fast.bat [RELEASE^|DEV] + exit /b 1 +) + +set COMMON_FLAGS=--standalone --enable-plugin=pyside6 --include-data-dir=assets=assets + +if /I "%1"=="RELEASE" ( + echo Building RELEASE version... + python -m nuitka %COMMON_FLAGS% --windows-console-mode=disable --output-dir=build\release src\main.py --lto=yes +) else if /I "%1"=="DEV" ( + echo Building DEV version... + python -m nuitka %COMMON_FLAGS% --output-dir=build\dev src\main.py +) else ( + echo Invalid argument. Use RELEASE or DEV. + exit /b 1 +) + +if errorlevel 1 ( + echo Build failed. + exit /b 1 +) else ( + echo Build completed successfully. +) diff --git a/src/imports_and_globals.py b/src/imports_and_globals.py index d09b0c2..7566fef 100644 --- a/src/imports_and_globals.py +++ b/src/imports_and_globals.py @@ -57,10 +57,14 @@ def open_file_safe(file_path, mode="r"): def resource_path(relative_path): - try: - # PyInstaller creates a temp folder and stores path in _MEIPASS + if hasattr(sys, "_MEIPASS"): + # PyInstaller path base_path = sys._MEIPASS - except Exception: + elif "__compiled__" in globals(): + # Nuitka path + base_path = os.path.dirname(sys.executable) + else: + # Regular Python path base_path = os.path.abspath(".") return os.path.join(base_path, relative_path)