1 Commits

Author SHA1 Message Date
0e54616000 fix: use msiextract for tkinter, fix step numbering, graceful Docker fallback
Some checks failed
Build Release / create-release (push) Successful in 0s
Lint & Test / test (push) Failing after 14s
Build Release / build-linux (push) Successful in 1m27s
Build Release / build-docker (push) Successful in 6s
Build Release / build-windows (push) Successful in 3m26s
- Replace 7z with msiextract (msitools) to extract tkinter from
  python.org's individual MSI packages (tcltk.msi + lib.msi)
- Fix build step numbering to /9
- Docker job continues on login failure (registry may not be enabled)
- Show makensis output for debugging
2026-03-22 03:44:37 +03:00
2 changed files with 40 additions and 42 deletions

View File

@@ -63,7 +63,7 @@ jobs:
- name: Install system dependencies - name: Install system dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y --no-install-recommends zip libportaudio2 nsis p7zip-full sudo apt-get install -y --no-install-recommends zip libportaudio2 nsis msitools
- name: Cross-build Windows distribution - name: Cross-build Windows distribution
run: | run: |
@@ -188,12 +188,15 @@ jobs:
echo "server_host=$SERVER_HOST" >> "$GITHUB_OUTPUT" echo "server_host=$SERVER_HOST" >> "$GITHUB_OUTPUT"
- name: Login to Gitea Container Registry - name: Login to Gitea Container Registry
id: docker-login
continue-on-error: true
run: | run: |
echo "${{ secrets.GITEA_TOKEN }}" | docker login \ echo "${{ secrets.GITEA_TOKEN }}" | docker login \
"${{ steps.meta.outputs.server_host }}" \ "${{ steps.meta.outputs.server_host }}" \
-u "${{ gitea.actor }}" --password-stdin -u "${{ gitea.actor }}" --password-stdin
- name: Build Docker image - name: Build Docker image
if: steps.docker-login.outcome == 'success'
run: | run: |
TAG="${{ gitea.ref_name }}" TAG="${{ gitea.ref_name }}"
REGISTRY="${{ steps.meta.outputs.registry }}" REGISTRY="${{ steps.meta.outputs.registry }}"
@@ -211,6 +214,7 @@ jobs:
fi fi
- name: Push Docker image - name: Push Docker image
if: steps.docker-login.outcome == 'success'
run: | run: |
TAG="${{ gitea.ref_name }}" TAG="${{ gitea.ref_name }}"
REGISTRY="${{ steps.meta.outputs.registry }}" REGISTRY="${{ steps.meta.outputs.registry }}"

View File

