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
Tutorial
How to Manage Python Projects With pyproject.toml
Learn how to manage Python projects with the pyproject.toml configuration file. In this tutorial, you'll explore key use cases of the pyproject.toml file, including configuring your build, installing your package locally, managing dependencies, and publishing your package to PyPI.
For additional information on related topics, take a look at the following resources:
- Everyday Project Packaging With pyproject.toml (Course)
- How to Publish an Open-Source Python Package to PyPI (Tutorial)
- How to Manage Python Projects With pyproject.toml (Quiz)
- Publishing Python Packages to PyPI (Course)
- How to Publish Your Own Python Package to PyPI (Course)
- How to Publish an Open-Source Python Package to PyPI (Quiz)
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Leodanis Pozo Ramos • Updated Oct. 31, 2026