Open-Source Wikis

/

uv

/

Crates

/

uv-distribution-types

astral-sh/uv

uv-distribution-types

crates/uv-distribution-types/ defines the type vocabulary for uv's package model. Every piece of code that needs to talk about a wheel, a source distribution, an index, or a requirement uses types from here.

Purpose

Centralize the data model so the resolver, distribution database, installer, and lockfile can share definitions without circular dependencies. The crate is data-only — no I/O, no HTTP.

Directory layout

The crate is one big src/ with 32 modules (492 KB of code). Notable files:

File Purpose
lib.rs The Dist enum — the central distribution type, plus re-exports.
index.rs, index_url.rs, index_name.rs, pip_index.rs Index models: Index, IndexUrl, IndexName, PipIndex, PipExtraIndex, PipFindLinks.
requirement.rs (~40 KB) uv's internal Requirement type plus Source, RequirementSource, and conversions to/from PEP 508.
requires_python.rs (~35 KB) RequiresPython parsing, ranges, and intersection logic.
installed.rs InstalledDist for already-installed packages.
cached.rs CachedDist for entries in the wheel cache.
buildable.rs BuildableSource for sdists/git/path that need building.
prioritized_distribution.rs (~50 KB) PrioritizedDist for ordering wheels by tag preference.
resolution.rs, resolved.rs ResolvedDist and resolution graph node types.
config_settings.rs ConfigSettings and ConfigSettingPackageEntry for build-system flags.
dependency_metadata.rs The [[tool.uv.dependency-metadata]] override surface.
exclude_newer.rs Cross-cutting ExcludeNewer* types shared with the resolver.
file.rs, hash.rs, id.rs File metadata, hash digests, identifiers.
traits.rs Common traits like Name, Identifier, RemoteSource.
status_code_strategy.rs Per-index 4xx handling.
known_platform.rs Tag families for "common" platforms.

Key abstractions

  • Dist — the top-level enum: Built(BuiltDist), Source(SourceDist).
  • BuiltDist — wheel from a registry, URL, path, or registry mirror.
  • SourceDist — sdist from a registry, URL, path, git, or directory.
  • IndexLocations — the resolved list of indexes for a given resolution.
  • Origin — where a requirement came from (a project, a constraint file, …).
  • Requirement — uv's internal extension of PEP 508 with sources.

Integration points

Almost every other crate depends on this one. It is the lingua franca for distributions and requirements throughout uv.

See also

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

uv-distribution-types – uv wiki | Factory