setuptools
setuptools is a packaging library and build backend for Python that builds and distributes packages, discovers modules, and defines entry points for applications and plugins.
Installation and Setup
Install it from the Python Package Index (PyPI) into a virtual environment:
Key Features
- Acts as a PEP 517 build backend and supports PEP 621 project metadata in
pyproject.toml. - Discovers packages automatically and supports a
src/layout through simple configuration. - Defines console scripts and plugin entry points that expose commands and extensibility hooks.
- Includes package data and supports extras, environment markers, and optional dependencies.
- Builds pure Python and compiled extension modules and integrates with common build tools.
Usage
A modern project declares its build system and metadata in pyproject.toml:
pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "package-name"
version = "0.1.0"
description = "Example package"
readme = "README.md"
requires-python = ">=3.10"
dependencies = ["requests>=2.32"]
# ...
Install your project in editable mode during development:
$ python -m pip install -e .
Related Resources
Course
Everyday Project Packaging With pyproject.toml
In this Code Conversation video course, you'll learn how to package your everyday projects with pyproject.toml. Playing on the same team as the import system means you can call your project from anywhere, ensure consistent imports, and have one file that'll work for many build systems.
By Leodanis Pozo Ramos • Updated July 18, 2026