Resolution¶
sources
¶
Packages on disk and where they come from.
A Package is a manifest and the directory its modules live in, together
with how it was found: a directory named by a path dependency, a commit of a
git repository, an index entry (which names a repository and a commit), or
the standard library that ships with quivers. PackageSources materializes
each kind, reading git repositories through the project cache.
Package
didactic-model
¶
Package(*, manifest: Manifest, directory: str, source: SourceKind, location: str = '', commit: str = '', revision: str = '', implicit: bool = False, published: tuple[LockedModule, ...] = ())
Bases: Model
A package's manifest and the place its modules are.
| ATTRIBUTE | DESCRIPTION |
|---|---|
manifest |
Its manifest.
TYPE:
|
directory |
Its directory, absolute.
TYPE:
|
source |
How it was found.
TYPE:
|
location |
For a path dependency, the directory relative to the root package; for a git dependency, the repository; for an indexed one, the index's repository; empty for the root and the standard library.
TYPE:
|
commit |
The commit of its source, for
TYPE:
|
revision |
For
TYPE:
|
implicit |
Whether every package depends on it without saying so (the standard library).
TYPE:
|
published |
For an indexed version, the module hashes its index entry publishes.
TYPE:
|
version
property
¶
version: Version
The package's version.
| RETURNS | DESCRIPTION |
|---|---|
Version
|
|
module_root
¶
The directory module paths of this package are relative to.
| RETURNS | DESCRIPTION |
|---|---|
Path
|
|
module_paths
¶
Every module of the package: each .qvr file in its namespace.
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
The dotted module paths, sorted. |
Source code in src/quivers/packages/sources.py
describe
¶
The package as diagnostics name it.
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/packages/sources.py
PackageSources
¶
PackageSources(root: Path, cache: GitCache)
Materialize packages from their sources.
| PARAMETER | DESCRIPTION |
|---|---|
root
|
The root package's directory, which path dependencies are recorded relative to.
TYPE:
|
cache
|
The project's git cache.
TYPE:
|
Source code in src/quivers/packages/sources.py
root_package
¶
root_package() -> Package
The root package.
| RETURNS | DESCRIPTION |
|---|---|
Package
|
The package whose manifest is in the root directory. |
| RAISES | DESCRIPTION |
|---|---|
ManifestError
|
If its manifest is missing or malformed. |
Source code in src/quivers/packages/sources.py
directory
¶
directory(directory: Path) -> Package
The package in a directory, as a path dependency.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
The package's directory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Package
|
The package, located relative to the root package. |
| RAISES | DESCRIPTION |
|---|---|
ManifestError
|
If the directory has no manifest or it is malformed. |
Source code in src/quivers/packages/sources.py
git_manifest
¶
git_manifest(url: str, commit: str) -> Manifest
The manifest at a commit of a repository, without extracting it.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The repository.
TYPE:
|
commit
|
The commit.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Manifest
|
The manifest at the repository's top. |
| RAISES | DESCRIPTION |
|---|---|
ManifestError
|
If the commit has no manifest or it is malformed. |
GitError
|
If the commit cannot be read. |
Source code in src/quivers/packages/sources.py
git
¶
git(url: str, commit: str, *, source: SourceKind = 'git', revision: str = '') -> Package
The package at a commit of a repository, extracted into the cache.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The repository.
TYPE:
|
commit
|
The commit.
TYPE:
|
source
|
TYPE:
|
revision
|
The revision the depending manifest names.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Package
|
The package. |
| RAISES | DESCRIPTION |
|---|---|
ManifestError
|
If the commit has no manifest or it is malformed. |
GitError
|
If the commit cannot be read. |
Source code in src/quivers/packages/sources.py
standard_library
¶
standard_library(root: Path = STANDARD_LIBRARY_ROOT) -> Package
The standard library, the package every package depends on.
Its version is the version of quivers it ships with, and every module
below std/ is exposed.
| PARAMETER | DESCRIPTION |
|---|---|
root
|
The directory its
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Package
|
The package. |
Source code in src/quivers/packages/sources.py
resolve
¶
Dependency resolution by minimal version selection.
Every requirement on an indexed package names the minimum version its dependent was built against. Resolution walks the requirement graph from the root package, visiting every version any requirement names together with that version's own requirements, and selects for each package the largest minimum any visited requirement names [@cox2018minimal]. There is no search and no backtracking: the selection is a function of the manifests and the index, so it is the same on every machine and never moves to a newer version on its own.
A package from a directory, a git commit, or the standard library is pinned: its version is the one its manifest says, every requirement on it must name that same source, and every indexed requirement on it must be satisfied by that version. Two requirements on one package that no single version satisfies (two compatibility lines, a pinned version older than a requirement, two different sources) are refused with an explanation in the style of PubGrub [@pubgrub2018solver]: a chain of "because" steps from the two conflicting requirements up to the root.
ResolutionError
¶
Bases: ValueError
Requirements no build satisfies.
Its message says the explanation, one derivation step per line.
Origin
didactic-model
¶
Bases: Model
Where one requirement says a package comes from.
| ATTRIBUTE | DESCRIPTION |
|---|---|
kind |
TYPE:
|
location |
The absolute directory, the repository, or the index's repository.
TYPE:
|
commit |
The git commit, for
TYPE:
|
pinned
¶
Whether this origin fixes one version.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True for a directory, a git commit, and the standard library. |
Node
didactic-model
¶
Requirement
didactic-model
¶
Requirement(*, dependent: Node | None = None, name: str, origin: Origin, minimum: Version | None = None, written: str)
Bases: Model
One dependency edge of the requirement graph.
| ATTRIBUTE | DESCRIPTION |
|---|---|
dependent |
The package that requires;
TYPE:
|
name |
The package required.
TYPE:
|
origin |
Where the dependent says it comes from.
TYPE:
|
minimum |
For an indexed requirement, the minimum version.
TYPE:
|
written |
The requirement as explanations name it (
TYPE:
|
Edge
didactic-model
¶
Bases: Model
The dependencies of one package of a resolved build.
| ATTRIBUTE | DESCRIPTION |
|---|---|
package |
The package.
TYPE:
|
dependencies |
The packages it depends on, sorted.
TYPE:
|
Resolution
didactic-model
¶
Resolution(*, root: Package, packages: tuple[Package, ...] = (), edges: tuple[Edge, ...] = (), indexes: tuple[LockedIndex, ...] = ())
Bases: Model
A resolved build.
| ATTRIBUTE | DESCRIPTION |
|---|---|
root |
The root package.
TYPE:
|
packages |
Every other package of the build, by name.
TYPE:
|
edges |
Each package's dependencies after selection.
TYPE:
|
indexes |
The index commits read, by name.
TYPE:
|
package
¶
package(name: str) -> Package | None
The selected package of a name, the root included.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
A package name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Package | None
|
The package, or |
Source code in src/quivers/packages/resolve.py
dependencies_of
¶
The packages one package depends on, the implicit ones included.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
A package of the build.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
Their names, sorted. |
Source code in src/quivers/packages/resolve.py
Resolver
¶
Resolver(sources: PackageSources, *, locked: Lockfile | None = None, standard_library_root: Path = STANDARD_LIBRARY_ROOT)
Resolve a root package's requirements by minimal version selection.
| PARAMETER | DESCRIPTION |
|---|---|
sources
|
Materializes packages.
TYPE:
|
locked
|
A lockfile whose index and git commits to read instead of the newest ones, so a locked build resolves offline to the same build.
TYPE:
|
standard_library_root
|
Where the standard library's modules are.
TYPE:
|
Source code in src/quivers/packages/resolve.py
resolve
¶
resolve() -> Resolution
Resolve the root package's build.
| RETURNS | DESCRIPTION |
|---|---|
Resolution
|
Every selected package, its dependencies, and the index commits read. |
| RAISES | DESCRIPTION |
|---|---|
ResolutionError
|
If no build satisfies the requirements, with the explanation. |
ManifestError
|
If a manifest is malformed. |
GitError
|
If a repository cannot be read. |
Source code in src/quivers/packages/resolve.py
explain_conflict
¶
explain_conflict(left: Requirement, right: Requirement, reason: str, by_node: Mapping[str, Requirement], root: str) -> str
Explain two requirements no single version satisfies.
The explanation derives an incompatibility from the two requirements and lifts it, one dependency edge at a time, until both sides are the root, as PubGrub reports a failure.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
The conflicting requirements.
TYPE:
|
right
|
The conflicting requirements.
TYPE:
|
reason
|
Why no version satisfies both.
TYPE:
|
by_node
|
The requirement that first reached each visited node.
TYPE:
|
root
|
The root package's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The explanation, one step per line. |
Source code in src/quivers/packages/resolve.py
explain_missing
¶
explain_missing(requirement: Requirement, reason: str, by_node: Mapping[str, Requirement], root: str) -> str
Explain a requirement nothing satisfies.
| PARAMETER | DESCRIPTION |
|---|---|
requirement
|
The requirement.
TYPE:
|
reason
|
Why nothing satisfies it.
TYPE:
|
by_node
|
The requirement that first reached each visited node.
TYPE:
|
root
|
The root package's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The explanation, one step per line. |