mirror of https://github.com/astral-sh/uv
Implement 0.0.3
This commit is contained in:
parent
3e9ff9447a
commit
dc6757b270
|
|
@ -628,7 +628,8 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
|
||||||
let mut disabled_namespaces = FxHashSet::default();
|
let mut disabled_namespaces = FxHashSet::default();
|
||||||
let mut resolved_namespaces: FxHashMap<VariantNamespace, Arc<VariantProviderOutput>> =
|
let mut resolved_namespaces: FxHashMap<VariantNamespace, Arc<VariantProviderOutput>> =
|
||||||
futures::stream::iter(variants_json.providers.iter().filter(|(_, provider)| {
|
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
|
&& provider
|
||||||
.enable_if
|
.enable_if
|
||||||
.evaluate(marker_env, &MarkerVariantsUniversal, &[])
|
.evaluate(marker_env, &MarkerVariantsUniversal, &[])
|
||||||
|
|
@ -641,22 +642,27 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
|
||||||
.try_collect()
|
.try_collect()
|
||||||
.await?;
|
.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 {
|
for (namespace, provider) in &variants_json.providers {
|
||||||
// Track disabled namespaces for consistency checks.
|
// Track disabled namespaces for consistency checks.
|
||||||
if !provider
|
if !provider
|
||||||
.enable_if
|
.enable_if
|
||||||
.evaluate(marker_env, &MarkerVariantsUniversal, &[])
|
.evaluate(marker_env, &MarkerVariantsUniversal, &[])
|
||||||
|
|| provider.optional
|
||||||
{
|
{
|
||||||
disabled_namespaces.insert(namespace.clone());
|
disabled_namespaces.insert(namespace.clone());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if provider.plugin_use.unwrap_or_default().run_on_install() {
|
if provider.install_time.unwrap_or(true) {
|
||||||
continue;
|
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!(
|
warn!(
|
||||||
"Missing namespace {namespace} in default properties for {}=={}",
|
"Missing namespace {namespace} in default properties for {}=={}",
|
||||||
debug_filename.name, debug_filename.version
|
debug_filename.name, debug_filename.version
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
@ -13,7 +14,7 @@ use uv_pypi_types::VerbatimParsedUrl;
|
||||||
/// Mapping of namespaces in a variant
|
/// Mapping of namespaces in a variant
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
pub struct Variant(FxHashMap<VariantNamespace, FxHashMap<VariantFeature, Vec<VariantValue>>>);
|
pub struct Variant(BTreeMap<VariantNamespace, BTreeMap<VariantFeature, Vec<VariantValue>>>);
|
||||||
|
|
||||||
impl MarkerVariantsEnvironment for Variant {
|
impl MarkerVariantsEnvironment for Variant {
|
||||||
fn contains_namespace(&self, namespace: &VariantNamespace) -> bool {
|
fn contains_namespace(&self, namespace: &VariantNamespace) -> bool {
|
||||||
|
|
@ -74,7 +75,7 @@ impl MarkerVariantsEnvironment for Variant {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for Variant {
|
impl Deref for Variant {
|
||||||
type Target = FxHashMap<VariantNamespace, FxHashMap<VariantFeature, Vec<VariantValue>>>;
|
type Target = BTreeMap<VariantNamespace, BTreeMap<VariantFeature, Vec<VariantValue>>>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.0
|
&self.0
|
||||||
|
|
@ -87,11 +88,13 @@ impl Deref for Variant {
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct VariantsJsonContent {
|
pub struct VariantsJsonContent {
|
||||||
/// Default provider priorities
|
/// Default provider priorities.
|
||||||
pub default_priorities: DefaultPriorities,
|
pub default_priorities: DefaultPriorities,
|
||||||
/// Mapping of namespaces to provider information
|
/// Mapping of namespaces to provider information.
|
||||||
pub providers: FxHashMap<VariantNamespace, Provider>,
|
pub providers: FxHashMap<VariantNamespace, Provider>,
|
||||||
/// Mapping of variant labels to properties
|
/// The supported, ordered properties for `AoT` providers.
|
||||||
|
pub static_properties: Option<Variant>,
|
||||||
|
/// Mapping of variant labels to properties.
|
||||||
pub variants: FxHashMap<VariantLabel, Variant>,
|
pub variants: FxHashMap<VariantLabel, Variant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,10 +126,10 @@ pub struct DefaultPriorities {
|
||||||
pub namespace: Vec<VariantNamespace>,
|
pub namespace: Vec<VariantNamespace>,
|
||||||
/// Default feature priorities
|
/// Default feature priorities
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub feature: FxHashMap<VariantNamespace, Vec<VariantFeature>>,
|
pub feature: BTreeMap<VariantNamespace, Vec<VariantFeature>>,
|
||||||
/// Default property priorities
|
/// Default property priorities
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub property: FxHashMap<VariantNamespace, FxHashMap<VariantFeature, Vec<VariantValue>>>,
|
pub property: BTreeMap<VariantNamespace, BTreeMap<VariantFeature, Vec<VariantValue>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A `namespace :: feature :: property` entry.
|
/// A `namespace :: feature :: property` entry.
|
||||||
|
|
@ -138,47 +141,30 @@ pub struct VariantPropertyType {
|
||||||
pub value: VariantValue,
|
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
|
/// Provider information
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct Provider {
|
pub struct Provider {
|
||||||
/// Object reference to plugin class
|
/// Environment marker specifying when to enable the plugin.
|
||||||
pub plugin_api: Option<String>,
|
|
||||||
/// Environment marker specifying when to enable the plugin
|
|
||||||
#[serde(
|
#[serde(
|
||||||
skip_serializing_if = "uv_pep508::marker::ser::is_empty",
|
skip_serializing_if = "uv_pep508::marker::ser::is_empty",
|
||||||
serialize_with = "uv_pep508::marker::ser::serialize",
|
serialize_with = "uv_pep508::marker::ser::serialize",
|
||||||
default
|
default
|
||||||
)]
|
)]
|
||||||
pub enable_if: MarkerTree,
|
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<bool>,
|
||||||
|
/// 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<String>,
|
||||||
/// Dependency specifiers for how to install the plugin
|
/// Dependency specifiers for how to install the plugin
|
||||||
pub requires: Option<Vec<Requirement<VerbatimParsedUrl>>>,
|
pub requires: Option<Vec<Requirement<VerbatimParsedUrl>>>,
|
||||||
/// Whether this plugin is run at install time.
|
|
||||||
pub plugin_use: Option<PluginUse>,
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -19,6 +19,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"static-properties": {
|
||||||
|
"mathlib": {
|
||||||
|
"kind": [
|
||||||
|
"very_fast_lib"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"providers": {
|
"providers": {
|
||||||
"cpu_level": {
|
"cpu_level": {
|
||||||
"enable-if": "platform_machine == 'x86_64' or platform_machine == 'AMD64'",
|
"enable-if": "platform_machine == 'x86_64' or platform_machine == 'AMD64'",
|
||||||
|
|
@ -26,6 +33,9 @@
|
||||||
"requires": [
|
"requires": [
|
||||||
"cpu_level_provider >= 0.1, <0.2"
|
"cpu_level_provider >= 0.1, <0.2"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"mathlib": {
|
||||||
|
"install-time": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"variants": {
|
"variants": {
|
||||||
|
|
@ -34,6 +44,11 @@
|
||||||
"x86_64_level": [
|
"x86_64_level": [
|
||||||
"v1"
|
"v1"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"mathlib": {
|
||||||
|
"kind": [
|
||||||
|
"very_fast_lib"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cpu2": {
|
"cpu2": {
|
||||||
|
|
@ -41,6 +56,11 @@
|
||||||
"x86_64_level": [
|
"x86_64_level": [
|
||||||
"v2"
|
"v2"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"mathlib": {
|
||||||
|
"kind": [
|
||||||
|
"very_fast_lib"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cpu3": {
|
"cpu3": {
|
||||||
|
|
@ -48,6 +68,11 @@
|
||||||
"x86_64_level": [
|
"x86_64_level": [
|
||||||
"v3"
|
"v3"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"mathlib": {
|
||||||
|
"kind": [
|
||||||
|
"very_fast_lib"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cpu4": {
|
"cpu4": {
|
||||||
|
|
@ -55,6 +80,11 @@
|
||||||
"x86_64_level": [
|
"x86_64_level": [
|
||||||
"v4"
|
"v4"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"mathlib": {
|
||||||
|
"kind": [
|
||||||
|
"very_fast_lib"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -30,6 +30,12 @@ namespace = ["cpu_level"]
|
||||||
requires = ["cpu_level_provider >= 0.1, <0.2"]
|
requires = ["cpu_level_provider >= 0.1, <0.2"]
|
||||||
enable-if = "platform_machine == 'x86_64' or platform_machine == 'AMD64'"
|
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]
|
[build-system]
|
||||||
requires = ["uv_build>=0.8.0,<0.10.0"]
|
requires = ["uv_build>=0.8.0,<0.10.0"]
|
||||||
build-backend = "uv_build"
|
build-backend = "uv_build"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue