Python, from Zero, for AILesson 68 of 89

Module 7 · Objects, generators and the shape a larger program takes

pyproject.toml: making your project installable, and a command somebody can type

In this lesson

  • 9 min read
  • 8 reading sections
  • Knowledge check
  • Lesson 9 of 10 in this chapter

This chapter’s goalRestructure a growing script into classes and dataclasses with a swappable provider behind one interface, implement the dunder methods that let your objects work with for, len, in and with, write a decorator that retries or caches, run a type checker and act on its output, make the project installable as a command with pyproject.toml, and profile it to say from measurement rather than guesswork where the time goes.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch1:40Not available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 10Free · no account needed
Lesson steps

From a folder to a thing

Module 3 laid out a project so that imports work. Module 5 pinned its dependencies. What remains is turning it into something that can be installed (by you on another machine, by a colleague, by a server) and run with one word instead of python -m tagger.cli --input ....

The file that does it is pyproject.toml, at the root of the project:

TOML
[build-system]
requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta"

[project]
name = "tagger"
version = "0.1.0"
description = "Tag customer messages with a model"
requires-python = ">=3.10"
dependencies = [
    "requests>=2.31,<3",
    "pydantic>=2,<3",
]

[project.optional-dependencies]
dev = ["pytest", "pyright", "ruff"]

[project.scripts]
tagger = "tagger.cli:main"

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Stuck on something?Ask Divya, your AI tutor

How to cite: Addaly (2026) ‘pyproject.toml: making your project installable, and a command somebody can type’, in Python, from Zero, for AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/python-for-ai/packaging-with-pyproject (Accessed: 21 November 2026).