@@ -102,7 +102,7 @@ impl ExpandDevSourcesSpec {
102102 )
103103 ) ]
104104 pub ( crate ) async fn request (
105- self ,
105+ mut self ,
106106 command_dispatcher : CommandDispatcher ,
107107 ) -> Result < ExpandedDevSources , CommandDispatcherError < ExpandDevSourcesError > > {
108108 // Create a lookup set for dev_sources by output_name
@@ -117,136 +117,123 @@ impl ExpandDevSourcesSpec {
117117
118118 // Process each dev_source concurrently
119119 let mut futures = ExecutorFutures :: new ( command_dispatcher. executor ( ) ) ;
120-
121- for dev_source in self . dev_sources {
122- futures. push ( process_single_dev_source (
120+ for dev_source in std:: mem:: take ( & mut self . dev_sources ) {
121+ futures. push ( self . process_single_dev_source (
123122 dev_source,
124123 & command_dispatcher,
125- & self . channel_config ,
126- & self . channels ,
127- & self . build_environment ,
128- & self . variants ,
129- & self . enabled_protocols ,
130124 & dev_source_names,
131125 ) ) ;
132126 }
133127
134128 // Collect results as they complete
135129 let mut result = ExpandedDevSources :: default ( ) ;
136- while let Some ( dev_source_result ) = futures. next ( ) . await {
137- let ( dependencies , constraints ) = dev_source_result ?;
130+ while let Some ( expanded ) = futures. next ( ) . await {
131+ let expanded = expanded ?;
138132
139133 // Merge dependencies and constraints into the result
140- for ( name, spec) in dependencies. into_specs ( ) {
134+ for ( name, spec) in expanded . dependencies . into_specs ( ) {
141135 result. dependencies . insert ( name, spec) ;
142136 }
143- for ( name, spec) in constraints. into_specs ( ) {
137+ for ( name, spec) in expanded . constraints . into_specs ( ) {
144138 result. constraints . insert ( name, spec) ;
145139 }
146140 }
147141
148142 Ok ( result)
149143 }
150- }
151144
152- /// Process a single dev_source: checkout, get dependencies, and filter/resolve them.
153- async fn process_single_dev_source (
154- dev_source : DependencyOnlySource ,
155- command_dispatcher : & CommandDispatcher ,
156- channel_config : & ChannelConfig ,
157- channels : & [ ChannelUrl ] ,
158- build_environment : & BuildEnvironment ,
159- variants : & Option < BTreeMap < String , Vec < String > > > ,
160- enabled_protocols : & EnabledProtocols ,
161- dev_source_names : & HashSet < PackageName > ,
162- ) -> Result <
163- (
164- DependencyMap < PackageName , PixiSpec > ,
165- DependencyMap < PackageName , BinarySpec > ,
166- ) ,
167- CommandDispatcherError < ExpandDevSourcesError > ,
168- > {
169- // Pin and checkout the source
170- let pinned_source = command_dispatcher
171- . pin_and_checkout ( dev_source. source . clone ( ) )
172- . await
173- . map_err_with ( |error| ExpandDevSourcesError :: SourceCheckout {
174- name : dev_source. output_name . as_source ( ) . to_string ( ) ,
175- error,
176- } ) ?;
177-
178- // Create a SourceAnchor for resolving relative paths in dependencies
179- let source_anchor = SourceAnchor :: from ( SourceSpec :: from ( pinned_source. pinned . clone ( ) ) ) ;
180-
181- // Get the output dependencies
182- let spec = GetOutputDependenciesSpec {
183- source : pinned_source. pinned ,
184- output_name : dev_source. output_name . clone ( ) ,
185- channel_config : channel_config. clone ( ) ,
186- channels : channels. to_vec ( ) ,
187- build_environment : build_environment. clone ( ) ,
188- variants : variants. clone ( ) ,
189- enabled_protocols : enabled_protocols. clone ( ) ,
190- } ;
191-
192- let output_deps = command_dispatcher
193- . get_output_dependencies ( spec)
194- . await
195- . map_err_with ( |error| ExpandDevSourcesError :: GetOutputDependencies {
196- name : dev_source. output_name . clone ( ) ,
197- error,
198- } ) ?;
199-
200- // Process dependencies
201- let mut dependencies = DependencyMap :: default ( ) ;
202- let process_deps =
203- |deps : Option < DependencyMap < PackageName , PixiSpec > > ,
204- dependencies : & mut DependencyMap < PackageName , PixiSpec > | {
205- if let Some ( deps) = deps {
206- for ( name, spec) in deps. into_specs ( ) {
207- // Skip dependencies that are also dev_sources
208- // TODO: Currently matching by name only. In the future, we might want to
209- // also check if the source location matches for more precise matching.
210- if dev_source_names. contains ( & name) {
211- continue ;
212- }
145+ /// Process a single dev_source: checkout, get dependencies, and filter/resolve them.
146+ async fn process_single_dev_source (
147+ & self ,
148+ dev_source : DependencyOnlySource ,
149+ command_dispatcher : & CommandDispatcher ,
150+ dev_source_names : & HashSet < PackageName > ,
151+ ) -> Result < ExpandedDevSources , CommandDispatcherError < ExpandDevSourcesError > > {
152+ // Pin and checkout the source
153+ let pinned_source = command_dispatcher
154+ . pin_and_checkout ( dev_source. source . clone ( ) )
155+ . await
156+ . map_err_with ( |error| ExpandDevSourcesError :: SourceCheckout {
157+ name : dev_source. output_name . as_source ( ) . to_string ( ) ,
158+ error,
159+ } ) ?;
160+
161+ // Create a SourceAnchor for resolving relative paths in dependencies
162+ let source_anchor = SourceAnchor :: from ( SourceSpec :: from ( pinned_source. pinned . clone ( ) ) ) ;
163+
164+ // Get the output dependencies
165+ let spec = GetOutputDependenciesSpec {
166+ source : pinned_source. pinned ,
167+ output_name : dev_source. output_name . clone ( ) ,
168+ channel_config : self . channel_config . clone ( ) ,
169+ channels : self . channels . clone ( ) ,
170+ build_environment : self . build_environment . clone ( ) ,
171+ variants : self . variants . clone ( ) ,
172+ enabled_protocols : self . enabled_protocols . clone ( ) ,
173+ } ;
213174
214- // Resolve relative paths for source dependencies
215- let resolved_spec = match spec. into_source_or_binary ( ) {
216- Either :: Left ( source) => {
217- // Resolve the source relative to the dev_source's location
218- PixiSpec :: from ( source_anchor. resolve ( source) )
175+ let output_deps = command_dispatcher
176+ . get_output_dependencies ( spec)
177+ . await
178+ . map_err_with ( |error| ExpandDevSourcesError :: GetOutputDependencies {
179+ name : dev_source. output_name . clone ( ) ,
180+ error,
181+ } ) ?;
182+
183+ // Process dependencies
184+ let mut dependencies = DependencyMap :: default ( ) ;
185+ let process_deps =
186+ |deps : Option < DependencyMap < PackageName , PixiSpec > > ,
187+ dependencies : & mut DependencyMap < PackageName , PixiSpec > | {
188+ if let Some ( deps) = deps {
189+ for ( name, spec) in deps. into_specs ( ) {
190+ // Skip dependencies that are also dev_sources
191+ // TODO: Currently matching by name only. In the future, we might want to
192+ // also check if the source location matches for more precise matching.
193+ if dev_source_names. contains ( & name) {
194+ continue ;
219195 }
220- Either :: Right ( binary) => {
221- // Binary specs don't need path resolution
222- PixiSpec :: from ( binary)
223- }
224- } ;
225- dependencies. insert ( name, resolved_spec) ;
196+
197+ // Resolve relative paths for source dependencies
198+ let resolved_spec = match spec. into_source_or_binary ( ) {
199+ Either :: Left ( source) => {
200+ // Resolve the source relative to the dev_source's location
201+ PixiSpec :: from ( source_anchor. resolve ( source) )
202+ }
203+ Either :: Right ( binary) => {
204+ // Binary specs don't need path resolution
205+ PixiSpec :: from ( binary)
206+ }
207+ } ;
208+ dependencies. insert ( name, resolved_spec) ;
209+ }
226210 }
211+ } ;
212+
213+ // Process all dependency types
214+ process_deps ( output_deps. build_dependencies , & mut dependencies) ;
215+ process_deps ( output_deps. host_dependencies , & mut dependencies) ;
216+ process_deps ( Some ( output_deps. run_dependencies ) , & mut dependencies) ;
217+
218+ // Collect constraints
219+ let mut constraints = DependencyMap :: default ( ) ;
220+ if let Some ( build_constraints) = output_deps. build_constraints {
221+ for ( name, spec) in build_constraints. into_specs ( ) {
222+ constraints. insert ( name, spec) ;
227223 }
228- } ;
229-
230- // Process all dependency types
231- process_deps ( output_deps. build_dependencies , & mut dependencies) ;
232- process_deps ( output_deps. host_dependencies , & mut dependencies) ;
233- process_deps ( Some ( output_deps. run_dependencies ) , & mut dependencies) ;
234-
235- // Collect constraints
236- let mut constraints = DependencyMap :: default ( ) ;
237- if let Some ( build_constraints) = output_deps. build_constraints {
238- for ( name, spec) in build_constraints. into_specs ( ) {
239- constraints. insert ( name, spec) ;
240224 }
241- }
242- if let Some ( host_constraints) = output_deps. host_constraints {
243- for ( name, spec) in host_constraints. into_specs ( ) {
225+ if let Some ( host_constraints) = output_deps. host_constraints {
226+ for ( name, spec) in host_constraints. into_specs ( ) {
227+ constraints. insert ( name, spec) ;
228+ }
229+ }
230+ for ( name, spec) in output_deps. run_constraints . into_specs ( ) {
244231 constraints. insert ( name, spec) ;
245232 }
246- }
247- for ( name, spec) in output_deps. run_constraints . into_specs ( ) {
248- constraints. insert ( name, spec) ;
249- }
250233
251- Ok ( ( dependencies, constraints) )
234+ Ok ( ExpandedDevSources {
235+ dependencies,
236+ constraints,
237+ } )
238+ }
252239}
0 commit comments