Skip to content

Commit a8ed4a8

Browse files
committed
ci: add optimized build scripts using Nuitka
1 parent ac725c6 commit a8ed4a8

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ src/*
2424
docs/*
2525
!docs/*.py
2626

27-
# Allow assets folder, but only .svg, .png, and .ico files
27+
# Allow assets folder, but only .svg, .png, .rc and .ico files
2828
!assets/
2929
assets/*
3030
!assets/*.svg
3131
!assets/*.png
3232
!assets/*.ico
33+
!assets/*.rc
34+
!assets/*.res
3335

3436
# Allow .github folder and its contents
3537
!.github/

Diff for: assets/icon.RES

4.29 KB
Binary file not shown.

Diff for: assets/icon.rc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IDI_ICON1 ICON "favicon.ico"

Diff for: build_fast.bat

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@echo off
2+
3+
if "%1"=="" (
4+
echo Usage: build_fast.bat [RELEASE^|DEV]
5+
exit /b 1
6+
)
7+
8+
set COMMON_FLAGS=--standalone --enable-plugin=pyside6 --include-data-dir=assets=assets
9+
10+
if /I "%1"=="RELEASE" (
11+
echo Building RELEASE version...
12+
python -m nuitka %COMMON_FLAGS% --windows-console-mode=disable --output-dir=build\release src\main.py --lto=yes
13+
) else if /I "%1"=="DEV" (
14+
echo Building DEV version...
15+
python -m nuitka %COMMON_FLAGS% --output-dir=build\dev src\main.py
16+
) else (
17+
echo Invalid argument. Use RELEASE or DEV.
18+
exit /b 1
19+
)
20+
21+
if errorlevel 1 (
22+
echo Build failed.
23+
exit /b 1
24+
) else (
25+
echo Build completed successfully.
26+
)

Diff for: src/imports_and_globals.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ def open_file_safe(file_path, mode="r"):
5757

5858

5959
def resource_path(relative_path):
60-
try:
61-
# PyInstaller creates a temp folder and stores path in _MEIPASS
60+
if hasattr(sys, "_MEIPASS"):
61+
# PyInstaller path
6262
base_path = sys._MEIPASS
63-
except Exception:
63+
elif "__compiled__" in globals():
64+
# Nuitka path
65+
base_path = os.path.dirname(sys.executable)
66+
else:
67+
# Regular Python path
6468
base_path = os.path.abspath(".")
6569

6670
return os.path.join(base_path, relative_path)

0 commit comments

Comments
 (0)