Flit

3.12.0 · active · verified Mon Apr 06

Flit is a simple yet effective packaging tool for pure Python packages, focusing on streamlining the process of putting modules and packages on PyPI. It handles creating source distributions (sdists) and wheels, and publishing them. The current stable version is 3.12.0, with releases occurring as needed to incorporate fixes and new features, typically following a minor version increment cadence.

Warnings

Install

Imports

Quickstart

To get started with Flit, first create your Python module or package with a `__version__` attribute. Then, navigate to your project's root directory and run `flit init` to generate a `pyproject.toml` file. This file will contain your package's metadata. You can then build your distribution files using `flit build` and publish them to PyPI with `flit publish`.

# Create a directory for your package, e.g., 'my_package'
# Inside 'my_package', create 'my_module.py' or a package directory 'my_module/__init__.py'

# my_module/__init__.py (or my_module.py)
"""An amazing sample package!"""
__version__ = "0.1.0"

def greet(name):
    return f"Hello, {name}!"

# In the root of your package directory (e.g., 'my_package')
# 1. Initialize Flit (creates pyproject.toml)
# flit init

# This would be the content of the generated pyproject.toml (adjust details):
# [build-system]
# requires = ["flit_core >=3.2,<4"]
# build-backend = "flit_core.buildapi"

# [project]
# name = "my-module-name"
# authors = [{name = "Your Name", email = "your.email@example.com"}]
# dynamic = ["version", "description"]
# classifiers = [
#     "Programming Language :: Python :: 3",
#     "License :: OSI Approved :: MIT License",
#     "Operating System :: OS Independent",
# ]
# requires-python = ">=3.8"

# 2. Build the package (creates .whl and .tar.gz in 'dist/')
# flit build

# 3. Publish to PyPI (requires PyPI credentials setup)
# flit publish --repository pypi

# Example of using the installed package locally:
# pip install --no-index --find-links=./dist my-module-name

# import my_module
# print(my_module.greet("Flit User"))

view raw JSON →