flit (Python)¶
The awkward one, and the recipe that found a real defect. flit has no setting for where the package lives, so generation has to target a layout flit already recognises.
| Language | Python |
| Build system | flit |
| Idiom | B -- your project owns the manifest |
| Regeneration | None -- regeneration is an explicit step |
Notes¶
flit refuses to package a module without a docstring, and until this recipe was written the generated __init__.py carried only a generated-by comment -- so flit failed outright with NoDocstringError. The fix went into dsdlc rather than into this recipe: generated packages now carry a docstring and __version__, which is what lets the [project] table above declare both as dynamic and have flit read them out of the package.
flit looks for the package at the project root or under src/, and nowhere else. There is no equivalent of hatchling's packages or poetry's from; [tool.flit.module] directory does not do it. So this recipe generates into src/ while the other three generate into generated/ -- the one place where a Python recipe's --outdir is dictated by the build backend rather than by preference.
Every Python recipe builds its own virtual environment and lets pip fetch the build backend into it. That is correct isolation regardless, and it is the only thing that works on a distribution that marks its interpreter externally managed (PEP 668) -- which the toolshed image does.
Prerequisites¶
| Tool | Why |
|---|---|
python3 |
creates the virtual environment the backend installs into |
Commands¶
Run these from the recipe directory, with dsdl/ and src/ copied alongside it. This is the exact sequence CI runs.
# generate
dsdlc --target-language python dsdl/lanyard --py-package lanyard --outdir src
# virtual environment
python3 -m venv .venv
# install
.venv/bin/pip install -q .
# round-trip
.venv/bin/python src/python/test_roundtrip.py
The types this builds¶
The whole lanyard namespace -- twenty-four definitions, browsable from the showroom overview, where each one is paired with its wire-layout facts and a declaration excerpt in every language.
The build files¶
pyproject.toml¶
# The host owns this file. dsdlc also wrote a pyproject.toml beside the package it generated,
# declaring setuptools; it is inert here because nothing builds that directory.
[build-system]
requires = ["flit_core>=3.9"]
build-backend = "flit_core.buildapi"
[project]
name = "lanyard"
# flit reads both of these out of the package itself -- the docstring becomes the description and
# __version__ becomes the version -- which is why dsdlc emits them into the generated __init__.py.
dynamic = ["version", "description"]
requires-python = ">=3.10"