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, detecting both the flat-layout and
src/layout without requiring any special 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.
For additional information on related topics, take a look at the following resources:
- How to Publish an Open-Source Python Package to PyPI (Tutorial)
- How to Manage Python Projects With pyproject.toml (Tutorial)
- How to Publish Your Own Python Package to PyPI (Course)
- Publishing Python Packages to PyPI (Course)
- How to Publish an Open-Source Python Package to PyPI (Quiz)
- How to Manage Python Projects With pyproject.toml (Quiz)
By Leodanis Pozo Ramos • Updated Sept. 6, 2026