Interview Prep/Build Tools (Java, Node.js, Python, .NET)/Python builds (pip, venv, requirements.txt)

What are Poetry and uv?

IntermediateConceptPython builds (pip, venv, requirements.txt)
Answer

Short answer

Both are tools that manage Python dependencies with a lockfile and handle virtual environments for you. Poetry (poetry.lock) has been popular for years. uv (uv.lock), from Astral, is a very fast newer tool that replaces pip, pip-tools, venv and Poetry, and installs packages in seconds.

Common commands

Task Poetry uv
Add a package poetry add fastapi uv add fastapi
Install from lock (CI) poetry install --no-root --only main uv sync --frozen --no-dev
Run a command in the env poetry run pytest uv run pytest
Update the lock poetry lock uv lock

Dockerfile with uv

FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
WORKDIR /app
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-dev
COPY . .
CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

What to say in the interview

"Poetry and uv both give lockfile-based, reproducible installs and manage venvs. uv is much faster, which noticeably cuts CI time. Whichever the repo uses, CI installs from the lockfile in frozen mode."

All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: Python apps: pip, venv & requirements.txt

More on Python builds (pip, venv, requirements.txt)