PythiloLesson 5 of 5 · progress kept in this browser

Packaging and pyproject

pyproject.toml describes a Python project in one file. Installers and build tools read it.

# pyproject.toml, shown as text
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "shop"
version = "1.2.0"
requires-python = ">=3.12"
dependencies = ["requests>=2.30"]

[project.scripts]
shop = "shop.cli:main"
  • [build-system] names the tool that builds your package.
  • [project] holds the metadata. name is required, and version is too unless the build tool supplies it.
  • dependencies are installed along with your package.
  • [project.scripts] creates command-line entry points.

A build produces a wheel, a ready-to-install archive, and usually a source archive. Code commonly lives in src/shop/, which stops tests from importing the folder by accident instead of the installed package.

The standard library's tomllib reads TOML, so tools can inspect this file with no extra packages.

Your task

Write summarize(text) that parses pyproject text with tomllib and returns {"name", "version", "dependencies", "scripts"}, where dependencies is a list of package names only (for requests>=2.30 that is requests). Missing lists or tables become [] and {}. Raise ValueError if [project], name or version is missing.

All lessons