Skip to content
Latchkey

flit Build "Missing version or docstring" in pyproject.toml CI

flit derives version and description from your module’s __version__ and its docstring. If the module lacks either - or [project] does not mark them dynamic - flit_core cannot assemble the metadata and the build fails.

What this error means

A flit build fails with Cannot package module without a version string or Missing docstring in .... The build expects the source module to carry that metadata and stops when it is absent.

Build output
flit_core.common.NoVersionError: Cannot package module without a version string.
Please define a `__version__ = "x.y.z"` in your module.

Common causes

Module missing __version__ or docstring

flit reads __version__ for the version and the top-of-module docstring for the description. A module without them gives flit nothing to record.

Fields not declared dynamic in [project]

When [project] exists, version/description sourced from the module must be listed under dynamic, or flit reports them as missing.

How to fix it

Add __version__ and a module docstring

src/myapp/__init__.py
"""A short one-line description of the package."""

__version__ = "1.0.0"

Mark them dynamic for flit

Tell flit to pull these from the module by listing them as dynamic.

pyproject.toml
[project]
name = "myapp"
dynamic = ["version", "description"]

[build-system]
requires = ["flit_core>=3.4"]
build-backend = "flit_core.buildapi"

How to prevent it

  • Keep __version__ and a docstring in the package’s top module.
  • List flit-sourced fields under [project].dynamic.
  • Run flit build locally after metadata changes.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →