Project layout & pyproject

P35.project-layout.01 · Audience: guest, it-ml, language-pro

Real LLM grading for this pageLLM grading (this page):

A script becomes a package the moment someone else has to install it. That step is all about one file — pyproject.toml — and one decision: where the code lives. This module has you write a real pyproject.toml, so the pieces that turn a folder of .py files into something pip install-able are yours.

Step 1 / 3pyproject is the source of truth
ⓘ Concept: One file describes the package
pyproject.toml declares the package: its name and version, what it dependencies need, which Python it requires-python, and — in [build-system] — the backend that turns your source into a wheel. There is no setup.py to run: the file is data, read the same way by every tool.

Why it matters — Every modern tool — pip, uv, build — reads pyproject.toml, so one declarative file replaces the old setup.py and configures the whole package.

This repo is the worked example. Its pyproject.toml declares the same tables you are about to write — build backend, project metadata, dependencies:

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "tlab-compute"
version = "0.1.0"
requires-python = ">=3.11"
dependencies = ["numpy", "pandas"]
Ask the mentor about this module

Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.

Ctrl/Cmd + Enter to send

🎓 Practice ladder

2 graded rungs · ~20 min

Write a valid pyproject.toml for a small package, then reason about project layout and installs in an interview-style prompt.

Rung 1 — write a pyproject.toml (graded by parsing it)

Loading exercise…

Rung 2 — project layout & installs (interview)

Loading exercise…

You can declare a package. The next module is about its dependencies — how versions are constrained, and how a lockfile makes a build reproducible.