diff --git a/Cargo.lock b/Cargo.lock index 944b8c127..81bf183e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6013,8 +6013,10 @@ dependencies = [ "itertools 0.14.0", "rkyv", "serde", + "serde_json", "sha3", "thiserror 2.0.12", + "uv-pep508", ] [[package]] diff --git a/crates/uv-variants/Cargo.toml b/crates/uv-variants/Cargo.toml index 0f956a7ac..0698f560d 100644 --- a/crates/uv-variants/Cargo.toml +++ b/crates/uv-variants/Cargo.toml @@ -10,6 +10,8 @@ authors.workspace = true license.workspace = true [dependencies] +uv-pep508 = { workspace = true } + hex = { workspace = true } itertools = { workspace = true } rkyv = { workspace = true } @@ -17,5 +19,8 @@ serde = { workspace = true } sha3 = { workspace = true } thiserror = { workspace = true } +[dev-dependencies] +serde_json = { workspace = true } + [lints] workspace = true diff --git a/crates/uv-variants/src/lib.rs b/crates/uv-variants/src/lib.rs index e63a7d16f..00f33895f 100644 --- a/crates/uv-variants/src/lib.rs +++ b/crates/uv-variants/src/lib.rs @@ -1,3 +1,5 @@ +pub mod variants_json; + use std::cmp; use std::collections::HashMap; use std::num::NonZeroU32; diff --git a/crates/uv-variants/src/variants_json.rs b/crates/uv-variants/src/variants_json.rs new file mode 100644 index 000000000..8ed287678 --- /dev/null +++ b/crates/uv-variants/src/variants_json.rs @@ -0,0 +1,56 @@ +use std::collections::HashMap; + +use serde::Deserialize; + +use uv_pep508::{MarkerTree, Requirement}; + +/// Mapping of namespaces in a variant +pub type Variant = HashMap; + +/// Mapping of features to their possible values in a namespace +pub type VariantNamespace = HashMap>; + +// TODO(konsti): Validate the string contents +pub type Namespace = String; +pub type Feature = String; +pub type Property = String; + +/// Combined index metadata for wheel variants. +/// +/// See +#[derive(Debug, PartialEq, Eq, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct VariantsJsonContent { + /// Default provider priorities + pub default_priorities: DefaultPriorities, + /// Mapping of namespaces to provider information + pub providers: HashMap, + /// Mapping of variant labels to properties + pub variants: HashMap, +} + +/// Default provider priorities +#[derive(Debug, PartialEq, Eq, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct DefaultPriorities { + /// Default namespace priorities + pub namespace: Vec, + /// Default feature priorities + #[serde(default)] + pub feature: HashMap>, + /// Default property priorities + #[serde(default)] + pub property: HashMap>>, +} + +/// Provider information +#[derive(Debug, PartialEq, Eq, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub struct Provider { + /// Object reference to plugin class + pub plugin_api: Option, + /// Environment marker specifying when to enable the plugin + pub enable_if: Option, + /// Dependency specifiers for how to install the plugin + pub requires: Vec, +}