flit (Python)¶
The awkward one: 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. Generated packages carry a docstring and __version__, so the [project] table above declares both as dynamic and flit reads 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/; of the four, only here does the build backend dictate --outdir rather than preference.
Every Python recipe builds its own virtual environment and lets pip fetch the build backend into it. That is correct isolation regardless, and on a distribution that marks its interpreter externally managed (PEP 668) -- which the toolshed image does -- nothing else works.
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 --versioned-type-names 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.
[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"