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:

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

Initialize packaging metadata:

Shell
$ flit init

This creates or updates pyproject.toml. A minimal example looks like:

TOML
[build-system]
requires = ["flit_core>=3.8,<4"]
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 (pip install -e .) through the backend.
  • Controls sdist contents with include/exclude patterns under [tool.flit.sdist].

Usage

Build distributable artifacts:

Shell
$ flit build

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

Publish to PyPI or TestPyPI:

Shell
$ flit publish
$ flit publish --repository testpypi

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

Shell
$ flit install

Update only the wheel or sdist if needed:

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

Control what goes into the source distribution:

TOML pyproject.toml
[tool.flit.sdist]
include = ["src", "README.md", "LICENSE"]
exclude = ["tests", "docs/_build"]