mirror of
https://git.srhtnin.garden/sarah/SaraSuite.git
synced 2026-10-14 02:28:11 +02:00
49 lines
2.4 KiB
Bash
Executable File
49 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Builds dist/SaraSuite.exe, the Windows version: the same PyInstaller
|
|
# one-file recipe as the AppImage, run with the Windows Python inside a Wine
|
|
# prefix (build/WinBuild/Prefix; PyInstaller can't build for Windows from
|
|
# Linux directly). The first run sets that prefix up: it downloads the
|
|
# official Windows Python and installs the build requirements into it.
|
|
set -euo pipefail
|
|
cd "$(dirname "$(readlink -f "$0")")/.."
|
|
|
|
PythonVersion=3.14.8
|
|
export WINEPREFIX="$PWD/build/WinBuild/Prefix" WINEDEBUG=-all WINEARCH=win64
|
|
WinPython='C:\Python314\python.exe'
|
|
|
|
if [ ! -f "$WINEPREFIX/drive_c/Python314/python.exe" ]; then
|
|
echo "== Setting up the Windows build environment (one-time)"
|
|
mkdir -p build/WinBuild
|
|
Installer="build/WinBuild/python-$PythonVersion-amd64.exe"
|
|
[ -f "$Installer" ] || curl -sfL -o "$Installer" "https://www.python.org/ftp/python/$PythonVersion/python-$PythonVersion-amd64.exe"
|
|
wineboot -i >/dev/null 2>&1 || true
|
|
wine "$Installer" /quiet InstallAllUsers=0 PrependPath=1 Include_test=0 TargetDir='C:\Python314'
|
|
fi
|
|
wine "$WinPython" -m pip install --quiet --disable-pip-version-check -r requirements.txt pyinstaller pylnk3 pillow
|
|
|
|
find Programs -name __pycache__ -type d -prune -exec rm -rf {} +
|
|
Win() { winepath -w "$1"; }
|
|
|
|
# The window/taskbar/Explorer icon, from the same pixel art at whole multiples of its grid.
|
|
wine "$WinPython" -c "
|
|
from PIL import Image
|
|
Grid = Image.open(r'$(Win assets/Icon.png)').convert('RGBA').resize((32, 32), Image.NEAREST)
|
|
Grid.resize((256, 256), Image.NEAREST).save(r'$(Win build/WinBuild/Icon.ico)', sizes=[(S, S) for S in (256, 128, 64, 32, 16)])
|
|
"
|
|
|
|
# --python-option "X utf8": Python's UTF-8 mode, since on Windows it would
|
|
# otherwise read and write every TOML file in the old ANSI code page.
|
|
wine "$WinPython" -m PyInstaller --noconfirm --clean --log-level WARN \
|
|
--onefile --windowed --name SaraSuite --collect-data flet \
|
|
--python-option "X utf8" \
|
|
--icon "$(Win build/WinBuild/Icon.ico)" \
|
|
--add-data "$(Win assets);assets" --add-data "$(Win Programs);Programs" \
|
|
--distpath "$(Win build/WinBuild/dist)" --workpath "$(Win build/WinBuild/work)" --specpath "$(Win build/WinBuild)" \
|
|
"$(Win Main.py)"
|
|
|
|
mkdir -p dist
|
|
# Renamed into place, like the AppImage, in case one is running from dist/.
|
|
cp build/WinBuild/dist/SaraSuite.exe dist/SaraSuite.exe.new
|
|
mv -f dist/SaraSuite.exe.new dist/SaraSuite.exe
|
|
echo "Built dist/SaraSuite.exe"
|