@@ -47,7 +47,7 @@ echo ""
# ── Clean ──────────────────────────────────────────────────── # ── Clean ────────────────────────────────────────────────────
if [ -d "$DIST_DIR" ]; then if [ -d "$DIST_DIR" ]; then
echo "[1/8] Cleaning previous build..." echo "[1/9] Cleaning previous build..."
rm -rf "$DIST_DIR" rm -rf "$DIST_DIR"
fi fi
mkdir -p "$DIST_DIR" mkdir -p "$DIST_DIR"
@@ -57,7 +57,7 @@ mkdir -p "$DIST_DIR"
PYTHON_ZIP_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-embed-amd64.zip" PYTHON_ZIP_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-embed-amd64.zip"
PYTHON_ZIP_PATH="$BUILD_DIR/python-embed-win.zip" PYTHON_ZIP_PATH="$BUILD_DIR/python-embed-win.zip"
echo "[2/8] Downloading Windows embedded Python ${PYTHON_VERSION}..." echo "[2/9] Downloading Windows embedded Python ${PYTHON_VERSION}..."
if [ ! -f "$PYTHON_ZIP_PATH" ]; then if [ ! -f "$PYTHON_ZIP_PATH" ]; then
curl -sL "$PYTHON_ZIP_URL" -o "$PYTHON_ZIP_PATH" curl -sL "$PYTHON_ZIP_URL" -o "$PYTHON_ZIP_PATH"
fi fi
@@ -66,7 +66,7 @@ unzip -qo "$PYTHON_ZIP_PATH" -d "$PYTHON_DIR"
# ── Patch ._pth to enable site-packages ────────────────────── # ── Patch ._pth to enable site-packages ──────────────────────
echo "[3/8] Patching Python path configuration..." echo "[3/9] Patching Python path configuration..."
PTH_FILE=$(ls "$PYTHON_DIR"/python*._pth 2>/dev/null | head -1) PTH_FILE=$(ls "$PYTHON_DIR"/python*._pth 2>/dev/null | head -1)
if [ -z "$PTH_FILE" ]; then if [ -z "$PTH_FILE" ]; then
echo "ERROR: Could not find python*._pth in $PYTHON_DIR" >&2 echo "ERROR: Could not find python*._pth in $PYTHON_DIR" >&2
@@ -86,52 +86,46 @@ fi
echo " Patched $(basename "$PTH_FILE")" echo " Patched $(basename "$PTH_FILE")"
# ── Bundle tkinter into embedded Python ─────────────────────── # ── Bundle tkinter into embedded Python ───────────────────────
# Embedded Python doesn't include tkinter. We extract it from the # Embedded Python doesn't include tkinter. We download the individual
# official Windows installer (amd64.exe) which contains all components # MSI packages from python.org (tcltk.msi + lib.msi) and extract them
# as MSI cab files. # using msiextract (from msitools).
echo "[3b/8] Bundling tkinter for screen overlay support..." echo "[4/9] Bundling tkinter for screen overlay support..."
# Download the Windows installer (not the embed zip — the full one)
INSTALLER_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-amd64.exe"
INSTALLER_PATH="$BUILD_DIR/python-installer.exe"
if [ ! -f "$INSTALLER_PATH" ]; then
curl -sL "$INSTALLER_URL" -o "$INSTALLER_PATH"
fi
# The installer is a bundle of MSI/CAB files. We can extract with 7z or
# msiextract. The tkinter components are in the 'tcltk' feature.
TK_EXTRACT="$BUILD_DIR/tk-extract" TK_EXTRACT="$BUILD_DIR/tk-extract"
rm -rf "$TK_EXTRACT" rm -rf "$TK_EXTRACT"
mkdir -p "$TK_EXTRACT" mkdir -p "$TK_EXTRACT"
if command -v 7z &>/dev/null; then MSI_BASE="https://www.python.org/ftp/python/${PYTHON_VERSION}/amd64"
# Extract all cab files from the installer
7z x -o"$TK_EXTRACT/installer" "$INSTALLER_PATH" -y >/dev/null 2>&1 || true
# Find and extract the tcltk cab # Download tcltk.msi (contains _tkinter.pyd, tcl/tk DLLs, tcl8.6/, tk8.6/)
for cab in "$TK_EXTRACT/installer"/tcltk*.msi "$TK_EXTRACT/installer"/tcltk*; do TCLTK_MSI="$BUILD_DIR/tcltk.msi"
[ -f "$cab" ] || continue if [ ! -f "$TCLTK_MSI" ]; then
7z x -o"$TK_EXTRACT/tcltk" "$cab" -y >/dev/null 2>&1 || true curl -sL "$MSI_BASE/tcltk.msi" -o "$TCLTK_MSI"
done fi
# Find and extract the lib cab (contains tkinter Python package) # Download lib.msi (contains tkinter/ Python package in the stdlib)
for cab in "$TK_EXTRACT/installer"/lib*.msi "$TK_EXTRACT/installer"/lib*; do LIB_MSI="$BUILD_DIR/lib.msi"
[ -f "$cab" ] || continue if [ ! -f "$LIB_MSI" ]; then
7z x -o"$TK_EXTRACT/lib" "$cab" -y >/dev/null 2>&1 || true curl -sL "$MSI_BASE/lib.msi" -o "$LIB_MSI"
done fi
if command -v msiextract &>/dev/null; then
# Extract both MSIs
(cd "$TK_EXTRACT" && msiextract "$TCLTK_MSI" 2>/dev/null)
(cd "$TK_EXTRACT" && msiextract "$LIB_MSI" 2>/dev/null)
# Copy _tkinter.pyd # Copy _tkinter.pyd
TKINTER_PYD=$(find "$TK_EXTRACT" -name "_tkinter.pyd" 2>/dev/null | head -1) TKINTER_PYD=$(find "$TK_EXTRACT" -name "_tkinter.pyd" 2>/dev/null | head -1)
if [ -n "$TKINTER_PYD" ]; then if [ -n "$TKINTER_PYD" ]; then
cp "$TKINTER_PYD" "$PYTHON_DIR/DLLs/" 2>/dev/null || cp "$TKINTER_PYD" "$PYTHON_DIR/" cp "$TKINTER_PYD" "$PYTHON_DIR/"
echo " Copied _tkinter.pyd" echo " Copied _tkinter.pyd"
else else
echo " WARNING: _tkinter.pyd not found" echo " WARNING: _tkinter.pyd not found in tcltk.msi"
fi fi
# Copy Tcl/Tk DLLs # Copy Tcl/Tk DLLs
for dll in tcl86t.dll tk86t.dll zlib1.dll; do for dll in tcl86t.dll tk86t.dll; do
DLL_PATH=$(find "$TK_EXTRACT" -name "$dll" 2>/dev/null | head -1) DLL_PATH=$(find "$TK_EXTRACT" -name "$dll" 2>/dev/null | head -1)
if [ -n "$DLL_PATH" ]; then if [ -n "$DLL_PATH" ]; then
cp "$DLL_PATH" "$PYTHON_DIR/" cp "$DLL_PATH" "$PYTHON_DIR/"
@@ -158,7 +152,7 @@ if command -v 7z &>/dev/null; then
echo " tkinter bundled successfully" echo " tkinter bundled successfully"
else else
echo " WARNING: 7z not found — skipping tkinter bundling (install p7zip-full)" echo " WARNING: msiextract not found — skipping tkinter (install msitools)"
fi fi
# Add Lib to ._pth so tkinter package is importable # Add Lib to ._pth so tkinter package is importable
@@ -170,7 +164,7 @@ rm -rf "$TK_EXTRACT"
# ── Download pip and install into embedded Python ──────────── # ── Download pip and install into embedded Python ────────────
echo "[4/8] Installing pip into embedded Python..." echo "[5/9] Installing pip into embedded Python..."
SITE_PACKAGES="$PYTHON_DIR/Lib/site-packages" SITE_PACKAGES="$PYTHON_DIR/Lib/site-packages"
mkdir -p "$SITE_PACKAGES" mkdir -p "$SITE_PACKAGES"
@@ -192,7 +186,7 @@ done
# ── Download Windows wheels for all dependencies ───────────── # ── Download Windows wheels for all dependencies ─────────────
echo "[5/8] Downloading Windows dependencies..." echo "[6/9] Downloading Windows dependencies..."
WHEEL_DIR="$BUILD_DIR/win-wheels" WHEEL_DIR="$BUILD_DIR/win-wheels"
mkdir -p "$WHEEL_DIR" mkdir -p "$WHEEL_DIR"
@@ -295,14 +289,14 @@ echo " Installed $WHEEL_COUNT packages"
# ── Build frontend ─────────────────────────────────────────── # ── Build frontend ───────────────────────────────────────────
echo "[6/8] Building frontend bundle..." echo "[7/9] Building frontend bundle..."
(cd "$SERVER_DIR" && npm ci --loglevel error && npm run build) 2>&1 | { (cd "$SERVER_DIR" && npm ci --loglevel error && npm run build) 2>&1 | {
grep -v 'RemoteException' || true grep -v 'RemoteException' || true
} }
# ── Copy application files ─────────────────────────────────── # ── Copy application files ───────────────────────────────────
echo "[7/8] Copying application files..." echo "[8/9] Copying application files..."
mkdir -p "$APP_DIR" mkdir -p "$APP_DIR"
cp -r "$SERVER_DIR/src" "$APP_DIR/src" cp -r "$SERVER_DIR/src" "$APP_DIR/src"
@@ -315,7 +309,7 @@ find "$APP_DIR" -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
# ── Create launcher ────────────────────────────────────────── # ── Create launcher ──────────────────────────────────────────
echo "[8/8] Creating launcher and packaging..." echo "[8b/9] Creating launcher and packaging..."
cat > "$DIST_DIR/LedGrab.bat" << LAUNCHER cat > "$DIST_DIR/LedGrab.bat" << LAUNCHER
@echo off @echo off
@@ -412,8 +406,8 @@ SETUP_NAME="LedGrab-v${VERSION_CLEAN}-win-x64-setup.exe"
SETUP_PATH="$BUILD_DIR/$SETUP_NAME" SETUP_PATH="$BUILD_DIR/$SETUP_NAME"
if command -v makensis &>/dev/null; then if command -v makensis &>/dev/null; then
echo "[9/8] Building NSIS installer..." echo "[9/9] Building NSIS installer..."
makensis -DVERSION="${VERSION_CLEAN}" "$SCRIPT_DIR/installer.nsi" >/dev/null 2>&1 makensis -DVERSION="${VERSION_CLEAN}" "$SCRIPT_DIR/installer.nsi"
if [ -f "$SETUP_PATH" ]; then if [ -f "$SETUP_PATH" ]; then
SETUP_SIZE=$(du -h "$SETUP_PATH" | cut -f1) SETUP_SIZE=$(du -h "$SETUP_PATH" | cut -f1)
echo " Installer: $SETUP_PATH ($SETUP_SIZE)" echo " Installer: $SETUP_PATH ($SETUP_SIZE)"
@@ -421,7 +415,7 @@ if command -v makensis &>/dev/null; then
echo " WARNING: makensis ran but installer not found at $SETUP_PATH" echo " WARNING: makensis ran but installer not found at $SETUP_PATH"
fi fi
else else
echo "[9/8] Skipping installer (makensis not found — install nsis to enable)" echo "[9/9] Skipping installer (makensis not found — install nsis to enable)"
fi fi
echo "" echo ""