diff --git a/crates/uv-distribution/src/distribution_database.rs b/crates/uv-distribution/src/distribution_database.rs index 94f08319e..fa8adb280 100644 --- a/crates/uv-distribution/src/distribution_database.rs +++ b/crates/uv-distribution/src/distribution_database.rs @@ -628,7 +628,8 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> { let mut disabled_namespaces = FxHashSet::default(); let mut resolved_namespaces: FxHashMap> = futures::stream::iter(variants_json.providers.iter().filter(|(_, provider)| { - provider.plugin_use.unwrap_or_default().run_on_install() + provider.install_time.unwrap_or(true) + && !provider.optional && provider .enable_if .evaluate(marker_env, &MarkerVariantsUniversal, &[]) @@ -641,22 +642,27 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> { .try_collect() .await?; - // "Query" the non-install time providers, whose properties are all in the priorities + // "Query" the static providers for (namespace, provider) in &variants_json.providers { // Track disabled namespaces for consistency checks. if !provider .enable_if .evaluate(marker_env, &MarkerVariantsUniversal, &[]) + || provider.optional { disabled_namespaces.insert(namespace.clone()); continue; } - if provider.plugin_use.unwrap_or_default().run_on_install() { + if provider.install_time.unwrap_or(true) { continue; } - let Some(features) = variants_json.default_priorities.property.get(namespace) else { + let Some(features) = variants_json + .static_properties + .as_ref() + .and_then(|static_properties| static_properties.get(namespace)) + else { warn!( "Missing namespace {namespace} in default properties for {}=={}", debug_filename.name, debug_filename.version diff --git a/crates/uv-variants/src/variants_json.rs b/crates/uv-variants/src/variants_json.rs index 72f7f48af..d6e0c1820 100644 --- a/crates/uv-variants/src/variants_json.rs +++ b/crates/uv-variants/src/variants_json.rs @@ -1,3 +1,4 @@ +use std::collections::BTreeMap; use std::ops::Deref; use rustc_hash::FxHashMap; @@ -13,7 +14,7 @@ use uv_pypi_types::VerbatimParsedUrl; /// Mapping of namespaces in a variant #[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(transparent)] -pub struct Variant(FxHashMap>>); +pub struct Variant(BTreeMap>>); impl MarkerVariantsEnvironment for Variant { fn contains_namespace(&self, namespace: &VariantNamespace) -> bool { @@ -74,7 +75,7 @@ impl MarkerVariantsEnvironment for Variant { } impl Deref for Variant { - type Target = FxHashMap>>; + type Target = BTreeMap>>; fn deref(&self) -> &Self::Target { &self.0 @@ -87,11 +88,13 @@ impl Deref for Variant { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "kebab-case")] pub struct VariantsJsonContent { - /// Default provider priorities + /// Default provider priorities. pub default_priorities: DefaultPriorities, - /// Mapping of namespaces to provider information + /// Mapping of namespaces to provider information. pub providers: FxHashMap, - /// Mapping of variant labels to properties + /// The supported, ordered properties for `AoT` providers. + pub static_properties: Option, + /// Mapping of variant labels to properties. pub variants: FxHashMap, } @@ -123,10 +126,10 @@ pub struct DefaultPriorities { pub namespace: Vec, /// Default feature priorities #[serde(default)] - pub feature: FxHashMap>, + pub feature: BTreeMap>, /// Default property priorities #[serde(default)] - pub property: FxHashMap>>, + pub property: BTreeMap>>, } /// A `namespace :: feature :: property` entry. @@ -138,47 +141,30 @@ pub struct VariantPropertyType { pub value: VariantValue, } -/// The stages at which a plugin is run. -/// -/// Specifically captures whether it needs to be run at install time. -#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[serde(rename_all = "kebab-case")] -pub enum PluginUse { - /// The plugin is never run, it is only static. - None, - /// The plugin is run at build time, the install time evaluation is static. - Build, - /// The plugin is run both at build time and at install time. - #[default] - All, -} - -impl PluginUse { - /// Whether to run this plugin on installation, `false` for plugins evaluated from - /// default priorities. - pub fn run_on_install(self) -> bool { - match self { - Self::All => true, - Self::None | Self::Build => false, - } - } -} - /// Provider information #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, 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 + /// Environment marker specifying when to enable the plugin. #[serde( skip_serializing_if = "uv_pep508::marker::ser::is_empty", serialize_with = "uv_pep508::marker::ser::serialize", default )] pub enable_if: MarkerTree, + /// Whether this is an install-time provider. `false` means that it is an `AoT` provider instead. + /// + /// Defaults to `true` + pub install_time: Option, + /// Whether this is an optional provider. + /// + /// If it is `true`, the provider is not used unless the user opts in to it. + /// + /// Defaults to `false` + #[serde(default)] + pub optional: bool, + /// Object reference to plugin class + pub plugin_api: Option, /// Dependency specifiers for how to install the plugin pub requires: Option>>, - /// Whether this plugin is run at install time. - pub plugin_use: Option, } diff --git a/files/built_by_uv-0.1.0-py3-none-any-cpu1.whl b/files/built_by_uv-0.1.0-py3-none-any-cpu1.whl index b84b2693b..995f390ce 100644 Binary files a/files/built_by_uv-0.1.0-py3-none-any-cpu1.whl and b/files/built_by_uv-0.1.0-py3-none-any-cpu1.whl differ diff --git a/files/built_by_uv-0.1.0-py3-none-any-cpu2.whl b/files/built_by_uv-0.1.0-py3-none-any-cpu2.whl index b84b2693b..995f390ce 100644 Binary files a/files/built_by_uv-0.1.0-py3-none-any-cpu2.whl and b/files/built_by_uv-0.1.0-py3-none-any-cpu2.whl differ diff --git a/files/built_by_uv-0.1.0-py3-none-any-cpu3.whl b/files/built_by_uv-0.1.0-py3-none-any-cpu3.whl index b84b2693b..995f390ce 100644 Binary files a/files/built_by_uv-0.1.0-py3-none-any-cpu3.whl and b/files/built_by_uv-0.1.0-py3-none-any-cpu3.whl differ diff --git a/files/built_by_uv-0.1.0-py3-none-any-cpu4.whl b/files/built_by_uv-0.1.0-py3-none-any-cpu4.whl index b84b2693b..995f390ce 100644 Binary files a/files/built_by_uv-0.1.0-py3-none-any-cpu4.whl and b/files/built_by_uv-0.1.0-py3-none-any-cpu4.whl differ diff --git a/files/built_by_uv-0.1.0-variants.json b/files/built_by_uv-0.1.0-variants.json index eeba3ae68..1efd65a76 100644 --- a/files/built_by_uv-0.1.0-variants.json +++ b/files/built_by_uv-0.1.0-variants.json @@ -19,6 +19,13 @@ } } }, + "static-properties": { + "mathlib": { + "kind": [ + "very_fast_lib" + ] + } + }, "providers": { "cpu_level": { "enable-if": "platform_machine == 'x86_64' or platform_machine == 'AMD64'", @@ -26,6 +33,9 @@ "requires": [ "cpu_level_provider >= 0.1, <0.2" ] + }, + "mathlib": { + "install-time": false } }, "variants": { @@ -34,6 +44,11 @@ "x86_64_level": [ "v1" ] + }, + "mathlib": { + "kind": [ + "very_fast_lib" + ] } }, "cpu2": { @@ -41,6 +56,11 @@ "x86_64_level": [ "v2" ] + }, + "mathlib": { + "kind": [ + "very_fast_lib" + ] } }, "cpu3": { @@ -48,6 +68,11 @@ "x86_64_level": [ "v3" ] + }, + "mathlib": { + "kind": [ + "very_fast_lib" + ] } }, "cpu4": { @@ -55,6 +80,11 @@ "x86_64_level": [ "v4" ] + }, + "mathlib": { + "kind": [ + "very_fast_lib" + ] } } } diff --git a/files_sdist/built_by_uv-0.1.0.tar.gz b/files_sdist/built_by_uv-0.1.0.tar.gz index 8632c807e..fadd6cec2 100644 Binary files a/files_sdist/built_by_uv-0.1.0.tar.gz and b/files_sdist/built_by_uv-0.1.0.tar.gz differ diff --git a/files_wheel/built_by_uv-0.1.0-py3-none-any.whl b/files_wheel/built_by_uv-0.1.0-py3-none-any.whl index b84b2693b..995f390ce 100644 Binary files a/files_wheel/built_by_uv-0.1.0-py3-none-any.whl and b/files_wheel/built_by_uv-0.1.0-py3-none-any.whl differ diff --git a/scripts/packages/built-by-uv/pyproject.toml b/scripts/packages/built-by-uv/pyproject.toml index c25c89211..61c1d80ef 100644 --- a/scripts/packages/built-by-uv/pyproject.toml +++ b/scripts/packages/built-by-uv/pyproject.toml @@ -30,6 +30,12 @@ namespace = ["cpu_level"] requires = ["cpu_level_provider >= 0.1, <0.2"] enable-if = "platform_machine == 'x86_64' or platform_machine == 'AMD64'" +[variant.providers.mathlib] +install-time = false + +[variant.static-properties] +mathlib = { "kind" = ["very_fast_lib"] } + [build-system] requires = ["uv_build>=0.8.0,<0.10.0"] build-backend = "uv_build"