@@ -44,6 +44,7 @@ use pypi_modifiers::pypi_marker_env::determine_marker_environment;
4444use rattler:: package_cache:: PackageCache ;
4545use rattler_conda_types:: { Arch , GenericVirtualPackage , PackageName , Platform } ;
4646use rattler_lock:: { LockFile , LockedPackageRef , ParseCondaLockError } ;
47+ use std:: collections:: hash_map:: Entry ;
4748use std:: {
4849 cmp:: PartialEq ,
4950 collections:: { HashMap , HashSet } ,
@@ -1345,6 +1346,7 @@ impl<'p> UpdateContext<'p> {
13451346
13461347 // Spawn tasks to update the pypi packages.
13471348 let uv_context = once_cell:: sync:: OnceCell :: new ( ) ;
1349+ let mut pypi_conda_prefix_updaters = HashMap :: new ( ) ;
13481350 for ( environment, platform) in
13491351 self . outdated_envs
13501352 . pypi
@@ -1388,19 +1390,26 @@ impl<'p> UpdateContext<'p> {
13881390 . get_latest_group_repodata_records ( & group, environment. best_platform ( ) )
13891391 . ok_or_else ( || make_unsupported_pypi_platform_error ( environment, false ) ) ;
13901392
1391- // Creates an object to initiate an update at a later point
1392- let prefix_platform = environment. best_platform ( ) ;
1393- let conda_prefix_updater = CondaPrefixUpdater :: builder (
1394- group. clone ( ) ,
1395- prefix_platform,
1396- environment
1397- . virtual_packages ( prefix_platform)
1398- . into_iter ( )
1399- . map ( GenericVirtualPackage :: from)
1400- . collect ( ) ,
1401- self . command_dispatcher . clone ( ) ,
1402- )
1403- . finish ( ) ?;
1393+ // Creates an object to initiate an update at a later point. Make sure to only create a single entry if we are solving for multiple platforms.
1394+ let conda_prefix_updater =
1395+ match pypi_conda_prefix_updaters. entry ( environment. name ( ) . clone ( ) ) {
1396+ Entry :: Vacant ( entry) => {
1397+ let prefix_platform = environment. best_platform ( ) ;
1398+ let conda_prefix_updater = CondaPrefixUpdater :: builder (
1399+ group. clone ( ) ,
1400+ prefix_platform,
1401+ environment
1402+ . virtual_packages ( prefix_platform)
1403+ . into_iter ( )
1404+ . map ( GenericVirtualPackage :: from)
1405+ . collect ( ) ,
1406+ self . command_dispatcher . clone ( ) ,
1407+ )
1408+ . finish ( ) ?;
1409+ entry. insert ( conda_prefix_updater) . clone ( )
1410+ }
1411+ Entry :: Occupied ( entry) => entry. get ( ) . clone ( ) ,
1412+ } ;
14041413
14051414 let uv_context = uv_context
14061415 . get_or_try_init ( || UvResolutionContext :: from_workspace ( project) ) ?
0 commit comments