diff --git a/crates/pixi_build_types/src/procedures/conda_build_v1.rs b/crates/pixi_build_types/src/procedures/conda_build_v1.rs index 410b708830..a79c0119f4 100644 --- a/crates/pixi_build_types/src/procedures/conda_build_v1.rs +++ b/crates/pixi_build_types/src/procedures/conda_build_v1.rs @@ -10,7 +10,7 @@ use std::{ path::PathBuf, }; -use rattler_conda_types::{ChannelUrl, PackageName, Platform, VersionWithSource}; +use rattler_conda_types::{ChannelUrl, PackageName, Platform, RepoDataRecord, VersionWithSource}; use serde::{Deserialize, Serialize}; pub const METHOD_NAME: &str = "conda/build_v1"; @@ -59,8 +59,20 @@ pub struct CondaBuildV1Prefix { /// The platform for which the packages were installed. pub platform: Platform, - // TODO: Add information about matchspecs that were used to install the package. - // TODO: Add information about the packages that were installed. + + /// The packages that are installed in the prefix. + #[serde(default)] + pub packages: Vec, +} + +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(rename_all = "camelCase")] +pub struct CondaBuildV1PrefixPackage { + /// The repodata record of the package that was installed in the prefix. + #[serde(flatten)] + pub repodata_record: RepoDataRecord, + // TODO: Add information about how the package was introduced into the prefix. E.g. it was + // directly requested in the spec, or as a run_export, etc. } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/crates/pixi_command_dispatcher/src/backend_source_build/mod.rs b/crates/pixi_command_dispatcher/src/backend_source_build/mod.rs index 2813feb2fc..2a8bbc0357 100644 --- a/crates/pixi_command_dispatcher/src/backend_source_build/mod.rs +++ b/crates/pixi_command_dispatcher/src/backend_source_build/mod.rs @@ -16,12 +16,13 @@ use pixi_build_types::{ procedures::{ conda_build_v0::{CondaBuildParams, CondaBuiltPackage, CondaOutputIdentifier}, conda_build_v1::{ - CondaBuildV1Output, CondaBuildV1Params, CondaBuildV1Prefix, CondaBuildV1Result, + CondaBuildV1Output, CondaBuildV1Params, CondaBuildV1Prefix, CondaBuildV1PrefixPackage, + CondaBuildV1Result, }, }, }; -use pixi_record::{PinnedSourceSpec, PixiRecord}; -use rattler_conda_types::{ChannelConfig, ChannelUrl, Platform, Version}; +use pixi_record::PinnedSourceSpec; +use rattler_conda_types::{ChannelConfig, ChannelUrl, Platform, RepoDataRecord, Version}; use serde::Serialize; use thiserror::Error; @@ -113,7 +114,7 @@ pub struct BackendSourceBuildPrefix { pub prefix: PathBuf, /// The records that are installed in the prefix. - pub records: Vec, + pub records: Vec, } #[derive(Debug, Serialize)] @@ -275,10 +276,26 @@ impl BackendSourceBuildSpec { build_prefix: Some(CondaBuildV1Prefix { prefix: params.build_prefix.prefix, platform: params.build_prefix.platform, + packages: params + .build_prefix + .records + .into_iter() + .map(|record| CondaBuildV1PrefixPackage { + repodata_record: record, + }) + .collect(), }), host_prefix: Some(CondaBuildV1Prefix { prefix: params.host_prefix.prefix, platform: params.host_prefix.platform, + packages: params + .host_prefix + .records + .into_iter() + .map(|record| CondaBuildV1PrefixPackage { + repodata_record: record, + }) + .collect(), }), output: CondaBuildV1Output { name: record.name.clone(), diff --git a/crates/pixi_command_dispatcher/src/source_build/mod.rs b/crates/pixi_command_dispatcher/src/source_build/mod.rs index a6d3e6f2ee..923b29b1ce 100644 --- a/crates/pixi_command_dispatcher/src/source_build/mod.rs +++ b/crates/pixi_command_dispatcher/src/source_build/mod.rs @@ -477,6 +477,10 @@ impl SourceBuildSpec { CommandDispatcherError::Failed(SourceBuildError::CreateWorkDirectory(err)) })?; + // Extract the repodata records from the build and host environments. + let build_records = Self::extract_prefix_repodata(build_records, build_prefix); + let host_records = Self::extract_prefix_repodata(host_records, host_prefix); + let built_source = command_dispatcher .backend_source_build(BackendSourceBuildSpec { method: BackendSourceBuildMethod::BuildV1(BackendSourceBuildV1Method { @@ -484,12 +488,18 @@ impl SourceBuildSpec { build_prefix: BackendSourceBuildPrefix { platform: self.build_environment.build_platform, prefix: directories.build_prefix, - records: build_records.clone(), + records: build_records + .iter() + .map(|p| p.repodata_record.clone()) + .collect(), }, host_prefix: BackendSourceBuildPrefix { platform: self.build_environment.host_platform, prefix: directories.host_prefix, - records: host_records.clone(), + records: host_records + .iter() + .map(|p| p.repodata_record.clone()) + .collect(), }, variant: output.metadata.variant, output_directory: self.output_directory, @@ -503,50 +513,52 @@ impl SourceBuildSpec { .await .map_err_with(SourceBuildError::from)?; - // Little helper function the build a `BuildHostEnvironment` from expected and - // installed records. - let build_host_environment = - |records: Vec, prefix: Option| { - let Some(prefix) = prefix else { - return BuildHostEnvironment { packages: vec![] }; - }; - - BuildHostEnvironment { - packages: records - .into_iter() - .map(|record| match record { - PixiRecord::Binary(repodata_record) => BuildHostPackage { - repodata_record, - source: None, - }, - PixiRecord::Source(source) => { - let repodata_record = prefix - .resolved_source_records - .get(&source.package_record.name) - .cloned() - .expect( - "the source record should be present in the result sources", - ); - BuildHostPackage { - repodata_record, - source: Some(source.source), - } - } - }) - .collect(), - } - }; - Ok(BuiltPackage { output_file: built_source.output_file, metadata: CachedBuildSourceInfo { globs: built_source.input_globs, - build: build_host_environment(build_records, build_prefix), - host: build_host_environment(host_records, host_prefix), + build: BuildHostEnvironment { + packages: build_records, + }, + host: BuildHostEnvironment { + packages: host_records, + }, }, }) } + /// Little helper function the build a `BuildHostPackage` from expected and + /// installed records. + fn extract_prefix_repodata( + records: Vec, + prefix: Option, + ) -> Vec { + let Some(prefix) = prefix else { + return vec![]; + }; + + records + .into_iter() + .map(|record| match record { + PixiRecord::Binary(repodata_record) => BuildHostPackage { + repodata_record, + source: None, + }, + PixiRecord::Source(source) => { + let repodata_record = prefix + .resolved_source_records + .get(&source.package_record.name) + .cloned() + .expect("the source record should be present in the result sources"); + BuildHostPackage { + repodata_record, + source: Some(source.source), + } + } + }) + .collect() + } + async fn solve_dependencies( &self, name: String,