Skip to content

Commit 333c45b

Browse files
committed
Create build_windows.bat
1 parent 27bd942 commit 333c45b

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

build_linux.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Check for cmake
5+
if ! command -v cmake &> /dev/null; then
6+
echo "Error: cmake is not installed. Please install it (e.g., sudo apt install cmake) and try again."
7+
exit 1
8+
fi
9+
10+
# Build script for KokoroTTSGenerator using uv and pyinstaller
11+
12+
# Ensure we're in the script's directory
13+
cd "$(dirname "$0")"
14+
15+
# Clean previous build artifacts
16+
rm -rf build dist KokoroTTSGenerator.spec
17+
18+
# Build UPX from source if not already built
19+
if [ ! -f external/upx/src/upx ]; then
20+
echo "Building UPX from source..."
21+
if [ ! -d external/upx ]; then
22+
git clone https://github.com/upx/upx.git external/upx
23+
fi
24+
cd external/upx
25+
git submodule update --init
26+
make all
27+
cd ../../
28+
else
29+
echo "UPX already built, skipping build."
30+
fi
31+
32+
# Limit PyInstaller memory usage
33+
export PYINSTALLER_MAX_CONSECUTIVE=1
34+
35+
# Run PyInstaller with UPX for compression and --strip for smaller binaries
36+
uv run pyinstaller app.py \
37+
-n KokoroTTSGenerator \
38+
--noconfirm \
39+
--clean \
40+
--strip \
41+
--collect-all "en_core_web_sm" \
42+
--add-data "src:src" \
43+
--add-data ".venv/lib/python3.12/site-packages/nicegui:nicegui" \
44+
--add-data ".venv/lib/python3.12/site-packages/language_data:language_data" \
45+
--add-data ".venv/lib/python3.12/site-packages/language_tags:language_tags" \
46+
--add-data ".venv/lib/python3.12/site-packages/espeakng_loader:espeakng_loader" \
47+
--add-data ".venv/lib/python3.12/site-packages/espeakng_loader-0.2.4.dist-info:espeakng_loader-0.2.4.dist-info" \
48+
--add-data ".venv/lib/python3.12/site-packages/misaki:misaki" \
49+
--icon=icon.ico \
50+
--upx-dir=external/upx/src
51+
52+
echo "Build complete. Executable is in the dist/ directory."

build_windows.bat

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
@echo off
2+
REM build_windows.bat
3+
REM Windows build script for KokoroTTSGenerator using uv and pyinstaller
4+
5+
REM Exit on error
6+
setlocal enabledelayedexpansion
7+
set ERRLEV=0
8+
9+
REM Check for cmake
10+
where cmake >nul 2>nul
11+
if errorlevel 1 (
12+
echo Error: cmake is not installed. Please install it (e.g., choco install cmake) and try again.
13+
exit /b 1
14+
)
15+
16+
REM Ensure we're in the script's directory
17+
cd /d "%~dp0"
18+
19+
REM Clean previous build artifacts
20+
if exist build rmdir /s /q build
21+
if exist dist rmdir /s /q dist
22+
if exist KokoroTTSGenerator.spec del /q KokoroTTSGenerator.spec
23+
24+
REM Build UPX from source if not already built
25+
if not exist external\upx\src\upx.exe (
26+
echo Building UPX from source...
27+
if not exist external\upx (
28+
git clone https://github.com/upx/upx.git external\upx
29+
if errorlevel 1 (
30+
echo Error: Failed to clone UPX repository.
31+
exit /b 1
32+
)
33+
)
34+
pushd external\upx
35+
git submodule update --init
36+
REM On Windows, building UPX requires MSYS2/MinGW or MSVC. You may need to build manually.
37+
echo Please build UPX manually for Windows if not already built. Press any key to continue...
38+
pause
39+
popd
40+
) else (
41+
echo UPX already built, skipping build.
42+
)
43+
44+
REM Run PyInstaller with UPX for compression
45+
REM Note: --strip is ignored on Windows, but kept for parity.
46+
uv run pyinstaller app.py ^
47+
-n KokoroTTSGenerator ^
48+
--noconfirm ^
49+
--clean ^
50+
--collect-all "en_core_web_sm" ^
51+
--add-data "src;src" ^
52+
--add-data ".venv/Lib/site-packages/nicegui;nicegui" ^
53+
--add-data ".venv/Lib/site-packages/language_data;language_data" ^
54+
--add-data ".venv/Lib/site-packages/language_tags;language_tags" ^
55+
--add-data ".venv/Lib/site-packages/espeakng_loader;espeakng_loader" ^
56+
--add-data ".venv/Lib/site-packages/en_core_web_sm;en_core_web_sm" ^
57+
--add-data ".venv/Lib/site-packages/espeakng_loader-0.2.4.dist-info;espeakng_loader-0.2.4.dist-info" ^
58+
--add-data ".venv/Lib/site-packages/misaki;misaki" ^
59+
--icon=icon.ico ^
60+
--upx-dir=external\upx\src
61+
62+
if errorlevel 1 (
63+
echo Build failed.
64+
exit /b 1
65+
)
66+
67+
echo Build complete. Executable is in the dist\ directory.
68+
exit /b 0

0 commit comments

Comments
 (0)