livery.workshop._composition¶
livery.workshop._composition ¶
Compose extensions on one package: its set, order, list and name.
A package lists the extensions it is made of in its own
workshop.toml. Its set is that list and every extension the list
requires, transitively, whatever those extensions declare: requires
alone composes a package. Two extensions that cannot share one are
refused by the rules of the phase they both add steps to, two
providers of one key or two owners of one executable, never by a rule
over the pair.
Composition order is the order a set mounts in and is named in: an
extension comes after the extensions it requires, and ties go
alphabetically. A package writes its set as the canonical list, the
minimal one: no extension another member requires, in composition
order. A combination is a set, named by its canonical list joined with
+.
Every function here but extension_set reads declarations through a
lookup and imports nothing: livery.workshop._extensions answers the
lookup from what is installed, and a test from what it declares.
livery.workshop.extension_set is a package's set as the installed
declarations compose it, which the base's readers and the extensions
ask.
Classes:
| Name | Description |
|---|---|
OrderCycle |
A declared order with no first member: each one comes after another. |
Functions:
| Name | Description |
|---|---|
requirements |
The extensions name declares it requires; none when nothing declares it. |
closure |
names and every extension they require, transitively, first met first. |
extension_set |
The extensions package holds: its list and every extension the list requires. |
implied |
Of the extensions names require, transitively, every one. |
nearest_extensions |
Of the extensions names, the ones no other of them requires: the nearest. |
order |
names in order: after what each requires and the edges, ties alphabetical. |
order_or_sorted |
names in composition order, alphabetical when the order has no start. |
cycle_of |
One cycle among waiting, each member before the next, the first alphabetical. |
canonical |
The minimal list of listed's set, in composition order. |
combination |
The name of listed's set: its canonical list joined with |
Attributes:
| Name | Type | Description |
|---|---|---|
Lookup |
|
OrderCycle ¶
Bases: ValueError
A declared order with no first member: each one comes after another.
Attributes:
| Name | Type | Description |
|---|---|---|
members |
The extensions on the cycle, each before the next and the last before the first. |
Source code in packages/workshop/src/livery/workshop/_composition.py
requirements ¶
The extensions name declares it requires; none when nothing declares it.
Source code in packages/workshop/src/livery/workshop/_composition.py
closure ¶
names and every extension they require, transitively, first met first.
A list's set. A name the lookup finds no declaration for stays in it and requires nothing: a sync installs it, and the mount names it until then.
Source code in packages/workshop/src/livery/workshop/_composition.py
extension_set ¶
The extensions package holds: its list and every extension the list requires.
In composition order, as the installed declarations declare it:
each extension after the ones it requires, ties alphabetical, and
alphabetical while the declared order has no start. The list's own
order means nothing. Empty for a package that lists none. The
workspace's own tests (livery.workshop.workspace_suite) hold the
root's set: the extensions [workspace] extensions lists and
every one they require, read from the root's contract on each call.
A step that names extensions judges a package whose set holds one
of them.
A list is composed once for each scan of the installed extensions, so a scan taken after an install composes it again.
Source code in packages/workshop/src/livery/workshop/_composition.py
implied ¶
Of the extensions names require, transitively, every one.
Source code in packages/workshop/src/livery/workshop/_composition.py
nearest_extensions ¶
Of the extensions names, the ones no other of them requires: the nearest.
The rule a query's nearest combine applies, for a combine
function that decides between answers by what each answering
extension requires, transitively. lookup is the one such a
function is called with, passed on as it came. The nearest come in
the order of names; two of them means neither requires the other.
Answers whose requires close a cycle leave none nearest, and
layering.graph names the cycle.
Source code in packages/workshop/src/livery/workshop/_composition.py
order ¶
order(names: Iterable[str], lookup: Lookup, *, requires: bool = True, edges: Iterable[tuple[str, str]] = ()) -> tuple[str, ...]
names in order: after what each requires and the edges, ties alphabetical.
A name outside names orders nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
Iterable[str]
|
The extensions to order. |
required |
lookup
|
Lookup
|
Where each one's declaration is found. |
required |
requires
|
bool
|
Whether a requirement comes first. A phase orders by its context keys alone. |
True
|
edges
|
Iterable[tuple[str, str]]
|
Further |
()
|
Raises:
| Type | Description |
|---|---|
OrderCycle
|
when the declared order has no start, naming the members of one cycle. |
Source code in packages/workshop/src/livery/workshop/_composition.py
order_or_sorted ¶
names in composition order, alphabetical when the order has no start.
For a reader that answers while a cycle in the declared order
stands: the sync that lets a person remove the cycle still runs, and
layering.graph names it.
Source code in packages/workshop/src/livery/workshop/_composition.py
cycle_of ¶
One cycle among waiting, each member before the next, the first alphabetical.
Every member left waits on another member left, so walking from each to one it waits on returns to a name already walked.
Source code in packages/workshop/src/livery/workshop/_composition.py
canonical ¶
The minimal list of listed's set, in composition order.
Raises:
| Type | Description |
|---|---|
OrderCycle
|
when the set's declared order has no start. |
Source code in packages/workshop/src/livery/workshop/_composition.py
combination ¶
The name of listed's set: its canonical list joined with +.
Raises:
| Type | Description |
|---|---|
OrderCycle
|
when the set's declared order has no start. |