diff --git a/crates/pixi_build_backend_passthrough/src/lib.rs b/crates/pixi_build_backend_passthrough/src/lib.rs index 651eed79c3..c76d558f5e 100644 --- a/crates/pixi_build_backend_passthrough/src/lib.rs +++ b/crates/pixi_build_backend_passthrough/src/lib.rs @@ -1,9 +1,9 @@ //! A passthrough build backend for testing purposes. //! -//! This backend simply passes along the information from the project model to +//! This backend simply passes along the information from the package model to //! the `conda/outputs` API without any modifications. It's useful for testing //! and debugging purposes, as it does not perform any actual building or -//! processing of the project model. +//! processing of the package model. use std::{collections::BTreeSet, path::PathBuf}; @@ -15,8 +15,8 @@ use pixi_build_frontend::{ json_rpc::CommunicationError, }; use pixi_build_types::{ - BackendCapabilities, NamedSpecV1, PackageSpecV1, ProjectModelV1, SourcePackageName, - TargetSelectorV1, TargetV1, TargetsV1, VersionedProjectModel, + BackendCapabilities, NamedSpecV1, PackageModel, PackageSpecV1, SourcePackageName, + TargetSelectorV1, TargetV1, TargetsV1, procedures::{ conda_build_v1::{CondaBuildV1Params, CondaBuildV1Result}, conda_outputs::{ @@ -32,11 +32,11 @@ use serde::Deserialize; const BACKEND_NAME: &str = "passthrough"; /// An in-memory build backend that simply passes along the information from the -/// project model to the `conda/outputs` API without any modifications. This +/// package model to the `conda/outputs` API without any modifications. This /// backend is useful for testing and debugging purposes, as it does not perform -/// any actual building or processing of the project model. +/// any actual building or processing of the package model. pub struct PassthroughBackend { - project_model: ProjectModelV1, + package_model: PackageModel, config: PassthroughBackendConfig, source_dir: PathBuf, index_json: Option, @@ -72,7 +72,7 @@ impl InMemoryBackend for PassthroughBackend { outputs: vec![CondaOutput { metadata: CondaOutputMetadata { name: self - .project_model + .package_model .name .as_ref() .map(|name| PackageName::try_from(name.as_str()).unwrap()) @@ -85,7 +85,7 @@ impl InMemoryBackend for PassthroughBackend { }) }), version: self - .project_model + .package_model .version .as_ref() .or_else(|| self.index_json.as_ref().map(|j| j.version.version())) @@ -108,7 +108,7 @@ impl InMemoryBackend for PassthroughBackend { .and_then(|j| j.subdir.as_deref()) .map(|subdir| subdir.parse().unwrap()) .unwrap_or(Platform::NoArch), - license: self.project_model.license.clone(), + license: self.package_model.license.clone(), license_family: None, noarch: self .index_json @@ -120,17 +120,17 @@ impl InMemoryBackend for PassthroughBackend { variant: Default::default(), }, build_dependencies: Some(extract_dependencies( - &self.project_model.targets, + &self.package_model.targets, |t| t.build_dependencies.as_ref(), params.host_platform, )), host_dependencies: Some(extract_dependencies( - &self.project_model.targets, + &self.package_model.targets, |t| t.host_dependencies.as_ref(), params.host_platform, )), run_dependencies: extract_dependencies( - &self.project_model.targets, + &self.package_model.targets, |t| t.run_dependencies.as_ref(), params.host_platform, ), @@ -232,13 +232,10 @@ impl InMemoryBackendInstantiator for PassthroughBackendInstantiator { &self, params: InitializeParams, ) -> Result> { - let project_model = match params.project_model { - Some(VersionedProjectModel::V1(project_model)) => project_model, - _ => { - return Err(Box::new(CommunicationError::BackendError( - BackendError::new("Passthrough backend only supports project model v1"), - ))); - } + let Some(package_model) = params.package_model else { + return Err(Box::new(CommunicationError::BackendError( + BackendError::new("Passthrough backend requires a package model"), + ))); }; let config = match params.configuration { @@ -269,7 +266,7 @@ impl InMemoryBackendInstantiator for PassthroughBackendInstantiator { }; Ok(PassthroughBackend { - project_model, + package_model, config, source_dir, index_json, diff --git a/crates/pixi_build_discovery/src/discovery.rs b/crates/pixi_build_discovery/src/discovery.rs index 875a19feab..c38bf55c48 100644 --- a/crates/pixi_build_discovery/src/discovery.rs +++ b/crates/pixi_build_discovery/src/discovery.rs @@ -6,8 +6,8 @@ use std::{ use itertools::Itertools; use miette::Diagnostic; use ordermap::OrderMap; -use pixi_build_type_conversions::{to_project_model_v1, to_target_selector_v1}; -use pixi_build_types::{ProjectModelV1, TargetSelectorV1}; +use pixi_build_type_conversions::{to_package_model, to_target_selector_v1}; +use pixi_build_types::{PackageModel, TargetSelectorV1}; use pixi_config::Config; use pixi_manifest::{ DiscoveryStart, ExplicitManifestError, PackageManifest, PrioritizedChannel, WithProvenance, @@ -57,8 +57,8 @@ pub struct BackendInitializationParams { /// The absolute path of the discovered manifest pub manifest_path: PathBuf, - /// Optionally, the manifest of the discovered package. - pub project_model: Option, + /// Optionally, the package model of the discovered package. + pub package_model: Option, /// Additional configuration that applies to the backend. pub configuration: Option, @@ -205,7 +205,7 @@ impl DiscoveredBackend { source: None, source_anchor: source_dir, manifest_path: recipe_absolute_path, - project_model: None, + package_model: None, configuration: None, target_configuration: None, }, @@ -232,8 +232,8 @@ impl DiscoveredBackend { .expect("workspace manifest should have a parent directory") .to_path_buf(); - // Construct the project model from the manifest - let project_model = to_project_model_v1(package_manifest, channel_config)?; + // Construct the package model from the manifest + let package_model = to_package_model(package_manifest, channel_config)?; // Determine the build system requirements. let build_system = package_manifest.build.clone(); @@ -279,7 +279,7 @@ impl DiscoveredBackend { .parent() .expect("points to a file") .to_path_buf(), - project_model: Some(project_model), + package_model: Some(package_model), configuration: build_system.config.map(|config| { config .deserialize_into() @@ -377,7 +377,7 @@ impl DiscoveredBackend { source: None, source_anchor: source_dir, manifest_path: package_xml_absolute_path, - project_model: Some(ProjectModelV1::default()), + package_model: Some(PackageModel::default()), configuration: None, target_configuration: None, }, diff --git a/crates/pixi_build_discovery/tests/snapshots/discovery__direct_package_xml.snap b/crates/pixi_build_discovery/tests/snapshots/discovery__direct_package_xml.snap index a1471f9f8b..12218f8ebd 100644 --- a/crates/pixi_build_discovery/tests/snapshots/discovery__direct_package_xml.snap +++ b/crates/pixi_build_discovery/tests/snapshots/discovery__direct_package_xml.snap @@ -17,7 +17,7 @@ init-params: source: ~ source-anchor: "file:///ros-package" manifest-path: "file:///ros-package/package.xml" - project-model: + package-model: name: ~ version: ~ description: ~ diff --git a/crates/pixi_build_discovery/tests/snapshots/discovery__direct_recipe.snap b/crates/pixi_build_discovery/tests/snapshots/discovery__direct_recipe.snap index 5f80b4fb51..060f2b45d7 100644 --- a/crates/pixi_build_discovery/tests/snapshots/discovery__direct_recipe.snap +++ b/crates/pixi_build_discovery/tests/snapshots/discovery__direct_recipe.snap @@ -17,6 +17,6 @@ init-params: source: ~ source-anchor: "file:///recipe_yaml" manifest-path: "file:///recipe_yaml/recipe.yaml" - project-model: ~ + package-model: ~ configuration: ~ target-configuration: ~ diff --git a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@inherit__nested.snap b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@inherit__nested.snap index f26b3fc037..30bdb0160e 100644 --- a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@inherit__nested.snap +++ b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@inherit__nested.snap @@ -18,7 +18,7 @@ init-params: source: ~ source-anchor: "file:///inherit/nested" manifest-path: "file:///inherit/nested/pixi.toml" - project-model: + package-model: name: simple version: 0.1.0 description: ~ diff --git a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@nested__nested.snap b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@nested__nested.snap index e72a7a0103..b750bb12ee 100644 --- a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@nested__nested.snap +++ b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@nested__nested.snap @@ -18,7 +18,7 @@ init-params: source: ~ source-anchor: "file:///nested/nested" manifest-path: "file:///nested/nested/pixi.toml" - project-model: + package-model: name: simple version: 0.1.0 description: ~ diff --git a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@nested_recipe_yml.snap b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@nested_recipe_yml.snap index ed10f8a182..dc294ad584 100644 --- a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@nested_recipe_yml.snap +++ b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@nested_recipe_yml.snap @@ -18,6 +18,6 @@ init-params: source: ~ source-anchor: "file:///nested_recipe_yml" manifest-path: "file:///nested_recipe_yml/recipe/recipe.yml" - project-model: ~ + package-model: ~ configuration: ~ target-configuration: ~ diff --git a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@recipe_yaml.snap b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@recipe_yaml.snap index b999c8a58b..9788ecc5e8 100644 --- a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@recipe_yaml.snap +++ b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@recipe_yaml.snap @@ -18,6 +18,6 @@ init-params: source: ~ source-anchor: "file:///recipe_yaml" manifest-path: "file:///recipe_yaml/recipe.yaml" - project-model: ~ + package-model: ~ configuration: ~ target-configuration: ~ diff --git a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@recipe_yml.snap b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@recipe_yml.snap index eb73a4c1ef..ea6886c577 100644 --- a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@recipe_yml.snap +++ b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@recipe_yml.snap @@ -18,6 +18,6 @@ init-params: source: ~ source-anchor: "file:///recipe_yml" manifest-path: "file:///recipe_yml/recipe.yml" - project-model: ~ + package-model: ~ configuration: ~ target-configuration: ~ diff --git a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@simple.snap b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@simple.snap index 1975d68310..3ca92476c4 100644 --- a/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@simple.snap +++ b/crates/pixi_build_discovery/tests/snapshots/discovery__discovery@simple.snap @@ -18,7 +18,7 @@ init-params: source: ~ source-anchor: "file:///simple" manifest-path: "file:///simple/pixi.toml" - project-model: + package-model: name: simple version: 0.1.0 description: ~ diff --git a/crates/pixi_build_frontend/src/backend/json_rpc.rs b/crates/pixi_build_frontend/src/backend/json_rpc.rs index 78c617acaf..7ce3b7faff 100644 --- a/crates/pixi_build_frontend/src/backend/json_rpc.rs +++ b/crates/pixi_build_frontend/src/backend/json_rpc.rs @@ -14,8 +14,7 @@ use jsonrpsee::{ use miette::Diagnostic; use ordermap::OrderMap; use pixi_build_types::{ - BackendCapabilities, FrontendCapabilities, ProjectModelV1, TargetSelectorV1, - VersionedProjectModel, + BackendCapabilities, FrontendCapabilities, PackageModel, TargetSelectorV1, procedures::{ self, conda_build_v1::{CondaBuildV1Params, CondaBuildV1Result}, @@ -146,7 +145,7 @@ impl JsonRpcBackend { source_dir: PathBuf, manifest_path: PathBuf, workspace_root: PathBuf, - package_manifest: Option, + package_model: Option, configuration: Option, target_configuration: Option>, cache_dir: Option, @@ -196,7 +195,7 @@ impl JsonRpcBackend { source_dir, manifest_path, workspace_root, - package_manifest, + package_model, configuration, target_configuration, cache_dir, @@ -215,7 +214,7 @@ impl JsonRpcBackend { source_dir: PathBuf, manifest_path: PathBuf, workspace_root: PathBuf, - project_model: Option, + package_model: Option, configuration: Option, target_configuration: Option>, cache_dir: Option, @@ -252,7 +251,7 @@ impl JsonRpcBackend { .request( procedures::initialize::METHOD_NAME, RpcParams::from(InitializeParams { - project_model: project_model.map(VersionedProjectModel::V1), + package_model, configuration, target_configuration, manifest_path: manifest_path.clone(), diff --git a/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_cpp.snap b/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_cpp.snap index 90a49d5d05..ec5fb208df 100644 --- a/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_cpp.snap +++ b/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_cpp.snap @@ -1,6 +1,6 @@ --- source: crates/pixi_build_frontend/src/into_build_types.rs -expression: project_model +expression: package_model --- { "name": "python_bindings", diff --git a/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_python.snap b/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_python.snap index 2152e500b8..e774ec0c76 100644 --- a/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_python.snap +++ b/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_python.snap @@ -1,6 +1,6 @@ --- source: crates/pixi_build_frontend/src/into_build_types.rs -expression: project_model +expression: package_model --- { "name": "rich_example", diff --git a/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_workspace.snap b/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_workspace.snap index 2152e500b8..e774ec0c76 100644 --- a/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_workspace.snap +++ b/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_docs@pixi_build_workspace.snap @@ -1,6 +1,6 @@ --- source: crates/pixi_build_frontend/src/into_build_types.rs -expression: project_model +expression: package_model --- { "name": "rich_example", diff --git a/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_examples@boltons.snap b/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_examples@boltons.snap index fb65f4ff13..bdc15bd048 100644 --- a/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_examples@boltons.snap +++ b/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_examples@boltons.snap @@ -1,6 +1,6 @@ --- source: crates/pixi_build_frontend/src/into_build_types.rs -expression: project_model +expression: package_model --- { "name": "boltons", diff --git a/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_examples@cpp-sdl.snap b/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_examples@cpp-sdl.snap index 2cad6ea6e0..b3a0237940 100644 --- a/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_examples@cpp-sdl.snap +++ b/crates/pixi_build_frontend/src/snapshots/pixi_build_frontend__into_build_types__tests__conversions_v1_examples@cpp-sdl.snap @@ -1,6 +1,6 @@ --- source: crates/pixi_build_frontend/src/into_build_types.rs -expression: project_model +expression: package_model --- { "name": "sdl_example", diff --git a/crates/pixi_build_type_conversions/src/lib.rs b/crates/pixi_build_type_conversions/src/lib.rs index 4374a66a55..c0321af408 100644 --- a/crates/pixi_build_type_conversions/src/lib.rs +++ b/crates/pixi_build_type_conversions/src/lib.rs @@ -1,3 +1,3 @@ mod project_model; -pub use project_model::{to_project_model_v1, to_target_selector_v1}; +pub use project_model::{to_package_model, to_target_selector_v1}; diff --git a/crates/pixi_build_type_conversions/src/project_model.rs b/crates/pixi_build_type_conversions/src/project_model.rs index 8d285bd3fd..2775465121 100644 --- a/crates/pixi_build_type_conversions/src/project_model.rs +++ b/crates/pixi_build_type_conversions/src/project_model.rs @@ -163,12 +163,12 @@ fn to_targets_v1( }) } -/// Converts a [`PackageManifest`] to a [`pbt::ProjectModelV1`]. -pub fn to_project_model_v1( +/// Converts a [`PackageManifest`] to a [`pbt::PackageModel`]. +pub fn to_package_model( manifest: &PackageManifest, channel_config: &ChannelConfig, -) -> Result { - let project = pbt::ProjectModelV1 { +) -> Result { + let project = pbt::PackageModel { name: manifest.package.name.clone(), version: manifest.package.version.clone(), description: manifest.package.description.clone(), @@ -188,7 +188,6 @@ pub fn to_project_model_v1( mod tests { use std::path::PathBuf; - use pixi_build_types::VersionedProjectModel; use rattler_conda_types::ChannelConfig; use rstest::rstest; @@ -220,15 +219,14 @@ mod tests { .and_then(OsStr::to_str) .unwrap(); - // Convert the manifest to the project model - let project_model: VersionedProjectModel = - super::to_project_model_v1(&package_manifest.value, &some_channel_config()) - .unwrap() - .into(); + // Convert the manifest to the package model + let package_model = + super::to_package_model(&package_manifest.value, &some_channel_config()) + .unwrap(); let mut settings = insta::Settings::clone_current(); settings.set_snapshot_suffix(name); settings.bind(|| { - insta::assert_json_snapshot!(project_model); + insta::assert_json_snapshot!(package_model); }); } }}; diff --git a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@advanced_cpp.snap b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@advanced_cpp.snap index 42c45fb6b0..cd4fc9cde2 100644 --- a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@advanced_cpp.snap +++ b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@advanced_cpp.snap @@ -1,27 +1,24 @@ --- source: crates/pixi_build_type_conversions/src/project_model.rs -expression: project_model +expression: package_model --- { - "version": "1", - "data": { - "name": "cpp_math", - "version": "0.1.0", - "description": null, - "authors": null, - "license": null, - "licenseFile": null, - "readme": null, - "homepage": null, - "repository": null, - "documentation": null, - "targets": { - "defaultTarget": { - "hostDependencies": {}, - "buildDependencies": {}, - "runDependencies": {} - }, - "targets": {} - } + "name": "cpp_math", + "version": "0.1.0", + "description": null, + "authors": null, + "license": null, + "licenseFile": null, + "readme": null, + "homepage": null, + "repository": null, + "documentation": null, + "targets": { + "defaultTarget": { + "hostDependencies": {}, + "buildDependencies": {}, + "runDependencies": {} + }, + "targets": {} } } diff --git a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@advanced_python.snap b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@advanced_python.snap index cab0bb13f8..df10ba9e08 100644 --- a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@advanced_python.snap +++ b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@advanced_python.snap @@ -1,27 +1,24 @@ --- source: crates/pixi_build_type_conversions/src/project_model.rs -expression: project_model +expression: package_model --- { - "version": "1", - "data": { - "name": "rich_example", - "version": "0.1.0", - "description": null, - "authors": null, - "license": null, - "licenseFile": null, - "readme": null, - "homepage": null, - "repository": null, - "documentation": null, - "targets": { - "defaultTarget": { - "hostDependencies": {}, - "buildDependencies": {}, - "runDependencies": {} - }, - "targets": {} - } + "name": "rich_example", + "version": "0.1.0", + "description": null, + "authors": null, + "license": null, + "licenseFile": null, + "readme": null, + "homepage": null, + "repository": null, + "documentation": null, + "targets": { + "defaultTarget": { + "hostDependencies": {}, + "buildDependencies": {}, + "runDependencies": {} + }, + "targets": {} } } diff --git a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@cpp.snap b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@cpp.snap index b5e3947b63..de539e08ab 100644 --- a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@cpp.snap +++ b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@cpp.snap @@ -1,70 +1,67 @@ --- source: crates/pixi_build_type_conversions/src/project_model.rs -expression: project_model +expression: package_model --- { - "version": "1", - "data": { - "name": "cpp_math", - "version": "0.1.0", - "description": null, - "authors": null, - "license": null, - "licenseFile": null, - "readme": null, - "homepage": null, - "repository": null, - "documentation": null, - "targets": { - "defaultTarget": { - "hostDependencies": { - "cmake": { - "binary": { - "version": "3.20.*", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null - } - }, - "nanobind": { - "binary": { - "version": "2.4.*", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null - } - }, - "python": { - "binary": { - "version": "3.12.*", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null - } + "name": "cpp_math", + "version": "0.1.0", + "description": null, + "authors": null, + "license": null, + "licenseFile": null, + "readme": null, + "homepage": null, + "repository": null, + "documentation": null, + "targets": { + "defaultTarget": { + "hostDependencies": { + "cmake": { + "binary": { + "version": "3.20.*", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null } }, - "buildDependencies": {}, - "runDependencies": {} + "nanobind": { + "binary": { + "version": "2.4.*", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null + } + }, + "python": { + "binary": { + "version": "3.12.*", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null + } + } }, - "targets": {} - } + "buildDependencies": {}, + "runDependencies": {} + }, + "targets": {} } } diff --git a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@getting_started.snap b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@getting_started.snap index 9379b82def..682f8291d8 100644 --- a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@getting_started.snap +++ b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@getting_started.snap @@ -1,58 +1,55 @@ --- source: crates/pixi_build_type_conversions/src/project_model.rs -expression: project_model +expression: package_model snapshot_kind: text --- { - "version": "1", - "data": { - "name": "python_rich", - "version": "0.1.0", - "description": null, - "authors": null, - "license": null, - "licenseFile": null, - "readme": null, - "homepage": null, - "repository": null, - "documentation": null, - "targets": { - "defaultTarget": { - "hostDependencies": { - "hatchling": { - "binary": { - "version": "*", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null - } - } - }, - "buildDependencies": {}, - "runDependencies": { - "rich": { - "binary": { - "version": "13.9.*", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null - } + "name": "python_rich", + "version": "0.1.0", + "description": null, + "authors": null, + "license": null, + "licenseFile": null, + "readme": null, + "homepage": null, + "repository": null, + "documentation": null, + "targets": { + "defaultTarget": { + "hostDependencies": { + "hatchling": { + "binary": { + "version": "*", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null } } }, - "targets": {} - } + "buildDependencies": {}, + "runDependencies": { + "rich": { + "binary": { + "version": "13.9.*", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null + } + } + } + }, + "targets": {} } } diff --git a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@python.snap b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@python.snap index 31ac10f757..418b6f2770 100644 --- a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@python.snap +++ b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@python.snap @@ -1,57 +1,54 @@ --- source: crates/pixi_build_type_conversions/src/project_model.rs -expression: project_model +expression: package_model --- { - "version": "1", - "data": { - "name": "python_rich", - "version": "0.1.0", - "description": null, - "authors": null, - "license": null, - "licenseFile": null, - "readme": null, - "homepage": null, - "repository": null, - "documentation": null, - "targets": { - "defaultTarget": { - "hostDependencies": { - "hatchling": { - "binary": { - "version": "==1.26.3", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null - } - } - }, - "buildDependencies": {}, - "runDependencies": { - "rich": { - "binary": { - "version": "13.9.*", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null - } + "name": "python_rich", + "version": "0.1.0", + "description": null, + "authors": null, + "license": null, + "licenseFile": null, + "readme": null, + "homepage": null, + "repository": null, + "documentation": null, + "targets": { + "defaultTarget": { + "hostDependencies": { + "hatchling": { + "binary": { + "version": "==1.26.3", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null } } }, - "targets": {} - } + "buildDependencies": {}, + "runDependencies": { + "rich": { + "binary": { + "version": "13.9.*", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null + } + } + } + }, + "targets": {} } } diff --git a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@workspace.snap b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@workspace.snap index 5139394a89..146e2ce62e 100644 --- a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@workspace.snap +++ b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@workspace.snap @@ -1,64 +1,61 @@ --- source: crates/pixi_build_type_conversions/src/project_model.rs -expression: project_model +expression: package_model --- { - "version": "1", - "data": { - "name": "python_rich", - "version": "0.1.0", - "description": null, - "authors": null, - "license": null, - "licenseFile": null, - "readme": null, - "homepage": null, - "repository": null, - "documentation": null, - "targets": { - "defaultTarget": { - "hostDependencies": { - "hatchling": { - "binary": { - "version": "==1.26.3", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null + "name": "python_rich", + "version": "0.1.0", + "description": null, + "authors": null, + "license": null, + "licenseFile": null, + "readme": null, + "homepage": null, + "repository": null, + "documentation": null, + "targets": { + "defaultTarget": { + "hostDependencies": { + "hatchling": { + "binary": { + "version": "==1.26.3", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null + } + } + }, + "buildDependencies": {}, + "runDependencies": { + "cpp_math": { + "source": { + "Path": { + "path": "packages/cpp_math" } } }, - "buildDependencies": {}, - "runDependencies": { - "cpp_math": { - "source": { - "Path": { - "path": "packages/cpp_math" - } - } - }, - "rich": { - "binary": { - "version": "13.9.*", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null - } + "rich": { + "binary": { + "version": "13.9.*", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null } } - }, - "targets": {} - } + } + }, + "targets": {} } } diff --git a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@workspace_variants.snap b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@workspace_variants.snap index c4268bf53a..ec416a52f4 100644 --- a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@workspace_variants.snap +++ b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_docs@workspace_variants.snap @@ -1,64 +1,61 @@ --- source: crates/pixi_build_type_conversions/src/project_model.rs -expression: project_model +expression: package_model --- { - "version": "1", - "data": { - "name": "python_rich", - "version": "0.1.0", - "description": null, - "authors": null, - "license": null, - "licenseFile": null, - "readme": null, - "homepage": null, - "repository": null, - "documentation": null, - "targets": { - "defaultTarget": { - "hostDependencies": { - "hatchling": { - "binary": { - "version": "==1.26.3", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null + "name": "python_rich", + "version": "0.1.0", + "description": null, + "authors": null, + "license": null, + "licenseFile": null, + "readme": null, + "homepage": null, + "repository": null, + "documentation": null, + "targets": { + "defaultTarget": { + "hostDependencies": { + "hatchling": { + "binary": { + "version": "==1.26.3", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null + } + } + }, + "buildDependencies": {}, + "runDependencies": { + "cpp_math": { + "source": { + "Path": { + "path": "packages/cpp_math" } } }, - "buildDependencies": {}, - "runDependencies": { - "cpp_math": { - "source": { - "Path": { - "path": "packages/cpp_math" - } - } - }, - "rich": { - "binary": { - "version": ">=13.9.4,<14", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null - } + "rich": { + "binary": { + "version": ">=13.9.4,<14", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null } } - }, - "targets": {} - } + } + }, + "targets": {} } } diff --git a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_examples@array-api-extra.snap b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_examples@array-api-extra.snap index 55e7aa78be..07536ad3d7 100644 --- a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_examples@array-api-extra.snap +++ b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_examples@array-api-extra.snap @@ -1,27 +1,24 @@ --- source: crates/pixi_build_type_conversions/src/project_model.rs -expression: project_model +expression: package_model --- { - "version": "1", - "data": { - "name": "array-api-extra", - "version": "0.8.0", - "description": null, - "authors": null, - "license": null, - "licenseFile": null, - "readme": null, - "homepage": null, - "repository": null, - "documentation": null, - "targets": { - "defaultTarget": { - "hostDependencies": {}, - "buildDependencies": {}, - "runDependencies": {} - }, - "targets": {} - } + "name": "array-api-extra", + "version": "0.8.0", + "description": null, + "authors": null, + "license": null, + "licenseFile": null, + "readme": null, + "homepage": null, + "repository": null, + "documentation": null, + "targets": { + "defaultTarget": { + "hostDependencies": {}, + "buildDependencies": {}, + "runDependencies": {} + }, + "targets": {} } } diff --git a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_examples@cpp-sdl.snap b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_examples@cpp-sdl.snap index 9881fa4641..0149e028a9 100644 --- a/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_examples@cpp-sdl.snap +++ b/crates/pixi_build_type_conversions/src/snapshots/pixi_build_type_conversions__project_model__tests__conversions_v1_examples@cpp-sdl.snap @@ -1,44 +1,41 @@ --- source: crates/pixi_build_type_conversions/src/project_model.rs -expression: project_model +expression: package_model --- { - "version": "1", - "data": { - "name": "sdl_example", - "version": "0.1.0", - "description": "Showcases how to create a simple C++ executable with Pixi", - "authors": [ - "Bas Zalmstra " - ], - "license": null, - "licenseFile": null, - "readme": null, - "homepage": null, - "repository": null, - "documentation": null, - "targets": { - "defaultTarget": { - "hostDependencies": { - "sdl2": { - "binary": { - "version": ">=2.26.5,<3.0", - "build": null, - "buildNumber": null, - "fileName": null, - "channel": null, - "subdir": null, - "md5": null, - "sha256": null, - "url": null, - "license": null - } + "name": "sdl_example", + "version": "0.1.0", + "description": "Showcases how to create a simple C++ executable with Pixi", + "authors": [ + "Bas Zalmstra " + ], + "license": null, + "licenseFile": null, + "readme": null, + "homepage": null, + "repository": null, + "documentation": null, + "targets": { + "defaultTarget": { + "hostDependencies": { + "sdl2": { + "binary": { + "version": ">=2.26.5,<3.0", + "build": null, + "buildNumber": null, + "fileName": null, + "channel": null, + "subdir": null, + "md5": null, + "sha256": null, + "url": null, + "license": null } - }, - "buildDependencies": {}, - "runDependencies": {} + } }, - "targets": {} - } + "buildDependencies": {}, + "runDependencies": {} + }, + "targets": {} } } diff --git a/crates/pixi_build_types/src/lib.rs b/crates/pixi_build_types/src/lib.rs index e71082713d..f425ed2b7e 100644 --- a/crates/pixi_build_types/src/lib.rs +++ b/crates/pixi_build_types/src/lib.rs @@ -11,9 +11,9 @@ pub use capabilities::{BackendCapabilities, FrontendCapabilities}; pub use channel_configuration::ChannelConfiguration; pub use conda_package_metadata::CondaPackageMetadata; pub use project_model::{ - BinaryPackageSpecV1, GitReferenceV1, GitSpecV1, NamedSpecV1, PackageSpecV1, PathSpecV1, - ProjectModelV1, SourcePackageName, SourcePackageSpecV1, TargetSelectorV1, TargetV1, TargetsV1, - UrlSpecV1, VersionedProjectModel, + BinaryPackageSpecV1, GitReferenceV1, GitSpecV1, NamedSpecV1, PackageModel, PackageSpecV1, + PathSpecV1, SourcePackageName, SourcePackageSpecV1, TargetSelectorV1, TargetV1, TargetsV1, + UrlSpecV1, }; use rattler_conda_types::{ GenericVirtualPackage, PackageName, Platform, Version, VersionSpec, @@ -24,14 +24,15 @@ use serde::{Deserialize, Serialize}; // Version 0: Initial version (removed) // Version 1: Added conda/outputs and conda/build_v1 // Version 2: Name in project models can be `None`. +// Version 3: Package model unversioned and negotiated by API version only. /// The constraint for the pixi build api version package /// Adding this constraint when solving a pixi build backend environment ensures /// that a backend is selected that uses the same interface version as Pixi does pub static PIXI_BUILD_API_VERSION_NAME: LazyLock = LazyLock::new(|| PackageName::new_unchecked("pixi-build-api-version")); -pub const PIXI_BUILD_API_VERSION_LOWER: u64 = 1; -pub const PIXI_BUILD_API_VERSION_CURRENT: u64 = 2; +pub const PIXI_BUILD_API_VERSION_LOWER: u64 = 3; +pub const PIXI_BUILD_API_VERSION_CURRENT: u64 = 3; pub const PIXI_BUILD_API_VERSION_UPPER: u64 = PIXI_BUILD_API_VERSION_CURRENT + 1; pub static PIXI_BUILD_API_VERSION_SPEC: LazyLock = LazyLock::new(|| { VersionSpec::Group( @@ -84,6 +85,9 @@ impl PixiBuildApiVersion { 2 => BackendCapabilities { ..Self(1).expected_backend_capabilities() }, + 3 => BackendCapabilities { + ..Self(2).expected_backend_capabilities() + }, _ => BackendCapabilities::default(), } } diff --git a/crates/pixi_build_types/src/procedures/initialize.rs b/crates/pixi_build_types/src/procedures/initialize.rs index acaa8f244b..ed0008edcc 100644 --- a/crates/pixi_build_types/src/procedures/initialize.rs +++ b/crates/pixi_build_types/src/procedures/initialize.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use ordermap::OrderMap; use serde::{Deserialize, Serialize}; -use crate::{TargetSelectorV1, VersionedProjectModel}; +use crate::{PackageModel, TargetSelectorV1}; pub const METHOD_NAME: &str = "initialize"; @@ -45,10 +45,10 @@ pub struct InitializeParams { /// Optionally the cache directory to use for any caching activity. pub cache_directory: Option, - /// Project model that the backend should use even though it is an option + /// Package model that the backend should use even though it is an option /// it is highly recommended to use this field. Otherwise, it will be very /// easy to break backwards compatibility. - pub project_model: Option, + pub package_model: Option, /// Backend specific configuration passed from the frontend to the backend. pub configuration: Option, diff --git a/crates/pixi_build_types/src/project_model.rs b/crates/pixi_build_types/src/project_model.rs index 5a9c1d19c1..d59100a03c 100644 --- a/crates/pixi_build_types/src/project_model.rs +++ b/crates/pixi_build_types/src/project_model.rs @@ -9,15 +9,6 @@ //! that we try not to break this in pixi as much as possible. So as long as //! older pixi TOMLs keep loading, we can send them to the backend. //! -//! In regards to forwards compatibility, we want to be able to keep converting -//! to all versions of the `VersionedProjectModel` as much as possible. -//! -//! This is why we append a `V{version}` to the type names, to indicate the -//! version of the protocol. -//! -//! Only the whole ProjectModel is versioned explicitly in an enum. -//! When making a change to one of the types, be sure to add another enum -//! declaration if it is breaking. use std::{convert::Infallible, fmt::Display, hash::Hash, path::PathBuf, str::FromStr}; use ordermap::OrderMap; @@ -28,50 +19,12 @@ use serde::{Deserialize, Serialize}; use serde_with::{DeserializeFromStr, DisplayFromStr, SerializeDisplay, serde_as}; use url::Url; -/// Enum containing all versions of the project model. -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(tag = "version", content = "data")] -#[serde(rename_all = "camelCase")] -pub enum VersionedProjectModel { - /// Version 1 of the project model. - #[serde(rename = "1")] - V1(ProjectModelV1), - // When adding don't forget to update the highest_version function -} - -impl VersionedProjectModel { - /// Highest version of the project model. - pub fn highest_version() -> u32 { - // increase this when adding a new version - 1 - } - - /// Move into the v1 type, returns None if the version is not v1. - pub fn into_v1(self) -> Option { - match self { - VersionedProjectModel::V1(v) => Some(v), - // Add this once we have more versions - //_ => None, - } - } - - /// Returns a reference to the v1 type, returns None if the version is not - /// v1. - pub fn as_v1(&self) -> Option<&ProjectModelV1> { - match self { - VersionedProjectModel::V1(v) => Some(v), - // Add this once we have more versions - //_ => None, - } - } -} - /// The source package name of a package. Not normalized per se. pub type SourcePackageName = String; #[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "camelCase")] -pub struct ProjectModelV1 { +pub struct PackageModel { /// The name of the project pub name: Option, @@ -102,12 +55,12 @@ pub struct ProjectModelV1 { /// URL of the project documentation pub documentation: Option, - /// The target of the project, this may contain + /// The target of the package, this may contain /// platform specific configurations. pub targets: Option, } -impl IsDefault for ProjectModelV1 { +impl IsDefault for PackageModel { type Item = Self; fn is_non_default(&self) -> Option<&Self::Item> { @@ -115,12 +68,6 @@ impl IsDefault for ProjectModelV1 { } } -impl From for VersionedProjectModel { - fn from(value: ProjectModelV1) -> Self { - VersionedProjectModel::V1(value) - } -} - /// Represents a target selector. Currently, we only support explicit platform /// selection. #[derive(Debug, Clone, DeserializeFromStr, SerializeDisplay, Eq, PartialEq)] @@ -193,13 +140,13 @@ impl IsDefault for TargetsV1 { #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "camelCase")] pub struct TargetV1 { - /// Host dependencies of the project + /// Host dependencies of the package pub host_dependencies: Option>, - /// Build dependencies of the project + /// Build dependencies of the package pub build_dependencies: Option>, - /// Run dependencies of the project + /// Run dependencies of the package pub run_dependencies: Option>, } @@ -415,12 +362,12 @@ impl std::fmt::Debug for BinaryPackageSpecV1 { } // Custom Hash implementations that skip default values for stability -impl Hash for ProjectModelV1 { +impl Hash for PackageModel { /// Custom hash implementation using StableHashBuilder to ensure different /// field configurations produce different hashes while maintaining /// forward/backward compatibility. fn hash(&self, state: &mut H) { - let ProjectModelV1 { + let PackageModel { name, version, description, @@ -644,8 +591,8 @@ mod tests { #[test] fn test_hash_stability_with_default_values() { - // Create a minimal ProjectModelV1 instance - let mut project_model = ProjectModelV1 { + // Create a minimal PackageModel instance + let mut package_model = PackageModel { name: Some("test-project".to_string()), version: None, description: None, @@ -659,16 +606,16 @@ mod tests { targets: None, }; - let hash1 = calculate_hash(&project_model); + let hash1 = calculate_hash(&package_model); // Add empty targets field - with corrected implementation, this should NOT // change hash because we only include discriminants for // non-default/non-empty values - project_model.targets = Some(TargetsV1 { + package_model.targets = Some(TargetsV1 { default_target: None, targets: Some(OrderMap::new()), }); - let hash2 = calculate_hash(&project_model); + let hash2 = calculate_hash(&package_model); // Add a target with empty dependencies - this should also NOT change hash let empty_target = TargetV1 { @@ -676,11 +623,11 @@ mod tests { build_dependencies: Some(OrderMap::new()), run_dependencies: Some(OrderMap::new()), }; - project_model.targets = Some(TargetsV1 { + package_model.targets = Some(TargetsV1 { default_target: Some(empty_target), targets: Some(OrderMap::new()), }); - let hash3 = calculate_hash(&project_model); + let hash3 = calculate_hash(&package_model); // With corrected implementation, hashes should remain stable when adding // empty/default values This preserves forward/backward compatibility @@ -700,8 +647,8 @@ mod tests { #[test] fn test_hash_changes_with_meaningful_values() { - // Create a minimal ProjectModelV1 instance - let mut project_model = ProjectModelV1 { + // Create a minimal PackageModel instance + let mut package_model = PackageModel { name: Some("test-project".to_string()), version: None, description: None, @@ -715,11 +662,11 @@ mod tests { targets: None, }; - let hash1 = calculate_hash(&project_model); + let hash1 = calculate_hash(&package_model); // Add a meaningful field (should change hash) - project_model.description = Some("A test project".to_string()); - let hash2 = calculate_hash(&project_model); + package_model.description = Some("A test project".to_string()); + let hash2 = calculate_hash(&package_model); // Add a real dependency (should change hash) let mut deps = OrderMap::new(); @@ -730,11 +677,11 @@ mod tests { build_dependencies: Some(OrderMap::new()), run_dependencies: Some(OrderMap::new()), }; - project_model.targets = Some(TargetsV1 { + package_model.targets = Some(TargetsV1 { default_target: Some(target_with_deps), targets: Some(OrderMap::new()), }); - let hash3 = calculate_hash(&project_model); + let hash3 = calculate_hash(&package_model); // Hash should change when adding meaningful values assert_ne!(hash1, hash2, "Hash should change when adding description"); @@ -994,28 +941,28 @@ mod tests { } #[test] - fn test_hash_collision_bug_project_model() { - // Test the same issue in ProjectModelV1 - let project1 = ProjectModelV1 { + fn test_hash_collision_bug_package_model() { + // Test the same issue in PackageModel + let package1 = PackageModel { name: Some("test".to_string()), description: Some("test description".to_string()), license: None, ..Default::default() }; - let project2 = ProjectModelV1 { + let package2 = PackageModel { name: Some("test".to_string()), description: None, license: Some("test description".to_string()), ..Default::default() }; - let hash1 = calculate_hash(&project1); - let hash2 = calculate_hash(&project2); + let hash1 = calculate_hash(&package1); + let hash2 = calculate_hash(&package2); assert_ne!( hash1, hash2, - "Same value in different fields should produce different hashes in ProjectModelV1" + "Same value in different fields should produce different hashes in PackageModel" ); } } diff --git a/crates/pixi_command_dispatcher/src/build/build_cache.rs b/crates/pixi_command_dispatcher/src/build/build_cache.rs index 6b1c7da725..30c18f6ed2 100644 --- a/crates/pixi_command_dispatcher/src/build/build_cache.rs +++ b/crates/pixi_command_dispatcher/src/build/build_cache.rs @@ -9,7 +9,7 @@ use async_fd_lock::{LockWrite, RwLockWriteGuard}; use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD}; use ordermap::OrderMap; use pixi_build_discovery::{BackendInitializationParams, DiscoveredBackend}; -use pixi_build_types::{ProjectModelV1, TargetSelectorV1}; +use pixi_build_types::{PackageModel, TargetSelectorV1}; use pixi_record::PinnedSourceSpec; use pixi_stable_hash::{StableHashBuilder, json::StableJson, map::StableMap}; use rattler_conda_types::{ChannelUrl, GenericVirtualPackage, Platform, RepoDataRecord}; @@ -316,8 +316,8 @@ impl BuildCacheEntry { /// This is used to compute a singular hash that changes when a rebuild is /// warranted. pub struct PackageBuildInputHashBuilder<'a> { - /// The project model itself. Contains dependencies and more. - pub project_model: Option<&'a ProjectModelV1>, + /// The package model itself. Contains dependencies and more. + pub package_model: Option<&'a PackageModel>, /// The backend specific configuration pub configuration: Option<&'a serde_json::Value>, @@ -330,7 +330,7 @@ impl PackageBuildInputHashBuilder<'_> { pub fn finish(self) -> PackageBuildInputHash { let mut hasher = Xxh3::new(); StableHashBuilder::new() - .field("project_model", &self.project_model) + .field("package_model", &self.package_model) .field("configuration", &self.configuration.map(StableJson::new)) .field( "target_configuration", @@ -350,7 +350,7 @@ pub struct PackageBuildInputHash(u64); impl<'a> From<&'a DiscoveredBackend> for PackageBuildInputHash { fn from(value: &'a DiscoveredBackend) -> Self { let BackendInitializationParams { - project_model, + package_model, configuration, target_configuration, @@ -362,7 +362,7 @@ impl<'a> From<&'a DiscoveredBackend> for PackageBuildInputHash { } = &value.init_params; PackageBuildInputHashBuilder { - project_model: project_model.as_ref(), + package_model: package_model.as_ref(), configuration: configuration.as_ref(), target_configuration: target_configuration.as_ref(), } diff --git a/crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs b/crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs index e3eeb6873c..a5d2d32a75 100644 --- a/crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs +++ b/crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs @@ -11,7 +11,7 @@ use once_cell::sync::Lazy; use pathdiff::diff_paths; use pixi_build_discovery::{CommandSpec, EnabledProtocols}; use pixi_build_frontend::Backend; -use pixi_build_types::{ProjectModelV1, procedures::conda_outputs::CondaOutputsParams}; +use pixi_build_types::{PackageModel, procedures::conda_outputs::CondaOutputsParams}; use pixi_glob::GlobHashKey; use pixi_record::{InputHash, PinnedSourceSpec}; use pixi_spec::{SourceAnchor, SourceSpec}; @@ -120,9 +120,9 @@ impl BuildBackendMetadataSpec { .await .map_err_with(BuildBackendMetadataError::Discovery)?; - // Calculate the hash of the project model + // Calculate the hash of the package model let additional_glob_hash = calculate_additional_glob_hash( - &discovered_backend.init_params.project_model, + &discovered_backend.init_params.package_model, &self.variants, ); @@ -488,12 +488,12 @@ pub enum BuildBackendMetadataError { /// Computes an additional hash to be used in glob hash pub fn calculate_additional_glob_hash( - project_model: &Option, + package_model: &Option, variants: &Option>>, ) -> Vec { let mut hasher = Xxh3::new(); - if let Some(project_model) = project_model { - project_model.hash(&mut hasher); + if let Some(package_model) = package_model { + package_model.hash(&mut hasher); } if let Some(variants) = variants { if !variants.is_empty() { diff --git a/crates/pixi_command_dispatcher/src/command_dispatcher/instantiate_backend.rs b/crates/pixi_command_dispatcher/src/command_dispatcher/instantiate_backend.rs index cb5a3ffabd..e8a27527e4 100644 --- a/crates/pixi_command_dispatcher/src/command_dispatcher/instantiate_backend.rs +++ b/crates/pixi_command_dispatcher/src/command_dispatcher/instantiate_backend.rs @@ -84,7 +84,7 @@ impl CommandDispatcher { source_dir: Some(source_dir), workspace_root: Some(spec.init_params.workspace_root), cache_directory: Some(self.cache_dirs().root().clone()), - project_model: spec.init_params.project_model.map(Into::into), + package_model: spec.init_params.package_model.map(Into::into), configuration: spec.init_params.configuration, target_configuration: spec.init_params.target_configuration, }) @@ -163,11 +163,11 @@ impl CommandDispatcher { api_version, ); - // Make sure that the project model is compatible with the API version. + // Make sure that the package model is compatible with the API version. if !api_version.supports_name_none() && spec .init_params - .project_model + .package_model .as_ref() .is_some_and(|p| p.name.is_none()) { @@ -180,7 +180,7 @@ impl CommandDispatcher { source_dir, spec.init_params.manifest_path, spec.init_params.workspace_root, - spec.init_params.project_model, + spec.init_params.package_model, spec.init_params.configuration, spec.init_params.target_configuration, Some(self.cache_dirs().root().clone()), diff --git a/crates/pixi_command_dispatcher/src/source_build_cache_status/mod.rs b/crates/pixi_command_dispatcher/src/source_build_cache_status/mod.rs index 544d7f80ff..2966c2bad7 100644 --- a/crates/pixi_command_dispatcher/src/source_build_cache_status/mod.rs +++ b/crates/pixi_command_dispatcher/src/source_build_cache_status/mod.rs @@ -334,7 +334,7 @@ impl SourceBuildCacheStatusSpec { // Compute a hash of the package configuration. let package_build_input_hash = PackageBuildInputHashBuilder { - project_model: backend.init_params.project_model.as_ref(), + package_model: backend.init_params.package_model.as_ref(), configuration: backend.init_params.configuration.as_ref(), target_configuration: backend.init_params.target_configuration.as_ref(), } diff --git a/crates/pixi_core/src/lock_file/satisfiability/mod.rs b/crates/pixi_core/src/lock_file/satisfiability/mod.rs index cfe809d1dd..6595b6a04f 100644 --- a/crates/pixi_core/src/lock_file/satisfiability/mod.rs +++ b/crates/pixi_core/src/lock_file/satisfiability/mod.rs @@ -1522,7 +1522,7 @@ pub(crate) async fn verify_package_platform_satisfiability( .map_err(|err| Box::new(err.into()))?; let additional_glob_hash = calculate_additional_glob_hash( - &discovered_backend.init_params.project_model, + &discovered_backend.init_params.package_model, &Some(variants), ); diff --git a/tests/data/channels/channels/backend_channel_1/noarch/backend-with-compatible-api-version-0.1.0-h4616a5c_0.conda b/tests/data/channels/channels/backend_channel_1/noarch/backend-with-compatible-api-version-0.1.0-h4616a5c_0.conda index da0c89d653..9329da20a5 100644 Binary files a/tests/data/channels/channels/backend_channel_1/noarch/backend-with-compatible-api-version-0.1.0-h4616a5c_0.conda and b/tests/data/channels/channels/backend_channel_1/noarch/backend-with-compatible-api-version-0.1.0-h4616a5c_0.conda differ diff --git a/tests/data/channels/channels/backend_channel_1/noarch/backend-without-compatible-api-version-0.1.0-h4616a5c_0.conda b/tests/data/channels/channels/backend_channel_1/noarch/backend-without-compatible-api-version-0.1.0-h4616a5c_0.conda index 8569ba31ba..a2c0552250 100644 Binary files a/tests/data/channels/channels/backend_channel_1/noarch/backend-without-compatible-api-version-0.1.0-h4616a5c_0.conda and b/tests/data/channels/channels/backend_channel_1/noarch/backend-without-compatible-api-version-0.1.0-h4616a5c_0.conda differ diff --git a/tests/data/channels/channels/backend_channel_1/noarch/pixi-build-api-version-1-h4616a5c_0.conda b/tests/data/channels/channels/backend_channel_1/noarch/pixi-build-api-version-1-h4616a5c_0.conda deleted file mode 100644 index 8462ee824f..0000000000 Binary files a/tests/data/channels/channels/backend_channel_1/noarch/pixi-build-api-version-1-h4616a5c_0.conda and /dev/null differ diff --git a/tests/data/channels/channels/backend_channel_1/noarch/pixi-build-api-version-3-h4616a5c_0.conda b/tests/data/channels/channels/backend_channel_1/noarch/pixi-build-api-version-3-h4616a5c_0.conda new file mode 100644 index 0000000000..6b5dd3888f Binary files /dev/null and b/tests/data/channels/channels/backend_channel_1/noarch/pixi-build-api-version-3-h4616a5c_0.conda differ diff --git a/tests/data/channels/channels/backend_channel_1/noarch/repodata.json b/tests/data/channels/channels/backend_channel_1/noarch/repodata.json index 854311e3a3..473de91d55 100644 --- a/tests/data/channels/channels/backend_channel_1/noarch/repodata.json +++ b/tests/data/channels/channels/backend_channel_1/noarch/repodata.json @@ -1 +1 @@ -{"info":{"subdir":"noarch"},"packages":{},"packages.conda":{"backend-with-compatible-api-version-0.1.0-h4616a5c_0.conda":{"build":"h4616a5c_0","build_number":0,"depends":["pixi-build-api-version ==1"],"md5":"12b7d1260e0a376e8fec9ac781726aa2","name":"backend-with-compatible-api-version","noarch":"generic","sha256":"638352af140ffaab24daf6f74dee4859b4458d1dd573482557bea8e0438ba4ee","size":1125,"subdir":"noarch","timestamp":1760432200978,"version":"0.1.0"},"backend-without-compatible-api-version-0.1.0-h4616a5c_0.conda":{"build":"h4616a5c_0","build_number":0,"depends":[],"md5":"2f5b2a8d8d85a3e5f37f15ad80057c83","name":"backend-without-compatible-api-version","noarch":"generic","sha256":"7ac6227d775fe1f91e1e08b9aeea381c02eb06dd9f0c5f581d498d0b5b02f92d","size":1112,"subdir":"noarch","timestamp":1760432201168,"version":"0.1.0"},"pixi-build-api-version-1-h4616a5c_0.conda":{"build":"h4616a5c_0","build_number":0,"depends":[],"md5":"92456514a6c475d54cb81a4b816fb117","name":"pixi-build-api-version","noarch":"generic","sha256":"04be84dacf8468facffa4e9ab52f1c99c0450e69f5afc03d8b58c82d747287fe","size":1011,"subdir":"noarch","timestamp":1760432201318,"version":"1"}},"repodata_version":2} \ No newline at end of file +{"info":{"subdir":"noarch"},"packages":{},"packages.conda":{"backend-with-compatible-api-version-0.1.0-h4616a5c_0.conda":{"build":"h4616a5c_0","build_number":0,"depends":["pixi-build-api-version ==3"],"md5":"24c7086ffb6c0148aa8dcc3b184e884a","name":"backend-with-compatible-api-version","noarch":"generic","sha256":"855922ea5f6ebe838f8b9259615ae050b1ca673df0a77bfd50b8eac48d9b8204","size":1127,"subdir":"noarch","timestamp":1761820573900,"version":"0.1.0"},"backend-without-compatible-api-version-0.1.0-h4616a5c_0.conda":{"build":"h4616a5c_0","build_number":0,"depends":[],"md5":"961fa3fafd26a5383454dc2b80d33f27","name":"backend-without-compatible-api-version","noarch":"generic","sha256":"3da0f2b40a1b91404d794fe0d977288640f88e8f9e9acf1c8d753ed8769bc036","size":1113,"subdir":"noarch","timestamp":1761820574387,"version":"0.1.0"},"pixi-build-api-version-3-h4616a5c_0.conda":{"build":"h4616a5c_0","build_number":0,"depends":[],"md5":"ce0c3e597e0f2cfa1d4f7bb302e237de","name":"pixi-build-api-version","noarch":"generic","sha256":"40ce1dbb2a6afc67cae856d5ae80d72c01f615fa223cf039c2d568c4a0729e84","size":1014,"subdir":"noarch","timestamp":1761820574865,"version":"3"}},"repodata_version":2} \ No newline at end of file diff --git a/tests/data/channels/recipes/backend_channel_1/backend-with-compatible-api-version.yaml b/tests/data/channels/recipes/backend_channel_1/backend-with-compatible-api-version.yaml index 1bc9ff4e08..193eda9c3f 100644 --- a/tests/data/channels/recipes/backend_channel_1/backend-with-compatible-api-version.yaml +++ b/tests/data/channels/recipes/backend_channel_1/backend-with-compatible-api-version.yaml @@ -4,7 +4,7 @@ package: requirements: run: - - pixi-build-api-version==1 + - pixi-build-api-version==3 build: noarch: generic diff --git a/tests/data/channels/recipes/backend_channel_1/pixi-build-api-version.yaml b/tests/data/channels/recipes/backend_channel_1/pixi-build-api-version.yaml index b5e3af8597..87dc8ad8dd 100644 --- a/tests/data/channels/recipes/backend_channel_1/pixi-build-api-version.yaml +++ b/tests/data/channels/recipes/backend_channel_1/pixi-build-api-version.yaml @@ -1,6 +1,6 @@ package: name: pixi-build-api-version - version: 1 + version: 3 build: noarch: generic