|
|
|
|
@@ -47,7 +47,7 @@ echo ""
|
|
|
|
|
# ── Clean ────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
if [ -d "$DIST_DIR" ]; then
|
|
|
|
|
echo "[1/8] Cleaning previous build..."
|
|
|
|
|
echo "[1/9] Cleaning previous build..."
|
|
|
|
|
rm -rf "$DIST_DIR"
|
|
|
|
|
fi
|
|
|
|
|
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_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
|
|
|
|
|
curl -sL "$PYTHON_ZIP_URL" -o "$PYTHON_ZIP_PATH"
|
|
|
|
|
fi
|
|
|
|
|
@@ -66,7 +66,7 @@ unzip -qo "$PYTHON_ZIP_PATH" -d "$PYTHON_DIR"
|
|
|
|
|
|
|
|
|
|
# ── 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)
|
|
|
|
|
if [ -z "$PTH_FILE" ]; then
|
|
|
|
|
echo "ERROR: Could not find python*._pth in $PYTHON_DIR" >&2
|
|
|
|
|
@@ -86,76 +86,85 @@ fi
|
|
|
|
|
echo " Patched $(basename "$PTH_FILE")"
|
|
|
|
|
|
|
|
|
|
# ── Bundle tkinter into embedded Python ───────────────────────
|
|
|
|
|
# Embedded Python doesn't include tkinter. We download it from the
|
|
|
|
|
# official Windows Python nuget package (same version) which contains
|
|
|
|
|
# the _tkinter.pyd, tkinter/ package, and Tcl/Tk DLLs.
|
|
|
|
|
# Embedded Python doesn't include tkinter. We download the individual
|
|
|
|
|
# MSI packages from python.org (tcltk.msi + lib.msi) and extract them
|
|
|
|
|
# using msiextract (from msitools).
|
|
|
|
|
|
|
|
|
|
echo "[3b/8] Bundling tkinter for screen overlay support..."
|
|
|
|
|
echo "[4/9] Bundling tkinter for screen overlay support..."
|
|
|
|
|
|
|
|
|
|
# Python minor version for nuget package (e.g., 3.11.9 -> 3.11)
|
|
|
|
|
PYTHON_MINOR="${PYTHON_VERSION%.*}"
|
|
|
|
|
TK_EXTRACT="$BUILD_DIR/tk-extract"
|
|
|
|
|
rm -rf "$TK_EXTRACT"
|
|
|
|
|
mkdir -p "$TK_EXTRACT"
|
|
|
|
|
|
|
|
|
|
# Download the full Python nuget package (contains all stdlib + DLLs)
|
|
|
|
|
NUGET_URL="https://www.nuget.org/api/v2/package/python/${PYTHON_VERSION}"
|
|
|
|
|
NUGET_PKG="$BUILD_DIR/python-nuget.zip"
|
|
|
|
|
if [ ! -f "$NUGET_PKG" ]; then
|
|
|
|
|
curl -sL "$NUGET_URL" -o "$NUGET_PKG"
|
|
|
|
|
MSI_BASE="https://www.python.org/ftp/python/${PYTHON_VERSION}/amd64"
|
|
|
|
|
|
|
|
|
|
# Download tcltk.msi (contains _tkinter.pyd, tcl/tk DLLs, tcl8.6/, tk8.6/)
|
|
|
|
|
TCLTK_MSI="$BUILD_DIR/tcltk.msi"
|
|
|
|
|
if [ ! -f "$TCLTK_MSI" ]; then
|
|
|
|
|
curl -sL "$MSI_BASE/tcltk.msi" -o "$TCLTK_MSI"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
NUGET_DIR="$BUILD_DIR/python-nuget"
|
|
|
|
|
rm -rf "$NUGET_DIR"
|
|
|
|
|
mkdir -p "$NUGET_DIR"
|
|
|
|
|
unzip -qo "$NUGET_PKG" -d "$NUGET_DIR"
|
|
|
|
|
|
|
|
|
|
# Copy _tkinter.pyd (the C extension)
|
|
|
|
|
TKINTER_PYD=$(find "$NUGET_DIR" -name "_tkinter.pyd" | head -1)
|
|
|
|
|
if [ -n "$TKINTER_PYD" ]; then
|
|
|
|
|
cp "$TKINTER_PYD" "$PYTHON_DIR/"
|
|
|
|
|
echo " Copied _tkinter.pyd"
|
|
|
|
|
else
|
|
|
|
|
echo " WARNING: _tkinter.pyd not found in nuget package"
|
|
|
|
|
# Download lib.msi (contains tkinter/ Python package in the stdlib)
|
|
|
|
|
LIB_MSI="$BUILD_DIR/lib.msi"
|
|
|
|
|
if [ ! -f "$LIB_MSI" ]; then
|
|
|
|
|
curl -sL "$MSI_BASE/lib.msi" -o "$LIB_MSI"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Copy tkinter Python package from the stdlib zip or Lib/
|
|
|
|
|
# The nuget package has Lib/tkinter/
|
|
|
|
|
TKINTER_PKG=$(find "$NUGET_DIR" -type d -name "tkinter" | head -1)
|
|
|
|
|
if [ -n "$TKINTER_PKG" ]; then
|
|
|
|
|
mkdir -p "$PYTHON_DIR/Lib"
|
|
|
|
|
cp -r "$TKINTER_PKG" "$PYTHON_DIR/Lib/tkinter"
|
|
|
|
|
echo " Copied tkinter/ package"
|
|
|
|
|
else
|
|
|
|
|
echo " WARNING: tkinter package not found in nuget package"
|
|
|
|
|
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 Tcl/Tk DLLs (tcl86t.dll, tk86t.dll, etc.)
|
|
|
|
|
for dll in tcl86t.dll tk86t.dll; do
|
|
|
|
|
DLL_PATH=$(find "$NUGET_DIR" -name "$dll" | head -1)
|
|
|
|
|
if [ -n "$DLL_PATH" ]; then
|
|
|
|
|
cp "$DLL_PATH" "$PYTHON_DIR/"
|
|
|
|
|
echo " Copied $dll"
|
|
|
|
|
# Copy _tkinter.pyd
|
|
|
|
|
TKINTER_PYD=$(find "$TK_EXTRACT" -name "_tkinter.pyd" 2>/dev/null | head -1)
|
|
|
|
|
if [ -n "$TKINTER_PYD" ]; then
|
|
|
|
|
cp "$TKINTER_PYD" "$PYTHON_DIR/"
|
|
|
|
|
echo " Copied _tkinter.pyd"
|
|
|
|
|
else
|
|
|
|
|
echo " WARNING: _tkinter.pyd not found in tcltk.msi"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Copy Tcl/Tk data directories (tcl8.6, tk8.6)
|
|
|
|
|
for tcldir in tcl8.6 tk8.6; do
|
|
|
|
|
TCL_PATH=$(find "$NUGET_DIR" -type d -name "$tcldir" | head -1)
|
|
|
|
|
if [ -n "$TCL_PATH" ]; then
|
|
|
|
|
cp -r "$TCL_PATH" "$PYTHON_DIR/$tcldir"
|
|
|
|
|
echo " Copied $tcldir/"
|
|
|
|
|
# Copy Tcl/Tk DLLs
|
|
|
|
|
for dll in tcl86t.dll tk86t.dll; do
|
|
|
|
|
DLL_PATH=$(find "$TK_EXTRACT" -name "$dll" 2>/dev/null | head -1)
|
|
|
|
|
if [ -n "$DLL_PATH" ]; then
|
|
|
|
|
cp "$DLL_PATH" "$PYTHON_DIR/"
|
|
|
|
|
echo " Copied $dll"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Copy tkinter Python package
|
|
|
|
|
TKINTER_PKG=$(find "$TK_EXTRACT" -type d -name "tkinter" 2>/dev/null | head -1)
|
|
|
|
|
if [ -n "$TKINTER_PKG" ]; then
|
|
|
|
|
mkdir -p "$PYTHON_DIR/Lib"
|
|
|
|
|
cp -r "$TKINTER_PKG" "$PYTHON_DIR/Lib/tkinter"
|
|
|
|
|
echo " Copied tkinter/ package"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Copy tcl/tk data directories
|
|
|
|
|
for tcldir in tcl8.6 tk8.6; do
|
|
|
|
|
TCL_PATH=$(find "$TK_EXTRACT" -type d -name "$tcldir" 2>/dev/null | head -1)
|
|
|
|
|
if [ -n "$TCL_PATH" ]; then
|
|
|
|
|
cp -r "$TCL_PATH" "$PYTHON_DIR/$tcldir"
|
|
|
|
|
echo " Copied $tcldir/"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo " tkinter bundled successfully"
|
|
|
|
|
else
|
|
|
|
|
echo " WARNING: msiextract not found — skipping tkinter (install msitools)"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Add Lib to ._pth so tkinter package is importable
|
|
|
|
|
if ! grep -q '^Lib$' "$PTH_FILE"; then
|
|
|
|
|
echo 'Lib' >> "$PTH_FILE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
rm -rf "$NUGET_DIR"
|
|
|
|
|
echo " tkinter bundled successfully"
|
|
|
|
|
rm -rf "$TK_EXTRACT"
|
|
|
|
|
|
|
|
|
|
# ── 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"
|
|
|
|
|
mkdir -p "$SITE_PACKAGES"
|
|
|
|
|
|
|
|
|
|
@@ -177,7 +186,7 @@ done
|
|
|
|
|
|
|
|
|
|
# ── Download Windows wheels for all dependencies ─────────────
|
|
|
|
|
|
|
|
|
|
echo "[5/8] Downloading Windows dependencies..."
|
|
|
|
|
echo "[6/9] Downloading Windows dependencies..."
|
|
|
|
|
WHEEL_DIR="$BUILD_DIR/win-wheels"
|
|
|
|
|
mkdir -p "$WHEEL_DIR"
|
|
|
|
|
|
|
|
|
|
@@ -280,14 +289,14 @@ echo " Installed $WHEEL_COUNT packages"
|
|
|
|
|
|
|
|
|
|
# ── 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 | {
|
|
|
|
|
grep -v 'RemoteException' || true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ── Copy application files ───────────────────────────────────
|
|
|
|
|
|
|
|
|
|
echo "[7/8] Copying application files..."
|
|
|
|
|
echo "[8/9] Copying application files..."
|
|
|
|
|
mkdir -p "$APP_DIR"
|
|
|
|
|
|
|
|
|
|
cp -r "$SERVER_DIR/src" "$APP_DIR/src"
|
|
|
|
|
@@ -300,7 +309,7 @@ find "$APP_DIR" -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
|
|
|
|
|
|
|
|
|
|
# ── Create launcher ──────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
echo "[8/8] Creating launcher and packaging..."
|
|
|
|
|
echo "[8b/9] Creating launcher and packaging..."
|
|
|
|
|
|
|
|
|
|
cat > "$DIST_DIR/LedGrab.bat" << LAUNCHER
|
|
|
|
|
@echo off
|
|
|
|
|
@@ -397,8 +406,8 @@ SETUP_NAME="LedGrab-v${VERSION_CLEAN}-win-x64-setup.exe"
|
|
|
|
|
SETUP_PATH="$BUILD_DIR/$SETUP_NAME"
|
|
|
|
|
|
|
|
|
|
if command -v makensis &>/dev/null; then
|
|
|
|
|
echo "[9/8] Building NSIS installer..."
|
|
|
|
|
makensis -DVERSION="${VERSION_CLEAN}" "$SCRIPT_DIR/installer.nsi" >/dev/null 2>&1
|
|
|
|
|
echo "[9/9] Building NSIS installer..."
|
|
|
|
|
makensis -DVERSION="${VERSION_CLEAN}" "$SCRIPT_DIR/installer.nsi"
|
|
|
|
|
if [ -f "$SETUP_PATH" ]; then
|
|
|
|
|
SETUP_SIZE=$(du -h "$SETUP_PATH" | cut -f1)
|
|
|
|
|
echo " Installer: $SETUP_PATH ($SETUP_SIZE)"
|
|
|
|
|
@@ -406,7 +415,7 @@ if command -v makensis &>/dev/null; then
|
|
|
|
|
echo " WARNING: makensis ran but installer not found at $SETUP_PATH"
|
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|