@@ -23,6 +23,7 @@ use crate::{
2323 env_vars,
2424 metadata:: { Output , build_reindexed_channels} ,
2525 packaging:: Files ,
26+ post_process:: package_nature:: { CachedPrefixInfo , PrefixInfo } ,
2627 render:: resolved_dependencies:: {
2728 FinalizedDependencies , RunExportsDownload , install_environments, resolve_dependencies,
2829 } ,
@@ -72,6 +73,13 @@ pub struct StagingCacheMetadata {
7273
7374 /// The variant configuration that was used
7475 pub variant : BTreeMap < NormalizedKey , Variable > ,
76+
77+ /// Cached prefix info (path-to-package and package nature mappings)
78+ /// from the host environment at staging cache build time.
79+ /// This allows linking checks to attribute shared libraries to their
80+ /// providing packages without needing the conda-meta records installed.
81+ #[ serde( default ) ]
82+ pub cached_prefix_info : CachedPrefixInfo ,
7583}
7684
7785impl Output {
@@ -142,7 +150,7 @@ impl Output {
142150 /// 2. If yes, restore the cached files to the prefix
143151 /// 3. If no, build the staging cache and save it
144152 ///
145- /// Returns the finalized dependencies and sources from the staging cache
153+ /// Returns the finalized dependencies, sources, and cached prefix info
146154 pub async fn build_or_restore_staging_cache (
147155 & self ,
148156 staging : & StagingCache ,
@@ -151,6 +159,7 @@ impl Output {
151159 (
152160 FinalizedDependencies ,
153161 Vec < rattler_build_recipe:: stage1:: Source > ,
162+ CachedPrefixInfo ,
154163 ) ,
155164 miette:: Error ,
156165 > {
@@ -217,6 +226,7 @@ impl Output {
217226 (
218227 FinalizedDependencies ,
219228 Vec < rattler_build_recipe:: stage1:: Source > ,
229+ CachedPrefixInfo ,
220230 ) ,
221231 miette:: Error ,
222232 > {
@@ -368,6 +378,12 @@ impl Output {
368378 . run ( )
369379 . into_diagnostic ( ) ?;
370380
381+ // Capture prefix info (path-to-package and package nature mappings)
382+ // from the host environment while conda-meta records are still present.
383+ // This data is needed by linking checks in inheriting outputs.
384+ let prefix_info = PrefixInfo :: from_prefix ( self . prefix ( ) ) . into_diagnostic ( ) ?;
385+ let cached_prefix_info = CachedPrefixInfo :: from_prefix_info ( & prefix_info) ;
386+
371387 // Save metadata
372388 let metadata = StagingCacheMetadata {
373389 name : staging. name . clone ( ) ,
@@ -377,6 +393,7 @@ impl Output {
377393 work_dir_files : copied_work_dir. copied_paths ( ) . to_vec ( ) ,
378394 prefix : self . prefix ( ) . to_path_buf ( ) ,
379395 variant : staging. used_variant . clone ( ) ,
396+ cached_prefix_info,
380397 } ;
381398
382399 let metadata_json = serde_json:: to_string_pretty ( & metadata) . into_diagnostic ( ) ?;
@@ -388,7 +405,11 @@ impl Output {
388405 metadata. work_dir_files. len( )
389406 ) ;
390407
391- Ok ( ( finalized_dependencies, finalized_sources) )
408+ Ok ( (
409+ finalized_dependencies,
410+ finalized_sources,
411+ metadata. cached_prefix_info ,
412+ ) )
392413 }
393414
394415 /// Restore a staging cache from disk
@@ -400,6 +421,7 @@ impl Output {
400421 (
401422 FinalizedDependencies ,
402423 Vec < rattler_build_recipe:: stage1:: Source > ,
424+ CachedPrefixInfo ,
403425 ) ,
404426 miette:: Error ,
405427 > {
@@ -439,7 +461,11 @@ impl Output {
439461 metadata. name
440462 ) ;
441463
442- Ok ( ( metadata. finalized_dependencies , metadata. finalized_sources ) )
464+ Ok ( (
465+ metadata. finalized_dependencies ,
466+ metadata. finalized_sources ,
467+ metadata. cached_prefix_info ,
468+ ) )
443469 }
444470
445471 /// Process all staging caches for this output
@@ -454,6 +480,7 @@ impl Output {
454480 Option < (
455481 FinalizedDependencies ,
456482 Vec < rattler_build_recipe:: stage1:: Source > ,
483+ CachedPrefixInfo ,
457484 ) > ,
458485 miette:: Error ,
459486 > {
@@ -470,7 +497,7 @@ impl Output {
470497 "Building or restoring staging cache: {}" ,
471498 staging_cache. name
472499 ) ;
473- let ( _deps, _sources) = self
500+ let ( _deps, _sources, _prefix_info ) = self
474501 . build_or_restore_staging_cache ( staging_cache, tool_configuration)
475502 . await ?;
476503 }
@@ -491,11 +518,11 @@ impl Output {
491518 } ) ?;
492519
493520 // Get or build the cache
494- let ( deps, sources) = self
521+ let ( deps, sources, cached_prefix_info ) = self
495522 . build_or_restore_staging_cache ( staging, tool_configuration)
496523 . await ?;
497524
498- Ok ( Some ( ( deps, sources) ) )
525+ Ok ( Some ( ( deps, sources, cached_prefix_info ) ) )
499526 } else {
500527 Ok ( None )
501528 }
0 commit comments