Flit: Python Build and Publish Tool
Flit is a Python packaging tool for building and publishing pure-Python packages. It provides a CLI for scaffolding (flit init), local installation (flit install), and PyPI publishing (flit publish). Its build backend, flit-core, ships as a separate package with zero runtime dependencies and can be used independently of the flit CLI.
Flit does not manage virtual environments or resolve dependencies; those are handled by separate tools such as uv.
When to use Flit
Flit suits pure-Python libraries that have no C extensions and want a direct path from source to PyPI with minimal configuration. It requires less boilerplate than setuptools and has no lock file or virtualenv features to configure around.
For packages with C extensions or compiled code, use setuptools. For full project management with virtual environments, dependency locking, and publishing in one tool, use uv or hatch.
Key Features
Building and publishing
Flit builds source distributions and wheels from a pure-Python package and publishes them directly to PyPI with flit publish. It handles PyPI authentication via the standard ~/.pypirc file or environment variables and supports TestPyPI as a target.
Configuration
Flit reads project metadata from pyproject.toml following PEP 621. The package version comes from the version field in pyproject.toml or from the __version__ attribute in the package’s __init__.py. Data files committed alongside the Python source are included automatically.
flit-core build backend
flit-core is Flit’s build backend, distributed as a separate package with zero dependencies. It implements the PEP 517 build-system interface and can be used independently of the flit CLI, including in uv projects:
uv init --build-backend flit my-libThis generates a pyproject.toml with flit-core as the build backend:
[build-system]
requires = ["flit_core>=3.4"]
build-backend = "flit_core.buildapi"flit-core handles pure-Python packages only. Its zero-dependency footprint makes it a common backend choice for packages that need lightweight builds with no transitive install overhead.
Pros
- Zero-dependency build backend (flit-core) keeps CI and build environments lean
- Less configuration than setuptools for pure-Python packages
- PEP 621-compatible metadata; no proprietary config format
- Direct publishing to PyPI without a separate upload tool like twine
Cons
- No support for C extensions or compiled code
- No virtual environment management or dependency locking
- Version must come from
__version__in__init__.pyor from pyproject.toml; no dynamic versioning hooks - Smaller contributor base and slower release cadence than setuptools
Learn More
- Flit documentation
- Why use Flit?
- What is a build backend?
- What is a build frontend?
- What is PEP 621?
- What is PEP 517?
- setuptools: for packages with C extensions
- hatch: for full project management
- Example Flit package