#!/usr/bin/env bash
# Real demos for P090 "Python uv vs pip: Which One Should You Use?". Runs on a render box with Docker.
# One container stands in for Ana's Ubuntu 24.04 laptop (lab/Dockerfile: Python 3.12, pip and venv from apt).
# uv is installed on camera with Astral's official installer; packages come from PyPI, like on any laptop, and
# every cache starts empty, so the first race is a true cold start for both tools. Ana's tea shop price list is
# served on localhost:8000 inside the container (python3 -m http.server, started off-screen), so app.py has
# something to fetch. Every command shown is typed into a real interactive bash in a pty (demo_driver.py).
set -euo pipefail
cd "$(dirname "$0")"
P=ce-p090
cleanup() { docker rm -f $P-laptop >/dev/null 2>&1 || true; }
cleanup
[ -n "${KEEP:-}" ] || trap cleanup EXIT
docker build -q -t $P-laptop lab >/dev/null
docker run -d --name $P-laptop --hostname laptop $P-laptop sleep infinity >/dev/null
docker exec -d -u ana $P-laptop python3 -m http.server 8000 -d /srv/shop -b 127.0.0.1
sleep 1
python3 - "$P" < demo_driver.py
