Skip to content

flit

flit is a build and publishing tool that packages pure Python projects using pyproject.toml and the flit-core build backend.

Installation and Setup

Install it from PyPI:

Language: Windows PowerShell
(venv) PS> py -m pip install flit
Language: Shell
(venv) $ python -m pip install flit

Initialize packaging metadata:

Language: Shell
$ flit init

This creates a new pyproject.toml. If the file already exists, then flit prompts you before overwriting it rather than merging into it. A minimal example looks like:

Language: TOML
[build-system]
requires = ["flit_core >=3.11,<5"]
build-backend = "flit_core.buildapi"

# ...

Key Features

  • Uses pyproject.toml and the flit-core backend.
  • Builds wheels and source distributions with a single command and works well in CI systems.
  • Publishes releases to PyPI or TestPyPI without additional tools once credentials are configured.
  • Supports editable installs with pip install -e . through the backend.
  • Controls sdist contents with include/exclude patterns under [tool.flit.sdist].
  • Selects sdist contents from Git or Mercurial with --use-vcs, which is no longer the default as of flit 4.0.

Usage

Build distributable artifacts:

Language: Shell
$ flit build

Creates dist/*.whl and dist/*.tar.gz.

Publish to PyPI or TestPyPI:

Language: Shell
$ flit publish
$ flit publish --repository testpypi

The --repository value must name a section in your ~/.pypirc, so testpypi only works once you’ve added a [testpypi] entry to that file.

Install the project into the current environment for quick local testing:

Language: Shell
$ flit install

Update only the wheel or sdist if needed:

Language: Shell
$ flit build --format wheel
$ flit build --format sdist

Control what goes into the source distribution:

Language: TOML Filename: pyproject.toml
[tool.flit.sdist]
include = ["src", "README.md", "LICENSE"]
exclude = ["tests", "docs/_build"]
How to Publish an Open-Source Python Package to PyPI

Tutorial

How to Publish an Open-Source Python Package to PyPI

In this step-by-step tutorial, you’ll learn how to create a Python package for your project and how to publish it to PyPI, the Python Package Repository. Quickly get up to speed on everything from naming your package to configuring it using setup.cfg.

intermediate best-practices tools

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated Sept. 8, 2026