Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions crates/pixi_build_backend_passthrough/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -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::{
Expand All @@ -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<IndexJson>,
Expand Down Expand Up @@ -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())
Expand All @@ -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()))
Expand All @@ -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
Expand All @@ -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,
),
Expand Down Expand Up @@ -232,13 +232,10 @@ impl InMemoryBackendInstantiator for PassthroughBackendInstantiator {
&self,
params: InitializeParams,
) -> Result<Self::Backend, Box<CommunicationError>> {
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 {
Expand Down Expand Up @@ -269,7 +266,7 @@ impl InMemoryBackendInstantiator for PassthroughBackendInstantiator {
};

Ok(PassthroughBackend {
project_model,
package_model,
config,
source_dir,
index_json,
Expand Down
18 changes: 9 additions & 9 deletions crates/pixi_build_discovery/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<ProjectModelV1>,
/// Optionally, the package model of the discovered package.
pub package_model: Option<PackageModel>,

/// Additional configuration that applies to the backend.
pub configuration: Option<serde_json::Value>,
Expand Down Expand Up @@ -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,
},
Expand All @@ -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();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ init-params:
source: ~
source-anchor: "file://<ROOT>/ros-package"
manifest-path: "file://<ROOT>/ros-package/package.xml"
project-model:
package-model:
name: ~
version: ~
description: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ init-params:
source: ~
source-anchor: "file://<ROOT>/recipe_yaml"
manifest-path: "file://<ROOT>/recipe_yaml/recipe.yaml"
project-model: ~
package-model: ~
configuration: ~
target-configuration: ~
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ init-params:
source: ~
source-anchor: "file://<ROOT>/inherit/nested"
manifest-path: "file://<ROOT>/inherit/nested/pixi.toml"
project-model:
package-model:
name: simple
version: 0.1.0
description: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ init-params:
source: ~
source-anchor: "file://<ROOT>/nested/nested"
manifest-path: "file://<ROOT>/nested/nested/pixi.toml"
project-model:
package-model:
name: simple
version: 0.1.0
description: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ init-params:
source: ~
source-anchor: "file://<ROOT>/nested_recipe_yml"
manifest-path: "file://<ROOT>/nested_recipe_yml/recipe/recipe.yml"
project-model: ~
package-model: ~
configuration: ~
target-configuration: ~
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ init-params:
source: ~
source-anchor: "file://<ROOT>/recipe_yaml"
manifest-path: "file://<ROOT>/recipe_yaml/recipe.yaml"
project-model: ~
package-model: ~
configuration: ~
target-configuration: ~
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ init-params:
source: ~
source-anchor: "file://<ROOT>/recipe_yml"
manifest-path: "file://<ROOT>/recipe_yml/recipe.yml"
project-model: ~
package-model: ~
configuration: ~
target-configuration: ~
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ init-params:
source: ~
source-anchor: "file://<ROOT>/simple"
manifest-path: "file://<ROOT>/simple/pixi.toml"
project-model:
package-model:
name: simple
version: 0.1.0
description: ~
Expand Down
11 changes: 5 additions & 6 deletions crates/pixi_build_frontend/src/backend/json_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -146,7 +145,7 @@ impl JsonRpcBackend {
source_dir: PathBuf,
manifest_path: PathBuf,
workspace_root: PathBuf,
package_manifest: Option<ProjectModelV1>,
package_model: Option<PackageModel>,
configuration: Option<serde_json::Value>,
target_configuration: Option<OrderMap<TargetSelectorV1, serde_json::Value>>,
cache_dir: Option<PathBuf>,
Expand Down Expand Up @@ -196,7 +195,7 @@ impl JsonRpcBackend {
source_dir,
manifest_path,
workspace_root,
package_manifest,
package_model,
configuration,
target_configuration,
cache_dir,
Expand All @@ -215,7 +214,7 @@ impl JsonRpcBackend {
source_dir: PathBuf,
manifest_path: PathBuf,
workspace_root: PathBuf,
project_model: Option<ProjectModelV1>,
package_model: Option<PackageModel>,
configuration: Option<serde_json::Value>,
target_configuration: Option<OrderMap<TargetSelectorV1, serde_json::Value>>,
cache_dir: Option<PathBuf>,
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/pixi_build_frontend/src/into_build_types.rs
expression: project_model
expression: package_model
---
{
"name": "python_bindings",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/pixi_build_frontend/src/into_build_types.rs
expression: project_model
expression: package_model
---
{
"name": "rich_example",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/pixi_build_frontend/src/into_build_types.rs
expression: project_model
expression: package_model
---
{
"name": "rich_example",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/pixi_build_frontend/src/into_build_types.rs
expression: project_model
expression: package_model
---
{
"name": "boltons",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/pixi_build_frontend/src/into_build_types.rs
expression: project_model
expression: package_model
---
{
"name": "sdl_example",
Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_build_type_conversions/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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};
20 changes: 9 additions & 11 deletions crates/pixi_build_type_conversions/src/project_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<pbt::ProjectModelV1, SpecConversionError> {
let project = pbt::ProjectModelV1 {
) -> Result<pbt::PackageModel, SpecConversionError> {
let project = pbt::PackageModel {
name: manifest.package.name.clone(),
version: manifest.package.version.clone(),
description: manifest.package.description.clone(),
Expand All @@ -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;

Expand Down Expand Up @@ -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);
});
}
}};
Expand Down
Loading
Loading