- Makefile avec aide auto-documentee par categories (`make help`) : installation, utilisation, compilation, publication, nettoyage. - packaging/build_windows_wine.sh : produit le .exe Windows natif depuis Linux via un PyInstaller Windows execute dans un prefixe Wine dedie (PyInstaller ne cross-compilant pas). Installation des dependances idempotente, builds suivants incrementaux. - README.md : fonctionnalites, usage GUI/CLI, compilation, publication. - `make publish` pousse branche et tags vers tous les depots configures. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
79 lines
2.7 KiB
Bash
Executable File
79 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Fabrique le binaire Windows autonome (.exe) de JoinDomainGUI DEPUIS LINUX,
|
|
# en pilotant un Python Windows embarque dans un prefixe Wine dedie.
|
|
#
|
|
# PyInstaller ne cross-compile pas : on execute donc un vrai PyInstaller Windows
|
|
# sous Wine. Le .exe produit est un binaire Windows natif.
|
|
#
|
|
# Prerequis : wine (>= 8), curl, unzip.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
PYTHON_VERSION="${PYTHON_VERSION:-3.12.10}"
|
|
WINEPREFIX="${WINEPREFIX:-$PWD/.build-wine}"
|
|
export WINEPREFIX
|
|
export WINEARCH=win64
|
|
export WINEDEBUG="${WINEDEBUG:--all}"
|
|
|
|
PY_DIR="$WINEPREFIX/drive_c/python"
|
|
WPY="c:\\python\\python.exe"
|
|
CACHE=".build-wine-cache"
|
|
|
|
command -v wine >/dev/null || { echo "wine est requis (apt install wine)" >&2; exit 1; }
|
|
|
|
mkdir -p "$CACHE"
|
|
|
|
if [ ! -d "$WINEPREFIX" ]; then
|
|
echo ">> Initialisation du prefixe Wine ($WINEPREFIX)"
|
|
wineboot --init >/dev/null 2>&1
|
|
wineserver -w
|
|
fi
|
|
|
|
if [ ! -f "$PY_DIR/python.exe" ]; then
|
|
ZIP="$CACHE/python-$PYTHON_VERSION-embed-amd64.zip"
|
|
[ -f "$ZIP" ] || curl -fL --retry 3 -o "$ZIP" \
|
|
"https://www.python.org/ftp/python/$PYTHON_VERSION/python-$PYTHON_VERSION-embed-amd64.zip"
|
|
echo ">> Installation de Python $PYTHON_VERSION (Windows) dans le prefixe"
|
|
rm -rf "$PY_DIR"
|
|
mkdir -p "$PY_DIR"
|
|
unzip -q "$ZIP" -d "$PY_DIR"
|
|
# La distribution "embeddable" desactive site-packages : on le reactive
|
|
# pour que pip et les paquets installes soient importables.
|
|
sed -i 's/^#import site/import site/' "$PY_DIR"/python*._pth
|
|
fi
|
|
|
|
if [ ! -f "$PY_DIR/Scripts/pip.exe" ]; then
|
|
GETPIP="$CACHE/get-pip.py"
|
|
[ -f "$GETPIP" ] || curl -fL --retry 3 -o "$GETPIP" https://bootstrap.pypa.io/get-pip.py
|
|
echo ">> Installation de pip"
|
|
cp "$GETPIP" "$PY_DIR/get-pip.py"
|
|
wine "$WPY" c:\\python\\get-pip.py --no-warn-script-location
|
|
fi
|
|
|
|
# pip sous Wine est lent (plusieurs minutes pour le wheel PySide6) : on ne
|
|
# reinstalle que si le prefixe est neuf. FORCE_DEPS=1 pour forcer une mise a jour.
|
|
if [ ! -d "$PY_DIR/Lib/site-packages/PyInstaller" ] || [ "${FORCE_DEPS:-0}" = "1" ]; then
|
|
echo ">> Installation des dependances Windows (peut prendre plusieurs minutes)"
|
|
wine "$WPY" -m pip install -q --no-warn-script-location \
|
|
-r requirements.txt pyinstaller
|
|
else
|
|
echo ">> Dependances Windows deja presentes (FORCE_DEPS=1 pour les mettre a jour)"
|
|
fi
|
|
|
|
echo ">> Compilation du .exe"
|
|
wine "$WPY" -m PyInstaller \
|
|
--noconfirm \
|
|
--onefile \
|
|
--windowed \
|
|
--name JoinDomainGUI \
|
|
--distpath dist/windows \
|
|
--workpath build/windows \
|
|
--specpath build/windows \
|
|
main.py
|
|
|
|
wineserver -w
|
|
echo
|
|
echo "Binaire produit : dist/windows/JoinDomainGUI.exe"
|
|
echo "Lancement : clic droit -> Executer en tant qu'administrateur"
|