Files
ytdlp-tui/packaging/build_pex.sh
T
ingo 1471a342d8 1) set the required textual version to version 8.2.8
2) generated installers which bundle the required .venv
2026-09-19 14:38:49 +02:00

48 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build a self-contained Python zipapp (.pex) with Textual 8.2.8 and its
# other dependencies bundled, but WITHOUT a bundled Python interpreter — the
# target machine needs a compatible `python3` already on PATH.
#
# Usage: packaging/build_pex.sh
# Output: dist/ytdlp-tui.pex
# Run it with: python3 dist/ytdlp-tui.pex (or ./dist/ytdlp-tui.pex directly,
# since the shebang points at /usr/bin/env python3 on Unix)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$PROJECT_ROOT"
# pex bundles whatever's under the -D directory verbatim (code AND
# non-Python data files alike), so stage only the runtime files the app
# actually needs at runtime — not tests/, README.md, packaging/, etc.
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
cp -r main.py app lib i18n "$STAGE"/
find "$STAGE" -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
VENV_DIR=".build-venv-pex"
python3 -m venv "$VENV_DIR"
# shellcheck disable=SC1091
source "$VENV_DIR/bin/activate"
pip install --upgrade pip -q
pip install "pex>=2.3" -q
mkdir -p dist
pex \
-o dist/ytdlp-tui.pex \
-D "$STAGE" \
-r requirements-installer.txt \
-e main:main \
--python-shebang '/usr/bin/env python3'
deactivate
echo
echo "Built: dist/ytdlp-tui.pex"
echo "Run with: python3 dist/ytdlp-tui.pex"
echo "Note: needs a compatible python3 (and yt-dlp/ffmpeg on PATH) on the target machine — see packaging/README.md."