Frontend Labs
⋯

Part 0 — Start here

0.1 Setup: Python, uv, ruff, a type checker, and an editor

Do not use the Python that came with your operating system for your own work. macOS ships an old python3 for its own tools, and Linux distributions use the system Python to run the package manager. Installing packages into it can break the OS. Install your own Python per project with uv, a fast package and project manager written in Rust:

# macOS / Linux. Installs the single `uv` binary into ~/.local/bin.
curl -LsSf https://astral.sh/uv/install.sh | sh

uv python install 3.13 3.14     # managed CPython builds, side by side
uv python list                  # what is installed and what is available

uv init py-labs && cd py-labs   # pyproject.toml, .python-version, main.py
uv add httpx rich               # add dependencies; writes uv.lock
uv add --dev ruff pytest mypy   # tools only needed while developing
uv run main.py                  # runs inside the project's virtual env (.venv/)
uv run pytest                   # any tool, same environment

What each tool does:

Tool Job Replaces
uv installs Python, creates .venv, resolves and locks dependencies, runs commands pyenv, venv, pip, pip-tools, pipx, poetry
ruff linter and formatter, one binary flake8, isort, black, pyupgrade
mypy or pyright static type checker (Ch 18) —
pytest test runner (Ch 20) unittest boilerplate
uv run ruff check .          # lint
uv run ruff format .         # format (black-compatible)
uv run mypy src/             # type-check

If you cannot install uv, the standard library has everything needed for a virtual environment:

python3.13 -m venv .venv          # an isolated interpreter + site-packages
source .venv/bin/activate         # Windows: .venv\Scripts\activate
python -m pip install httpx       # always `python -m pip`, never a bare `pip`

python -m pip guarantees that the pip you run belongs to the python you mean. A bare pip can belong to a different interpreter on your PATH, and then packages land somewhere your program never looks. That is the cause of most "I installed it but ModuleNotFoundError" questions.

Editor: VS Code with the Python and Pylance extensions, or PyCharm. Turn on type checking ("python.analysis.typeCheckingMode": "standard"). Inferred types shown inline do for Python what rust-analyzer does for Rust: they answer "what is this value?" without running the code.

Lab machine: Parts I–III and V–IX run on macOS, Linux, or WSL. Part IV (Systems Python) needs Linux, because /proc, namespaces, and cgroups exist only there. Use the lab VM or container from the OS guide §0.3:

# A disposable Linux box with Python 3.14 and uv, from macOS:
docker run --rm -it --privileged -v "$PWD":/work -w /work python:3.14-slim bash
pip install uv     # inside the container

For Part VII you also need the data stack. On Apple Silicon, PyTorch uses the GPU through the mps device; on Linux with an NVIDIA card, use the CUDA wheels from pytorch.org:

uv add numpy pandas polars matplotlib scikit-learn
uv add torch transformers datasets tokenizers   # ~2 GB; only for Ch 58–61

Generated from real-life-python-guide.md · 8 Oct 2026 16:36