Skip to content

Commit 08fcfb7

Browse files
authored
feat: add channels to the build-v1 apis (#4249)
1 parent cd6d61e commit 08fcfb7

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

crates/pixi_build_types/src/procedures/conda_build_v1.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::{
1010
path::PathBuf,
1111
};
1212

13-
use rattler_conda_types::{PackageName, Platform, VersionWithSource};
13+
use rattler_conda_types::{ChannelUrl, PackageName, Platform, VersionWithSource};
1414
use serde::{Deserialize, Serialize};
1515

1616
pub const METHOD_NAME: &str = "conda/build_v1";
@@ -19,6 +19,13 @@ pub const METHOD_NAME: &str = "conda/build_v1";
1919
#[derive(Debug, Serialize, Deserialize, Clone)]
2020
#[serde(rename_all = "camelCase")]
2121
pub struct CondaBuildV1Params {
22+
/// The canonical channel URLs that define where dependencies will be
23+
/// fetched from. Although this information is not immediately useful for
24+
/// the backend, the backend may choose to generate a different recipe based
25+
/// on the channels.
26+
#[serde(default)]
27+
pub channels: Vec<ChannelUrl>,
28+
2229
/// The path to the build prefix, or `None` if no build prefix is created.
2330
pub build_prefix: Option<CondaBuildV1Prefix>,
2431

crates/pixi_build_types/src/procedures/conda_outputs.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::{
1212
};
1313

1414
use ordermap::OrderSet;
15-
use rattler_conda_types::{NoArchType, PackageName, Platform, VersionWithSource};
15+
use rattler_conda_types::{ChannelUrl, NoArchType, PackageName, Platform, VersionWithSource};
1616
use serde::{Deserialize, Serialize};
1717
use serde_with::serde_as;
1818

@@ -27,6 +27,13 @@ pub const METHOD_NAME: &str = "conda/outputs";
2727
#[derive(Debug, Serialize, Deserialize, Clone)]
2828
#[serde(rename_all = "camelCase")]
2929
pub struct CondaOutputsParams {
30+
/// The canonical channel URLs that define where dependencies will be
31+
/// fetched from. Although this information is not immediately useful for
32+
/// the backend, the backend may choose to generate a different recipe based
33+
/// on the channels.
34+
#[serde(default)]
35+
pub channels: Vec<ChannelUrl>,
36+
3037
/// The native platform for which the outputs should be computed.
3138
///
3239
/// This is usually the same platform as the platform on which the backend

crates/pixi_command_dispatcher/src/backend_source_build/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ pub struct BackendSourceBuildSpec {
4848
/// The method to use for building the source package.
4949
pub method: BackendSourceBuildMethod,
5050

51+
/// The channels to use for solving.
52+
pub channels: Vec<ChannelUrl>,
53+
5154
/// The working directory to use for the build.
5255
pub work_directory: PathBuf,
5356
}
@@ -63,9 +66,6 @@ pub struct BackendSourceBuildV0Method {
6366
/// The channel configuration to use when resolving metadata
6467
pub channel_config: ChannelConfig,
6568

66-
/// The channels to use for solving.
67-
pub channels: Vec<ChannelUrl>,
68-
6969
/// Information about the platform to install build tools for and the
7070
/// platform to target.
7171
pub build_environment: BuildEnvironment,
@@ -140,6 +140,7 @@ impl BackendSourceBuildSpec {
140140
self.source,
141141
params,
142142
self.work_directory,
143+
self.channels,
143144
log_sink,
144145
)
145146
.await
@@ -150,6 +151,7 @@ impl BackendSourceBuildSpec {
150151
self.package,
151152
params,
152153
self.work_directory,
154+
self.channels,
153155
log_sink,
154156
)
155157
.await
@@ -163,6 +165,7 @@ impl BackendSourceBuildSpec {
163165
source: PinnedSourceSpec,
164166
params: BackendSourceBuildV0Method,
165167
work_directory: PathBuf,
168+
channels: Vec<ChannelUrl>,
166169
mut log_sink: UnboundedSender<String>,
167170
) -> Result<BackendBuiltSource, CommandDispatcherError<BackendSourceBuildError>> {
168171
// Use the backend to build the source package.
@@ -172,7 +175,7 @@ impl BackendSourceBuildSpec {
172175
build_platform_virtual_packages: Some(
173176
params.build_environment.build_virtual_packages,
174177
),
175-
channel_base_urls: Some(params.channels.into_iter().map(Into::into).collect()),
178+
channel_base_urls: Some(channels.into_iter().map(Into::into).collect()),
176179
channel_configuration: ChannelConfiguration {
177180
base_url: params.channel_config.channel_alias.clone(),
178181
},
@@ -262,11 +265,13 @@ impl BackendSourceBuildSpec {
262265
record: PackageIdentifier,
263266
params: BackendSourceBuildV1Method,
264267
work_directory: PathBuf,
268+
channels: Vec<ChannelUrl>,
265269
mut log_sink: UnboundedSender<String>,
266270
) -> Result<BackendBuiltSource, CommandDispatcherError<BackendSourceBuildError>> {
267271
let built_package = backend
268272
.conda_build_v1(
269273
CondaBuildV1Params {
274+
channels,
270275
build_prefix: Some(CondaBuildV1Prefix {
271276
prefix: params.build_prefix.prefix,
272277
platform: params.build_prefix.platform,

crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ impl BuildBackendMetadataSpec {
230230
project_model_hash: Option<Vec<u8>>,
231231
) -> Result<CachedCondaMetadata, CommandDispatcherError<BuildBackendMetadataError>> {
232232
let params = CondaOutputsParams {
233+
channels: self.channels,
233234
host_platform: self.build_environment.host_platform,
234235
build_platform: self.build_environment.build_platform,
235236
variant_configuration: self.variants.map(|variants| variants.into_iter().collect()),

crates/pixi_command_dispatcher/src/source_build/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ impl SourceBuildSpec {
306306
method: BackendSourceBuildMethod::BuildV0(BackendSourceBuildV0Method {
307307
editable: self.editable(),
308308
channel_config: self.channel_config,
309-
channels: self.channels,
310309
build_environment: self.build_environment,
311310
variants: self.variants,
312311
output_directory: self.output_directory,
@@ -315,6 +314,7 @@ impl SourceBuildSpec {
315314
package: self.package,
316315
source: self.source,
317316
work_directory,
317+
channels: self.channels,
318318
})
319319
.await
320320
.map_err_with(SourceBuildError::from)?;
@@ -347,6 +347,7 @@ impl SourceBuildSpec {
347347
build_platform,
348348
variant_configuration: self.variants.clone(),
349349
work_directory: work_directory.clone(),
350+
channels: self.channels.clone(),
350351
})
351352
.await
352353
.map_err(BackendSourceBuildError::BuildError)
@@ -497,6 +498,7 @@ impl SourceBuildSpec {
497498
package: self.package,
498499
source: self.source,
499500
work_directory,
501+
channels: self.channels,
500502
})
501503
.await
502504
.map_err_with(SourceBuildError::from)?;

0 commit comments

Comments
 (0)