Skip to content

Commit

Permalink
Rename to metadata-overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Sep 16, 2024
1 parent 009a161 commit a9ef2ad
Show file tree
Hide file tree
Showing 34 changed files with 284 additions and 214 deletions.
6 changes: 3 additions & 3 deletions crates/bench/benches/uv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ mod resolver {

use anyhow::Result;

use distribution_types::{IndexCapabilities, IndexLocations, StaticMetadata};
use distribution_types::{IndexCapabilities, IndexLocations, MetadataOverrides};
use install_wheel_rs::linker::LinkMode;
use pep440_rs::Version;
use pep508_rs::{MarkerEnvironment, MarkerEnvironmentBuilder};
Expand Down Expand Up @@ -161,7 +161,7 @@ mod resolver {
let installed_packages = EmptyInstalledPackages;
let options = OptionsBuilder::new().exclude_newer(exclude_newer).build();
let sources = SourceStrategy::default();
let static_metadata = StaticMetadata::default();
let metadata_override = MetadataOverrides::default();

let python_requirement = if universal {
PythonRequirement::from_requires_python(
Expand All @@ -179,7 +179,7 @@ mod resolver {
interpreter,
&index_locations,
&flat_index,
&static_metadata,
&metadata_override,
&index,
&git,
&capabilities,
Expand Down
4 changes: 2 additions & 2 deletions crates/distribution-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ pub use crate::hash::*;
pub use crate::id::*;
pub use crate::index_url::*;
pub use crate::installed::*;
pub use crate::metadata_override::*;
pub use crate::prioritized_distribution::*;
pub use crate::resolution::*;
pub use crate::resolved::*;
pub use crate::specified_requirement::*;
pub use crate::static_metadata::*;
pub use crate::traits::*;

mod annotation;
Expand All @@ -76,11 +76,11 @@ mod hash;
mod id;
mod index_url;
mod installed;
mod metadata_override;
mod prioritized_distribution;
mod resolution;
mod resolved;
mod specified_requirement;
mod static_metadata;
mod traits;

#[derive(Debug, Clone)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use uv_normalize::PackageName;

/// Pre-defined [`Metadata23`] entries, indexed by [`PackageName`] and [`Version`].
#[derive(Debug, Clone, Default)]
pub struct StaticMetadata(FxHashMap<PackageName, FxHashMap<Version, Metadata23>>);
pub struct MetadataOverrides(FxHashMap<PackageName, FxHashMap<Version, Metadata23>>);

impl StaticMetadata {
impl MetadataOverrides {
/// Index a set of [`Metadata23`] entries by [`PackageName`] and [`Version`].
pub fn from_entries(entries: impl IntoIterator<Item = Metadata23>) -> Self {
let mut map = Self::default();
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-cli/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub fn resolver_options(
} else {
prerelease
},
static_metadata: None,
metadata_override: None,
config_settings: config_setting
.map(|config_settings| config_settings.into_iter().collect::<ConfigSettings>()),
no_build_isolation: flag(no_build_isolation, build_isolation),
Expand Down Expand Up @@ -365,7 +365,7 @@ pub fn resolver_installer_options(
} else {
prerelease
},
static_metadata: None,
metadata_override: None,
config_settings: config_setting
.map(|config_settings| config_settings.into_iter().collect::<ConfigSettings>()),
no_build_isolation: flag(no_build_isolation, build_isolation),
Expand Down
12 changes: 6 additions & 6 deletions crates/uv-dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_hash::FxHashMap;
use tracing::{debug, instrument};

use distribution_types::{
CachedDist, IndexCapabilities, IndexLocations, Name, Resolution, SourceDist, StaticMetadata,
CachedDist, IndexCapabilities, IndexLocations, MetadataOverrides, Name, Resolution, SourceDist,
VersionOrUrlRef,
};
use pypi_types::Requirement;
Expand Down Expand Up @@ -46,7 +46,7 @@ pub struct BuildDispatch<'a> {
index: &'a InMemoryIndex,
git: &'a GitResolver,
capabilities: &'a IndexCapabilities,
static_metadata: &'a StaticMetadata,
metadata_override: &'a MetadataOverrides,
in_flight: &'a InFlight,
build_isolation: BuildIsolation<'a>,
link_mode: install_wheel_rs::linker::LinkMode,
Expand All @@ -68,7 +68,7 @@ impl<'a> BuildDispatch<'a> {
interpreter: &'a Interpreter,
index_locations: &'a IndexLocations,
flat_index: &'a FlatIndex,
static_metadata: &'a StaticMetadata,
metadata_override: &'a MetadataOverrides,
index: &'a InMemoryIndex,
git: &'a GitResolver,
capabilities: &'a IndexCapabilities,
Expand All @@ -93,7 +93,7 @@ impl<'a> BuildDispatch<'a> {
index,
git,
capabilities,
static_metadata,
metadata_override,
in_flight,
index_strategy,
config_settings,
Expand Down Expand Up @@ -140,8 +140,8 @@ impl<'a> BuildContext for BuildDispatch<'a> {
self.capabilities
}

fn static_metadata(&self) -> &StaticMetadata {
self.static_metadata
fn metadata_override(&self) -> &MetadataOverrides {
self.metadata_override
}

fn build_options(&self) -> &BuildOptions {
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-distribution/src/distribution_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
// If the metadata was provided by the user directly, prefer it.
if let Some(metadata) = self
.build_context
.static_metadata()
.metadata_override()
.get(dist.name(), dist.version())
{
return Ok(ArchiveMetadata::from_metadata23(metadata.clone()));
Expand Down Expand Up @@ -429,7 +429,7 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
if let Some(version) = dist.version() {
if let Some(metadata) = self
.build_context
.static_metadata()
.metadata_override()
.get(dist.name(), version)
{
return Ok(ArchiveMetadata::from_metadata23(metadata.clone()));
Expand Down
26 changes: 13 additions & 13 deletions crates/uv-resolver/src/lock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use distribution_filename::{DistExtension, ExtensionError, SourceDistExtension,
use distribution_types::{
BuiltDist, DirectUrlBuiltDist, DirectUrlSourceDist, DirectorySourceDist, Dist,
DistributionMetadata, FileLocation, FlatIndexLocation, GitSourceDist, HashPolicy,
IndexLocations, IndexUrl, Name, PathBuiltDist, PathSourceDist, RegistryBuiltDist,
RegistryBuiltWheel, RegistrySourceDist, RemoteSource, Resolution, ResolvedDist, StaticMetadata,
ToUrlError, UrlString,
IndexLocations, IndexUrl, MetadataOverrides, Name, PathBuiltDist, PathSourceDist,
RegistryBuiltDist, RegistryBuiltWheel, RegistrySourceDist, RemoteSource, Resolution,
ResolvedDist, ToUrlError, UrlString,
};
use pep440_rs::Version;
use pep508_rs::{split_scheme, MarkerEnvironment, MarkerTree, VerbatimUrl, VerbatimUrlError};
Expand Down Expand Up @@ -795,9 +795,9 @@ impl Lock {
manifest_table.insert("overrides", value(overrides));
}

if !self.manifest.static_metadata.is_empty() {
if !self.manifest.metadata_override.is_empty() {
let mut tables = ArrayOfTables::new();
for metadata in &self.manifest.static_metadata {
for metadata in &self.manifest.metadata_override {
let mut table = Table::new();
table.insert("name", value(metadata.name.to_string()));
table.insert("version", value(metadata.version.to_string()));
Expand All @@ -824,7 +824,7 @@ impl Lock {
}
tables.push(table);
}
manifest_table.insert("static-metadata", Item::ArrayOfTables(tables));
manifest_table.insert("metadata-override", Item::ArrayOfTables(tables));
}

if !manifest_table.is_empty() {
Expand Down Expand Up @@ -913,7 +913,7 @@ impl Lock {
requirements: &[Requirement],
constraints: &[Requirement],
overrides: &[Requirement],
static_metadata: &StaticMetadata,
metadata_override: &MetadataOverrides,
indexes: Option<&IndexLocations>,
build_options: &BuildOptions,
tags: &Tags,
Expand Down Expand Up @@ -1030,8 +1030,8 @@ impl Lock {

// Validate that the lockfile was generated with the same static metadata.
{
let expected = static_metadata.values().cloned().collect::<BTreeSet<_>>();
let actual = &self.manifest.static_metadata;
let expected = metadata_override.values().cloned().collect::<BTreeSet<_>>();
let actual = &self.manifest.metadata_override;
if expected != *actual {
return Ok(SatisfiesResult::MismatchedStaticMetadata(expected, actual));
}
Expand Down Expand Up @@ -1348,7 +1348,7 @@ pub struct ResolverManifest {
overrides: BTreeSet<Requirement>,
/// The static metadata provided to the resolver.
#[serde(default)]
static_metadata: BTreeSet<Metadata23>,
metadata_override: BTreeSet<Metadata23>,
}

impl ResolverManifest {
Expand All @@ -1359,14 +1359,14 @@ impl ResolverManifest {
requirements: impl IntoIterator<Item = Requirement>,
constraints: impl IntoIterator<Item = Requirement>,
overrides: impl IntoIterator<Item = Requirement>,
static_metadata: impl IntoIterator<Item = Metadata23>,
metadata_override: impl IntoIterator<Item = Metadata23>,
) -> Self {
Self {
members: members.into_iter().collect(),
requirements: requirements.into_iter().collect(),
constraints: constraints.into_iter().collect(),
overrides: overrides.into_iter().collect(),
static_metadata: static_metadata.into_iter().collect(),
metadata_override: metadata_override.into_iter().collect(),
}
}

Expand All @@ -1389,7 +1389,7 @@ impl ResolverManifest {
.into_iter()
.map(|requirement| requirement.relative_to(workspace.install_path()))
.collect::<Result<BTreeSet<_>, _>>()?,
static_metadata: self.static_metadata,
metadata_override: self.metadata_override,
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Ok(
requirements: {},
constraints: {},
overrides: {},
static_metadata: {},
metadata_override: {},
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Ok(
requirements: {},
constraints: {},
overrides: {},
static_metadata: {},
metadata_override: {},
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Ok(
requirements: {},
constraints: {},
overrides: {},
static_metadata: {},
metadata_override: {},
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Ok(
requirements: {},
constraints: {},
overrides: {},
static_metadata: {},
metadata_override: {},
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Ok(
requirements: {},
constraints: {},
overrides: {},
static_metadata: {},
metadata_override: {},
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Ok(
requirements: {},
constraints: {},
overrides: {},
static_metadata: {},
metadata_override: {},
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Ok(
requirements: {},
constraints: {},
overrides: {},
static_metadata: {},
metadata_override: {},
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Ok(
requirements: {},
constraints: {},
overrides: {},
static_metadata: {},
metadata_override: {},
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Ok(
requirements: {},
constraints: {},
overrides: {},
static_metadata: {},
metadata_override: {},
},
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Ok(
requirements: {},
constraints: {},
overrides: {},
static_metadata: {},
metadata_override: {},
},
},
)
Loading

0 comments on commit a9ef2ad

Please sign in to comment.