Lockfiles and indexes¶
lockfile
¶
The lockfile, qvr.lock: every package of a build, pinned by content.
qvr lock resolves a package's dependencies and writes the result beside
its manifest. The lockfile pins each package of the build to its version,
its source (a directory relative to the root package, a git commit, an index
entry, or the builtin standard library), and the content hashes of every
module it provides:
core, the hash of the module's checked declarations (quivers.qiec.content_hash), which renaming, reformatting, and comments leave unchanged;interface, the digest of the module's public interface (ModuleInterface.digest), which its names enter.
A build checks every pin before compiling anything, so a dependency whose content moved under an unchanged version or commit is refused. The file is a function of the manifest and the index alone: packages are sorted, paths are relative to the root package, and nothing about the machine (cache locations, times) enters it.
SourceKind
¶
How a locked package was found.
LockfileError
¶
Bases: ValueError
A lockfile that cannot be read, or a build that disagrees with it.
Its message says what is wrong, naming the package and module.
LockedModule
didactic-model
¶
Bases: Model
The content hashes a lockfile pins for one module.
| ATTRIBUTE | DESCRIPTION |
|---|---|
path |
The module's path.
TYPE:
|
core |
The hash of its checked declarations.
TYPE:
|
interface |
The digest of its public interface.
TYPE:
|
LockedPackage
didactic-model
¶
LockedPackage(*, name: str, version: Version, source: SourceKind, location: str = '', commit: str = '', revision: str = '', dependencies: tuple[str, ...] = (), modules: tuple[LockedModule, ...] = ())
Bases: Model
One package of a locked build.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The package's name.
TYPE:
|
version |
Its version.
TYPE:
|
source |
How it was found.
TYPE:
|
location |
The directory relative to the root package (
TYPE:
|
commit |
The git commit of its source, for
TYPE:
|
revision |
For
TYPE:
|
dependencies |
The names of the packages it depends on, sorted.
TYPE:
|
modules |
Its modules' hashes, by path.
TYPE:
|
module
¶
module(path: str) -> LockedModule | None
The pin of one module.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The module's path.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LockedModule | None
|
Its pin, or |
Source code in src/quivers/packages/lockfile.py
LockedIndex
didactic-model
¶
Bases: Model
An index a locked build looked dependencies up in.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The index's name in the root manifest.
TYPE:
|
url |
Its repository.
TYPE:
|
commit |
The commit of the index the build was resolved against.
TYPE:
|
Lockfile
didactic-model
¶
Lockfile(*, root: str, dependencies: tuple[str, ...] = (), indexes: tuple[LockedIndex, ...] = (), packages: tuple[LockedPackage, ...] = ())
Bases: Model
A resolved, pinned build.
| ATTRIBUTE | DESCRIPTION |
|---|---|
root |
The root package's name.
TYPE:
|
dependencies |
The root's direct dependencies, sorted.
TYPE:
|
indexes |
The indexes resolution read, by name.
TYPE:
|
packages |
Every package of the build except the root, by name.
TYPE:
|
package
¶
package(name: str) -> LockedPackage | None
The locked package of a name.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
A package name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LockedPackage | None
|
The package, or |
Source code in src/quivers/packages/lockfile.py
index
¶
index(name: str) -> LockedIndex | None
The locked commit of a named index.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The index's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
LockedIndex | None
|
The index, or |
Source code in src/quivers/packages/lockfile.py
render_lockfile
¶
render_lockfile(lock: Lockfile) -> str
The lockfile as TOML text.
| PARAMETER | DESCRIPTION |
|---|---|
lock
|
The lockfile.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Deterministic TOML: the same lockfile always renders to the same bytes. |
Source code in src/quivers/packages/lockfile.py
parse_lockfile
¶
parse_lockfile(text: str, *, where: str = LOCKFILE_NAME) -> Lockfile
Read a lockfile from its text.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The TOML text
TYPE:
|
where
|
The file name diagnostics name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Lockfile
|
The lockfile. |
| RAISES | DESCRIPTION |
|---|---|
LockfileError
|
If the text is not a lockfile of this layout. |
Source code in src/quivers/packages/lockfile.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 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 | |
read_lockfile
¶
read_lockfile(directory: Path) -> Lockfile | None
The lockfile beside a manifest, if there is one.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
The root package's directory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Lockfile | None
|
The lockfile, or |
| RAISES | DESCRIPTION |
|---|---|
LockfileError
|
If the lockfile exists and is malformed. |
Source code in src/quivers/packages/lockfile.py
index
¶
Package indexes: git repositories of package metadata.
An index needs no service. It is a git repository with one file per
published version, <name>/<version>.toml::
[package]
name = "worlds"
version = "1.2.0"
git = "https://example.org/worlds.git"
commit = "3f0c...e1"
[dependencies]
logic = "1.0.0"
[[module]]
path = "worlds.boolean"
core = "9a1f..."
interface = "51c0..."
The entry says where the version's source is (a repository and a commit), which packages of the same index it depends on (each with the minimum version it was built against), and the content hashes of the modules it provides, which every build checks. Resolution reads an index at one commit, which the lockfile records, so the same manifest and index commit resolve to the same build anywhere.
PackageIndexError
¶
Bases: ValueError
An index entry that is malformed or missing.
Its message says what is wrong, naming the index and the entry.
IndexRequirement
didactic-model
¶
IndexRequirement(*, name: str, minimum: Version)
Bases: Model
A dependency of an indexed version on another package of its index.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The package.
TYPE:
|
minimum |
The version it was built against.
TYPE:
|
IndexEntry
didactic-model
¶
IndexEntry(*, name: str, version: Version, url: str, commit: str, dependencies: tuple[IndexRequirement, ...] = (), modules: tuple[LockedModule, ...] = ())
Bases: Model
One published version of a package.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The package.
TYPE:
|
version |
The version.
TYPE:
|
url |
The repository holding its source.
TYPE:
|
commit |
The commit of that repository.
TYPE:
|
dependencies |
Its dependencies, by name.
TYPE:
|
modules |
The content hashes of the modules it provides, by path.
TYPE:
|
PackageIndex
¶
PackageIndex(name: str, url: str, commit: str, cache: GitCache)
An index repository read at one commit.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The index's name in the root manifest.
TYPE:
|
url
|
The repository.
TYPE:
|
commit
|
The commit read.
TYPE:
|
cache
|
The project cache holding its mirror.
TYPE:
|
Source code in src/quivers/packages/index.py
open
classmethod
¶
open(name: str, url: str, cache: GitCache, *, commit: str = '') -> PackageIndex
Open an index at a commit, or at its default branch's head.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The index's name.
TYPE:
|
url
|
Its repository.
TYPE:
|
cache
|
The project cache.
TYPE:
|
commit
|
The commit to read, as a lockfile pins it; the newest commit of the default branch when empty.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PackageIndex
|
The index. |
| RAISES | DESCRIPTION |
|---|---|
GitError
|
If the repository or the commit cannot be read. |
Source code in src/quivers/packages/index.py
versions
¶
versions(package: str) -> tuple[Version, ...]
Every published version of a package.
| PARAMETER | DESCRIPTION |
|---|---|
package
|
The package.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Version, ...]
|
Its versions, ascending. |
Source code in src/quivers/packages/index.py
packages
¶
Every package the index lists.
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
Their names, sorted. |
Source code in src/quivers/packages/index.py
entry
¶
entry(package: str, version: Version) -> IndexEntry
The entry of one published version.
| PARAMETER | DESCRIPTION |
|---|---|
package
|
The package.
TYPE:
|
version
|
The version.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
IndexEntry
|
Its entry. |
| RAISES | DESCRIPTION |
|---|---|
PackageIndexError
|
If the index does not list that version, or its entry disagrees with its path. |
Source code in src/quivers/packages/index.py
entry_path
¶
entry_path(name: str, version: Version) -> str
Where an entry lives in an index repository.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The package.
TYPE:
|
version
|
The version.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/packages/index.py
render_entry
¶
render_entry(entry: IndexEntry) -> str
An index entry as TOML text.
| PARAMETER | DESCRIPTION |
|---|---|
entry
|
The entry.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The file |
Source code in src/quivers/packages/index.py
parse_entry
¶
parse_entry(text: str, *, where: str) -> IndexEntry
Read an index entry.
| PARAMETER | DESCRIPTION |
|---|---|
text
|
The entry's TOML text.
TYPE:
|
where
|
The index and path diagnostics name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
IndexEntry
|
The entry. |
| RAISES | DESCRIPTION |
|---|---|
PackageIndexError
|
If the text is not an index entry. |
Source code in src/quivers/packages/index.py
git
¶
Git repositories in the project cache, through the git command.
Git dependencies and package indexes are git repositories. The cache keeps a
bare mirror of each repository under <root>/.qvr/packages/git and
extracts each commit a build uses under <root>/.qvr/packages/src, so a
build that has every pinned commit runs without the network: a revision that
names a commit already in the mirror is never fetched.
CACHE_DIRECTORY
module-attribute
¶
Where a project's package cache lives, relative to its root package.
GitError
¶
Bases: OSError
A git command that failed, or a revision that names no commit.
Its message says the command and what git reported.
GitCache
¶
The git repositories and extracted commits of one project.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
The cache directory,
TYPE:
|
Source code in src/quivers/packages/git.py
for_package
classmethod
¶
for_package(root: Path) -> GitCache
The cache of the project whose root package is a directory.
| PARAMETER | DESCRIPTION |
|---|---|
root
|
The root package's directory.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
GitCache
|
Its cache. |
Source code in src/quivers/packages/git.py
mirror_path
¶
Where the mirror of a repository lives.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The repository.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path
|
Its bare mirror's directory. |
Source code in src/quivers/packages/git.py
has_commit
¶
Whether the mirror of a repository holds a commit.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The repository.
TYPE:
|
commit
|
A full commit id.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether the commit is present without fetching. |
Source code in src/quivers/packages/git.py
fetch
¶
Bring a repository's mirror up to date, cloning it when absent.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The repository.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path
|
The mirror. |
| RAISES | DESCRIPTION |
|---|---|
GitError
|
If the repository cannot be cloned or fetched. |
Source code in src/quivers/packages/git.py
resolve
¶
The commit a revision of a repository names.
A full commit id already in the mirror resolves without the
network; any other revision (a tag, a branch, a short id, or the
default branch for "") fetches first.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The repository.
TYPE:
|
revision
|
A commit, tag, or branch; empty for the default branch.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The full commit id. |
| RAISES | DESCRIPTION |
|---|---|
GitError
|
If the repository cannot be fetched or the revision names no commit. |
Source code in src/quivers/packages/git.py
read
¶
A file's text at a commit.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The repository.
TYPE:
|
commit
|
A commit in its mirror.
TYPE:
|
path
|
The file's path in the repository, POSIX spelling.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
The file's text, or |
| RAISES | DESCRIPTION |
|---|---|
GitError
|
If the commit is not in the mirror. |
Source code in src/quivers/packages/git.py
files
¶
Every file of a commit.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The repository.
TYPE:
|
commit
|
A commit in its mirror.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
The files' paths, sorted. |
| RAISES | DESCRIPTION |
|---|---|
GitError
|
If the commit is not in the mirror. |
Source code in src/quivers/packages/git.py
checkout
¶
A directory holding a commit's files, extracted once.
| PARAMETER | DESCRIPTION |
|---|---|
url
|
The repository.
TYPE:
|
commit
|
A full commit id.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path
|
The extracted tree, |
| RAISES | DESCRIPTION |
|---|---|
GitError
|
If the commit is not in the repository. |
Source code in src/quivers/packages/git.py
run_git
¶
Run one git command and return its standard output.
| PARAMETER | DESCRIPTION |
|---|---|
arguments
|
The arguments after
TYPE:
|
cwd
|
The directory to run in.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bytes
|
What the command wrote to standard output. |
| RAISES | DESCRIPTION |
|---|---|
GitError
|
If git is not installed or the command exits with a failure. |
Source code in src/quivers/packages/git.py
is_commit
¶
Whether a revision is spelled as a full commit id.
| PARAMETER | DESCRIPTION |
|---|---|
revision
|
A revision.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether it is forty lowercase hexadecimal digits. |
Source code in src/quivers/packages/git.py
same_repository
¶
Whether two spellings name one repository.
A local repository may be spelled as a path or as a file:// URL;
both name the same directory. Remote URLs are compared as written.
| PARAMETER | DESCRIPTION |
|---|---|
left
|
Two repository spellings.
TYPE:
|
right
|
Two repository spellings.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether they name the same repository. |