Files

Installers

Two ways to build a distributable bundle, both producing a single file under dist/. Both bundle the app's own code, the i18n library, the i18n translation data, and app/styles.tcss. Neither bundles yt-dlp or ffmpeg — the app runs them as external command-line tools via subprocess, never imports them as Python libraries, so both still need to be installed separately and be on PATH on the machine that runs the installer's output, regardless of which installer you use.

build_pyinstaller.sh build_pex.sh
Bundles a Python interpreter Yes No — needs a compatible python3 already on the target machine
Bundles Textual 8.2.8 + deps Yes Yes
Output dist/ytdlp-tui (native executable) dist/ytdlp-tui.pex (zipapp)
Run it with ./dist/ytdlp-tui python3 dist/ytdlp-tui.pex
Typical size ~35-40 MB ~3-4 MB

Both scripts create their own throwaway build venv (.build-venv-*, already git-ignored) so they don't touch whatever environment you're already using, and both read dependency versions from requirements-installer.txt — the subset of requirements.txt the app actually imports (just textual==8.2.8). yt-dlp is deliberately not pip-installed into either bundle: even if it were, that would only add the yt_dlp Python package inside the bundle, not put a yt-dlp executable on the target machine's PATH — which is what the app's subprocess calls actually need.

Build

# Bundled-Python installer (PyInstaller)
packaging/build_pyinstaller.sh
./dist/ytdlp-tui

# No-bundled-Python zipapp (pex)
packaging/build_pex.sh
python3 dist/ytdlp-tui.pex

Run either from the project root. Both are Bash scripts (Linux/macOS); on Windows use WSL or adapt them to PowerShell — the underlying pyinstaller/ pex invocations are unchanged.

How the data files travel

app/tui_app.py's CSS_PATH and main.py's PROJECT_ROOT are both resolved through app/runtime_paths.bundle_root() rather than a plain Path(__file__).parent, because a frozen PyInstaller build's Python modules run from inside an embedded archive with no real file on disk — __file__-relative resolution would silently point at a path that doesn't exist. bundle_root() returns:

  • sys._MEIPASS when running under a PyInstaller build (where --add-data files are actually extracted to), or
  • the directory containing main.py otherwise — true for a plain source checkout, and also for a pex zipapp, since pex extracts its bundled sources to a cache directory on first run and imports them from there like a normal checkout.

The PyInstaller spec (packaging/pyinstaller/ytdlp-tui.spec) explicitly adds i18n/ and app/styles.tcss as datas so they land next to _MEIPASS at the same relative paths bundle_root() expects. It also runs collect_all("textual") — without it, the frozen build fails the first time a lazily-loaded widget (e.g. MarkdownViewer, opened via Ctrl+A) is used, since Textual imports some of its own widgets on demand through __getattr__, which PyInstaller's static analysis can't see.

The pex build doesn't need any of this special-casing: -D <staging dir> bundles a plain copy of main.py, app/, lib/, i18n/ verbatim (code and data files alike), preserving the exact same relative layout as a normal checkout.

Verifying a build

Both scripts were smoke-tested end to end (not just "it starts"): run under a pty, the full main screen renders with translated labels and the external stylesheet applied, and Ctrl+A correctly opens the MarkdownViewer showing i18n/en/help.md's actual content — confirming both the bundled stylesheet and the bundled translation/help data resolve correctly in each packaging mode.