@@ -20,12 +20,12 @@ use pixi_build_types::{
20
20
} ,
21
21
} ,
22
22
} ;
23
- use pixi_record:: SourceRecord ;
23
+ use pixi_record:: PinnedSourceSpec ;
24
24
use rattler_conda_types:: { ChannelConfig , ChannelUrl , Platform , Version } ;
25
25
use serde:: Serialize ;
26
26
use thiserror:: Error ;
27
27
28
- use crate :: { BuildEnvironment , CommandDispatcher , CommandDispatcherError , build :: WorkDirKey } ;
28
+ use crate :: { BuildEnvironment , CommandDispatcherError , PackageIdentifier } ;
29
29
30
30
/// The `BackendSourceBuildSpec` struct is used to define the specifications for
31
31
/// building a source package using a pre-instantiated backend. This task
@@ -40,10 +40,16 @@ pub struct BackendSourceBuildSpec {
40
40
pub backend : Backend ,
41
41
42
42
/// The package that we are building.
43
- pub record : SourceRecord ,
43
+ pub package : PackageIdentifier ,
44
+
45
+ /// The source location of the package that we are building.
46
+ pub source : PinnedSourceSpec ,
44
47
45
48
/// The method to use for building the source package.
46
49
pub method : BackendSourceBuildMethod ,
50
+
51
+ /// The working directory to use for the build.
52
+ pub work_directory : PathBuf ,
47
53
}
48
54
49
55
#[ derive( Debug , Serialize ) ]
@@ -115,27 +121,28 @@ pub struct BackendBuiltSource {
115
121
impl BackendSourceBuildSpec {
116
122
pub async fn build (
117
123
self ,
118
- command_dispatcher : CommandDispatcher ,
119
124
log_sink : UnboundedSender < String > ,
120
125
) -> Result < BackendBuiltSource , CommandDispatcherError < BackendSourceBuildError > > {
121
126
match self . method {
122
127
BackendSourceBuildMethod :: BuildV0 ( params) => {
123
128
Self :: build_v0 (
124
129
self . backend ,
125
- self . record ,
130
+ self . package ,
131
+ self . source ,
126
132
params,
133
+ self . work_directory ,
127
134
log_sink,
128
- command_dispatcher,
129
135
)
130
136
. await
131
137
}
132
138
BackendSourceBuildMethod :: BuildV1 ( params) => {
133
139
Self :: build_v1 (
134
140
self . backend ,
135
- self . record ,
141
+ self . package ,
142
+ self . source ,
136
143
params,
144
+ self . work_directory ,
137
145
log_sink,
138
- command_dispatcher,
139
146
)
140
147
. await
141
148
}
@@ -144,10 +151,11 @@ impl BackendSourceBuildSpec {
144
151
145
152
async fn build_v0 (
146
153
backend : Backend ,
147
- record : SourceRecord ,
154
+ record : PackageIdentifier ,
155
+ source : PinnedSourceSpec ,
148
156
params : BackendSourceBuildV0Method ,
157
+ work_directory : PathBuf ,
149
158
mut log_sink : UnboundedSender < String > ,
150
- command_dispatcher : CommandDispatcher ,
151
159
) -> Result < BackendBuiltSource , CommandDispatcherError < BackendSourceBuildError > > {
152
160
// Use the backend to build the source package.
153
161
let mut build_result = backend
@@ -161,29 +169,22 @@ impl BackendSourceBuildSpec {
161
169
base_url : params. channel_config . channel_alias . clone ( ) ,
162
170
} ,
163
171
outputs : Some ( BTreeSet :: from_iter ( [ CondaOutputIdentifier {
164
- name : Some ( record. package_record . name . as_normalized ( ) . to_string ( ) ) ,
165
- version : Some ( record. package_record . version . to_string ( ) ) ,
166
- build : Some ( record. package_record . build . clone ( ) ) ,
167
- subdir : Some ( record. package_record . subdir . clone ( ) ) ,
172
+ name : Some ( record. name . as_normalized ( ) . to_string ( ) ) ,
173
+ version : Some ( record. version . to_string ( ) ) ,
174
+ build : Some ( record. build . clone ( ) ) ,
175
+ subdir : Some ( record. subdir . clone ( ) ) ,
168
176
} ] ) ) ,
169
177
variant_configuration : params
170
178
. variants
171
179
. map ( |variants| variants. into_iter ( ) . collect ( ) ) ,
172
- work_directory : command_dispatcher. cache_dirs ( ) . working_dirs ( ) . join (
173
- WorkDirKey {
174
- source : Box :: new ( record. clone ( ) ) . into ( ) ,
175
- host_platform : params. build_environment . host_platform ,
176
- build_backend : backend. identifier ( ) . to_string ( ) ,
177
- }
178
- . key ( ) ,
179
- ) ,
180
+ work_directory,
180
181
host_platform : Some ( PlatformAndVirtualPackages {
181
182
platform : params. build_environment . host_platform ,
182
183
virtual_packages : Some (
183
184
params. build_environment . host_virtual_packages . clone ( ) ,
184
185
) ,
185
186
} ) ,
186
- editable : !record . source . is_immutable ( ) ,
187
+ editable : source. is_mutable ( ) ,
187
188
} ,
188
189
move |line| {
189
190
let _err = futures:: executor:: block_on ( log_sink. send ( line) ) ;
@@ -206,8 +207,8 @@ impl BackendSourceBuildSpec {
206
207
} ) ;
207
208
tracing:: warn!(
208
209
"While building {} for {}, the build backend returned more packages than expected: {pkgs}. Only the package matching the source record will be used." ,
209
- record . source,
210
- record. package_record . subdir,
210
+ source,
211
+ record. subdir,
211
212
) ;
212
213
}
213
214
@@ -221,10 +222,10 @@ impl BackendSourceBuildSpec {
221
222
} else {
222
223
return Err ( CommandDispatcherError :: Failed (
223
224
BackendSourceBuildError :: UnexpectedPackage ( UnexpectedPackageError {
224
- subdir : record. package_record . subdir . clone ( ) ,
225
- name : record. package_record . name . as_normalized ( ) . to_string ( ) ,
226
- version : record. package_record . version . to_string ( ) ,
227
- build : record. package_record . build . clone ( ) ,
225
+ subdir : record. subdir . clone ( ) ,
226
+ name : record. name . as_normalized ( ) . to_string ( ) ,
227
+ version : record. version . to_string ( ) ,
228
+ build : record. build . clone ( ) ,
228
229
packages : build_result
229
230
. packages
230
231
. iter ( )
@@ -250,20 +251,12 @@ impl BackendSourceBuildSpec {
250
251
251
252
async fn build_v1 (
252
253
backend : Backend ,
253
- record : SourceRecord ,
254
+ record : PackageIdentifier ,
255
+ source : PinnedSourceSpec ,
254
256
params : BackendSourceBuildV1Method ,
257
+ work_directory : PathBuf ,
255
258
mut log_sink : UnboundedSender < String > ,
256
- command_dispatcher : CommandDispatcher ,
257
259
) -> Result < BackendBuiltSource , CommandDispatcherError < BackendSourceBuildError > > {
258
- let work_directory = command_dispatcher. cache_dirs ( ) . working_dirs ( ) . join (
259
- WorkDirKey {
260
- source : Box :: new ( record. clone ( ) ) . into ( ) ,
261
- host_platform : params. host_prefix . platform ,
262
- build_backend : backend. identifier ( ) . to_string ( ) ,
263
- }
264
- . key ( ) ,
265
- ) ;
266
-
267
260
let built_package = backend
268
261
. conda_build_v1 (
269
262
CondaBuildV1Params {
@@ -276,19 +269,18 @@ impl BackendSourceBuildSpec {
276
269
platform : params. host_prefix . platform ,
277
270
} ) ,
278
271
output : CondaBuildV1Output {
279
- name : record. package_record . name . clone ( ) ,
280
- version : Some ( record. package_record . version . clone ( ) ) ,
281
- build : Some ( record. package_record . build . clone ( ) ) ,
272
+ name : record. name . clone ( ) ,
273
+ version : Some ( record. version . clone ( ) ) ,
274
+ build : Some ( record. build . clone ( ) ) ,
282
275
subdir : record
283
- . package_record
284
276
. subdir
285
277
. parse ( )
286
278
. expect ( "found a package record with an unparsable subdir" ) ,
287
279
variant : params. variant ,
288
280
} ,
289
281
work_directory,
290
282
output_directory : params. output_directory ,
291
- editable : Some ( !record . source . is_immutable ( ) ) ,
283
+ editable : Some ( source. is_mutable ( ) ) ,
292
284
} ,
293
285
move |line| {
294
286
let _err = futures:: executor:: block_on ( log_sink. send ( line) ) ;
@@ -302,10 +294,10 @@ impl BackendSourceBuildSpec {
302
294
if v1_built_package_matches_requested ( & built_package, & record) {
303
295
return Err ( CommandDispatcherError :: Failed (
304
296
BackendSourceBuildError :: UnexpectedPackage ( UnexpectedPackageError {
305
- subdir : record. package_record . subdir . clone ( ) ,
306
- name : record. package_record . name . as_normalized ( ) . to_string ( ) ,
307
- version : record. package_record . version . to_string ( ) ,
308
- build : record. package_record . build . clone ( ) ,
297
+ subdir : record. subdir . clone ( ) ,
298
+ name : record. name . as_normalized ( ) . to_string ( ) ,
299
+ version : record. version . to_string ( ) ,
300
+ build : record. build . clone ( ) ,
309
301
packages : vec ! [ format!(
310
302
"{}/{}={}={}" ,
311
303
built_package. subdir,
@@ -326,23 +318,23 @@ impl BackendSourceBuildSpec {
326
318
327
319
/// Returns true if the requested package matches the one that was built by a
328
320
/// backend.
329
- fn v0_built_package_matches_request ( record : & SourceRecord , pkg : & & CondaBuiltPackage ) -> bool {
330
- pkg. name == record. package_record . name
331
- && Version :: from_str ( & pkg. version ) . ok ( ) . as_ref ( ) == Some ( & record. package_record . version )
332
- && pkg. build == record. package_record . build
333
- && pkg. subdir == record. package_record . subdir
321
+ fn v0_built_package_matches_request ( record : & PackageIdentifier , pkg : & & CondaBuiltPackage ) -> bool {
322
+ pkg. name == record. name
323
+ && Version :: from_str ( & pkg. version ) . ok ( ) . as_ref ( ) == Some ( & record. version )
324
+ && pkg. build == record. build
325
+ && pkg. subdir == record. subdir
334
326
}
335
327
336
328
/// Returns true if the requested package matches the one that was built by a
337
329
/// backend.
338
330
fn v1_built_package_matches_requested (
339
331
built_package : & CondaBuildV1Result ,
340
- record : & SourceRecord ,
332
+ record : & PackageIdentifier ,
341
333
) -> bool {
342
- built_package. name != record. package_record . name . as_normalized ( )
343
- || built_package. version != record. package_record . version
344
- || built_package. build != record. package_record . build
345
- || built_package. subdir . as_str ( ) != record. package_record . subdir
334
+ built_package. name != record. name . as_normalized ( )
335
+ || built_package. version != record. version
336
+ || built_package. build != record. build
337
+ || built_package. subdir . as_str ( ) != record. subdir
346
338
}
347
339
348
340
#[ derive( Debug , thiserror:: Error , Diagnostic ) ]
0 commit comments