Manifests and versions¶
manifest
¶
The package manifest, qvr.toml.
A package is a directory with a qvr.toml manifest::
[package]
name = "discourse"
version = "1.2.0"
modules = ["discourse.score", "discourse.model"]
source = "src"
[holes]
Worlds = { default = "worlds.boolean" }
[links]
Lexicon = "lexicon.core"
[dependencies]
worlds = { path = "../worlds" }
lexicon = { git = "https://example.org/lexicon.git", rev = "v2.0.0" }
grammar = { version = "1.4.0", index = "main" }
[indexes]
main = "https://example.org/qvr-index.git"
The package's name is the first segment of every module path it provides,
so the modules of two packages never share a path. modules lists the
modules other packages may import; the package's other modules are private
to it. holes lists the package's holes (declared in its modules with
hole P : S) and the module that fills each when a dependent links none.
links fills holes for builds of this package. A dependency comes from a
directory (path), a git repository (git, at rev: a commit, a tag,
or a branch), or a package index (version, the minimum version the
package was built against, looked up in one of indexes).
LOCKFILE_NAME
module-attribute
¶
The lockfile's file name, beside the manifest.
TomlValue
¶
A value of a parsed TOML document.
ManifestError
¶
Bases: ValueError
A manifest that does not describe a package.
Its message says what is wrong, naming the file and the key.
DependencySource
didactic-model
¶
Bases: TaggedUnion
Where a dependency comes from.
PathSource
didactic-model
¶
Bases: DependencySource
A dependency found in a directory.
| ATTRIBUTE | DESCRIPTION |
|---|---|
path |
The directory, relative to the depending package's directory, in POSIX spelling.
TYPE:
|
GitSource
didactic-model
¶
Bases: DependencySource
A dependency found in a git repository.
| ATTRIBUTE | DESCRIPTION |
|---|---|
url |
The repository, as
TYPE:
|
rev |
A commit, tag, or branch; the repository's default branch when empty.
TYPE:
|
IndexSource
didactic-model
¶
IndexSource(*, index: str, minimum: Version, kind: Literal['index'] = 'index')
Bases: DependencySource
A dependency looked up in a package index.
| ATTRIBUTE | DESCRIPTION |
|---|---|
index |
The index's name in the depending package's
TYPE:
|
minimum |
The version the dependent was built against; any later version on its compatibility line satisfies it.
TYPE:
|
Dependency
didactic-model
¶
Dependency(*, name: str, source: DependencySource)
Bases: Model
One dependency of a package.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The depended-on package's name.
TYPE:
|
source |
Where it comes from.
TYPE:
|
HoleSpec
didactic-model
¶
Bases: Model
A hole a package exposes.
| ATTRIBUTE | DESCRIPTION |
|---|---|
path |
The hole's module path.
TYPE:
|
default |
The module that fills it when no link does; empty for none.
TYPE:
|
LinkSpec
didactic-model
¶
Bases: Model
A hole a package fills for its own builds.
| ATTRIBUTE | DESCRIPTION |
|---|---|
hole |
The hole's module path.
TYPE:
|
module |
The filling module's path.
TYPE:
|
IndexSpec
didactic-model
¶
Bases: Model
A package index a manifest may look dependencies up in.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The name dependencies refer to it by.
TYPE:
|
url |
The index's git repository.
TYPE:
|
Manifest
didactic-model
¶
Manifest(*, name: str, version: Version, modules: tuple[str, ...] = (), source: str = '.', holes: tuple[HoleSpec, ...] = (), links: tuple[LinkSpec, ...] = (), dependencies: tuple[Dependency, ...] = (), indexes: tuple[IndexSpec, ...] = ())
Bases: Model
A parsed qvr.toml.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The package's name, the first segment of its module paths.
TYPE:
|
version |
The package's version.
TYPE:
|
modules |
The modules dependents may import, sorted.
TYPE:
|
source |
The directory below the package's directory that module paths are
relative to (
TYPE:
|
holes |
The holes the package exposes, by path.
TYPE:
|
links |
The links, by hole path.
TYPE:
|
dependencies |
The dependencies, by name.
TYPE:
|
indexes |
The indexes, by name.
TYPE:
|
dependency
¶
dependency(name: str) -> Dependency | None
The dependency on a package.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The package's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dependency | None
|
The dependency, or |
Source code in src/quivers/packages/manifest.py
index_url
¶
The repository of a named index.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The index's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Its repository. |
| RAISES | DESCRIPTION |
|---|---|
ManifestError
|
If the manifest declares no such index. |
Source code in src/quivers/packages/manifest.py
provides
¶
Whether a module path is in this package's namespace.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
A module path's segments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether its first segment is the package's name. |
Source code in src/quivers/packages/manifest.py
parse_manifest
¶
parse_manifest(text: str, *, where: str = MANIFEST_NAME) -> Manifest
Read a manifest from its text.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The TOML text.
TYPE:
|
where
|
The file name diagnostics name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Manifest
|
The manifest. |
| RAISES | DESCRIPTION |
|---|---|
ManifestError
|
If the text is not TOML, a key is unknown or mistyped, a name is not a package name, a module is outside the package's namespace, or a dependency names an undeclared index. |
Source code in src/quivers/packages/manifest.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
read_manifest
¶
read_manifest(directory: Path) -> Manifest
Read the manifest of a package directory.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
The package's directory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Manifest
|
Its manifest. |
| RAISES | DESCRIPTION |
|---|---|
ManifestError
|
If the directory has no manifest or the manifest is malformed. |
Source code in src/quivers/packages/manifest.py
find_package_root
¶
The nearest directory at or above a path that holds a manifest.
| PARAMETER | DESCRIPTION |
|---|---|
start
|
A file or directory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path | None
|
The package's directory, or |
Source code in src/quivers/packages/manifest.py
versions
¶
Semantic versions, compatibility lines, and version requirements.
A package version is MAJOR.MINOR.PATCH. Two versions are compatible
when they share a compatibility line: the leftmost nonzero component and
everything before it (1.4.2 is on line 1, 0.3.7 on 0.3,
0.0.4 on 0.0.4). A change that breaks dependents moves a package to
a new line; any other change stays on its line. A dependency names the
minimum version it was built against, and any later version on the same
line satisfies it, which is what minimal version selection needs: a
requirement is a lower bound within a line, never a range.
CHANGE_LEVELS
module-attribute
¶
CHANGE_LEVELS: tuple[ChangeLevel, ...] = ('none', 'patch', 'minor', 'major')
The change levels from least to most.
ChangeLevel
¶
How much a change to a package moves its version: major breaks
dependents, minor adds to the interface (or changes the meaning of a
program fit to data), patch changes bodies only, none changes
nothing.
VersionError
¶
Bases: ValueError
A version or a requirement that does not parse.
Its message says what is malformed, quoting the text.
Version
didactic-model
¶
Bases: Model
A semantic version MAJOR.MINOR.PATCH.
| ATTRIBUTE | DESCRIPTION |
|---|---|
major, minor, patch |
The components.
TYPE:
|
parse
classmethod
¶
parse(text: str) -> Version
Read a version.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Version
|
The version. |
| RAISES | DESCRIPTION |
|---|---|
VersionError
|
If the text is not a version. |
Source code in src/quivers/packages/versions.py
key
¶
The version as a sortable key.
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, int, int]
|
|
render
¶
line
¶
The compatibility line: components up to the leftmost nonzero one.
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, ...]
|
|
Source code in src/quivers/packages/versions.py
render_line
¶
The compatibility line as text.
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/packages/versions.py
compatible
¶
compatible(other: Version) -> bool
Whether two versions share a compatibility line.
| PARAMETER | DESCRIPTION |
|---|---|
other
|
Another version.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether one may stand in for the other. |
Source code in src/quivers/packages/versions.py
bumped
¶
bumped(level: ChangeLevel) -> Version
The next version after a change of a given level.
The leftmost nonzero component is the one a breaking change moves,
so on line 0.y a breaking change bumps y and any other change
bumps the patch; on line 0.0.z every change bumps z.
| PARAMETER | DESCRIPTION |
|---|---|
level
|
The change.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Version
|
The version that publishes it (this version for |
Source code in src/quivers/packages/versions.py
level_to
¶
level_to(later: Version) -> ChangeLevel
The largest change a later version may publish over this one.
| PARAMETER | DESCRIPTION |
|---|---|
later
|
A version greater than this one.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ChangeLevel
|
|
| RAISES | DESCRIPTION |
|---|---|
VersionError
|
If |
Source code in src/quivers/packages/versions.py
parse_requirement
¶
parse_requirement(text: str) -> Version
Read a dependency's version requirement: the minimum version it needs.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
A version such as
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Version
|
The minimum; any later version on its compatibility line satisfies the requirement. |
| RAISES | DESCRIPTION |
|---|---|
VersionError
|
If the text is a range or not a version: minimal version selection reads a requirement as the version the dependent was built against. |
Source code in src/quivers/packages/versions.py
level_at_least
¶
level_at_least(level: ChangeLevel, floor: ChangeLevel) -> ChangeLevel
The larger of two change levels.
| PARAMETER | DESCRIPTION |
|---|---|
level
|
Two levels.
TYPE:
|
floor
|
Two levels.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ChangeLevel
|
The one further along |