{"library":"flit","title":"Flit","description":"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.","status":"active","version":"3.12.0","language":"en","source_language":"en","source_url":"https://github.com/pypa/flit","tags":["packaging","pypi","build-system","pyproject.toml","distribution"],"install":[{"cmd":"pip install flit","lang":"bash","label":"Install Flit"}],"dependencies":[{"reason":"Provides the PEP 517 build backend for Flit. It is automatically installed as a dependency.","package":"flit_core","optional":false}],"imports":[{"note":"Users interact with Flit via its command-line interface (e.g., `flit init`, `flit build`, `flit publish`). The `flit_core` package provides the PEP 517 build backend, with its public API at `flit_core.buildapi`, which is generally used by build frontends, not directly by end-user Python code.","symbol":"flit","correct":"Flit is primarily a command-line tool. Direct Python imports for typical packaging tasks are not common."}],"quickstart":{"code":"# Create a directory for your package, e.g., 'my_package'\n# Inside 'my_package', create 'my_module.py' or a package directory 'my_module/__init__.py'\n\n# my_module/__init__.py (or my_module.py)\n\"\"\"An amazing sample package!\"\"\"\n__version__ = \"0.1.0\"\n\ndef greet(name):\n    return f\"Hello, {name}!\"\n\n# In the root of your package directory (e.g., 'my_package')\n# 1. Initialize Flit (creates pyproject.toml)\n# flit init\n\n# This would be the content of the generated pyproject.toml (adjust details):\n# [build-system]\n# requires = [\"flit_core >=3.2,<4\"]\n# build-backend = \"flit_core.buildapi\"\n\n# [project]\n# name = \"my-module-name\"\n# authors = [{name = \"Your Name\", email = \"your.email@example.com\"}]\n# dynamic = [\"version\", \"description\"]\n# classifiers = [\n#     \"Programming Language :: Python :: 3\",\n#     \"License :: OSI Approved :: MIT License\",\n#     \"Operating System :: OS Independent\",\n# ]\n# requires-python = \">=3.8\"\n\n# 2. Build the package (creates .whl and .tar.gz in 'dist/')\n# flit build\n\n# 3. Publish to PyPI (requires PyPI credentials setup)\n# flit publish --repository pypi\n\n# Example of using the installed package locally:\n# pip install --no-index --find-links=./dist my-module-name\n\n# import my_module\n# print(my_module.greet(\"Flit User\"))","lang":"python","description":"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`."},"warnings":[{"fix":"Convert `flit.ini` to `pyproject.toml` by running `python3 -m flit.tomlify` in your project directory. Ensure `[build-system]` and `[project]` tables are correctly configured according to PEP 621.","message":"Flit 3.0 removed support for the older `flit.ini` configuration file format. Projects must now use `pyproject.toml` for all metadata.","severity":"breaking","affected_versions":">=3.0"},{"fix":"Always install and run Flit using a Python 3 environment (e.g., `python3 -m pip install flit`). Ensure your project's `pyproject.toml` specifies `requires-python` appropriately.","message":"The `flit_core` build backend, which Flit uses, now explicitly requires Python 3. This means that while Flit can package Python 2 modules, it must be run on a Python 3 interpreter.","severity":"breaking","affected_versions":"flit_core >= 3.x"},{"fix":"If you need to support older installers that do not support PEP 517 and require a `setup.py`, you can explicitly include it during `flit build` or `flit publish` (check documentation for specific flags if needed, though typically `--sdist-include-setup-py` was removed in favor of `pyproject.toml` configuration).","message":"In Flit 3.5, the default behavior of `flit build` and `flit publish` changed; they no longer generate a `setup.py` file in the sdist by default. This makes sdists only compatible with tools supporting PEP 517.","severity":"deprecated","affected_versions":">=3.5"},{"fix":"For projects with complex build requirements, consider alternative tools like Setuptools or Hatchling, which are designed to handle such scenarios.","message":"Flit is designed for pure Python packages without complex build steps (e.g., C extensions, bundled Javascript). If your project requires compilation or other build processes, Flit may not be the most suitable tool.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure all external package dependencies are accurately listed in the `[project.dependencies]` section of your `pyproject.toml`.","message":"Flit does not manage your project's dependencies directly; you must declare them in `pyproject.toml` manually. Tools like Poetry or Pipenv offer integrated dependency management.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-06T00:00:00.000Z","next_check":"2026-07-05T00:00:00.000Z"}