typing#

Minimal set of interfaces required to describe shards code to clients (solvers)

Classes#

Shards

Base class for protocol classes.

BuildRepodataSubset

Protocol for build_repodata_subset callable.

class Shards#

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
base_url: str#
property package_names: collections.abc.KeysView[str]#

Return the names of all packages available in this shard collection.

__contains__(package: str) bool#

Check if a package is available in this shard collection.

iter_records() collections.abc.Iterator[tuple[str, dict]]#

Yield (filename, record) tuples for all packages in visited shards.

iter_records_v3() collections.abc.Iterable[tuple[tuple[str, str], dict]]#

Yield ((key, section), record) tuples for all packages in visited shards.

Section can be: "packages" for .tar.bz2 packages, "packages.conda" for .conda packages, "v3.whl", "v3.conda", "v3.tar.bz2" for v3 packages.

key is the same as the filename for "packages", "packages.conda" but is different from the filename for v3 packages.

class BuildRepodataSubset#

Bases: Protocol

Protocol for build_repodata_subset callable.

This function is used by solvers to construct a minimal subset of repodata based on the root packages that might be installed and the available channels. It traverses package dependencies to discover all reachable (channel, package) tuples, which are then used by the solver to reduce search space.

__call__(root_packages: collections.abc.Iterable[str], channels: dict[str, Any], algorithm: Literal['bfs', 'pipelined'] = 'pipelined', repodata_version: int = 1) dict[str, Shards] | None#

Retrieve a minimal subset of repodata based on root packages.

Parameters:
  • root_packages -- Iterable of installed and requested package names

  • channels -- Dictionary mapping channel URLs to Channel objects

  • algorithm -- Traversal algorithm to use ("bfs" or "pipelined")

  • repodata_version -- repodata format version (1 = classic, 3 = v3).

Returns:

A dictionary mapping channel URLs to Shards objects containing the subset of packages needed, or None if shards are unavailable