02.08

Project layout and pyproject.toml

skillmaxingPython with AIProject layout and pyproject.toml
Visual lesson

Project layout and pyproject.toml

Included with Pro · 4:28
Lessons · 1,026 words

A Python project has two layout problems. The first is imports: from relay.tickets import Ticket has to find relay, and where Python looks depends on the current directory, which is why a test suite that passes from the project root fails from one level down. The second is configuration: pytest, ruff, mypy and the build tool each want settings, and a project that scatters them across five dotfiles is one nobody wants to maintain.

Both have a standard answer now. Put the package in a src/ directory and install it into the environment, so imports resolve the same way everywhere. And put all configuration in pyproject.toml, which every modern tool reads, so there is one file to open.

Pro

Continue reading

Pro unlocks every video lesson, the full notes and runnable code across the Python with AI course, from the language itself to agents, MCP, Langfuse and deployment.

Unlock full access to
Python with AIAI researchComplete system design
30% off with LAUNCH30ends in 7h 40m
Buy now
View all plans ·Already Pro? Sign in
124 online