Share workspace cache between lock and sync operations (#14321)

## Summary

Closes #14316.
This commit is contained in:
Charlie Marsh 2025-06-27 14:48:40 -04:00 committed by GitHub
parent 4eef79e5e8
commit 6a5d2f1ec4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 29 additions and 7 deletions

View file

@ -853,6 +853,7 @@ async fn lock_and_sync(
Box::new(DefaultResolveLogger),
concurrency,
cache,
&WorkspaceCache::default(),
printer,
preview,
)
@ -974,6 +975,7 @@ async fn lock_and_sync(
Box::new(SummaryResolveLogger),
concurrency,
cache,
&WorkspaceCache::default(),
printer,
preview,
)
@ -1021,6 +1023,7 @@ async fn lock_and_sync(
installer_metadata,
concurrency,
cache,
WorkspaceCache::default(),
DryRun::Disabled,
printer,
preview,

View file

@ -193,6 +193,7 @@ pub(crate) async fn export(
Box::new(DefaultResolveLogger),
concurrency,
cache,
&workspace_cache,
printer,
preview,
)

View file

@ -199,6 +199,7 @@ pub(crate) async fn lock(
Box::new(DefaultResolveLogger),
concurrency,
cache,
&workspace_cache,
printer,
preview,
)
@ -263,6 +264,7 @@ pub(super) struct LockOperation<'env> {
logger: Box<dyn ResolveLogger>,
concurrency: Concurrency,
cache: &'env Cache,
workspace_cache: &'env WorkspaceCache,
printer: Printer,
preview: PreviewMode,
}
@ -277,6 +279,7 @@ impl<'env> LockOperation<'env> {
logger: Box<dyn ResolveLogger>,
concurrency: Concurrency,
cache: &'env Cache,
workspace_cache: &'env WorkspaceCache,
printer: Printer,
preview: PreviewMode,
) -> Self {
@ -289,6 +292,7 @@ impl<'env> LockOperation<'env> {
logger,
concurrency,
cache,
workspace_cache,
printer,
preview,
}
@ -334,6 +338,7 @@ impl<'env> LockOperation<'env> {
self.logger,
self.concurrency,
self.cache,
self.workspace_cache,
self.printer,
self.preview,
)
@ -372,6 +377,7 @@ impl<'env> LockOperation<'env> {
self.logger,
self.concurrency,
self.cache,
self.workspace_cache,
self.printer,
self.preview,
)
@ -402,6 +408,7 @@ async fn do_lock(
logger: Box<dyn ResolveLogger>,
concurrency: Concurrency,
cache: &Cache,
workspace_cache: &WorkspaceCache,
printer: Printer,
preview: PreviewMode,
) -> Result<LockResult, ProjectError> {
@ -654,8 +661,6 @@ async fn do_lock(
FlatIndex::from_entries(entries, None, &hasher, build_options)
};
let workspace_cache = WorkspaceCache::default();
// Create a build dispatch.
let build_dispatch = BuildDispatch::new(
&client,
@ -674,7 +679,7 @@ async fn do_lock(
&build_hasher,
*exclude_newer,
*sources,
workspace_cache,
workspace_cache.clone(),
concurrency,
preview,
);

View file

@ -302,6 +302,7 @@ pub(crate) async fn remove(
Box::new(DefaultResolveLogger),
concurrency,
cache,
&WorkspaceCache::default(),
printer,
preview,
)
@ -357,6 +358,7 @@ pub(crate) async fn remove(
installer_metadata,
concurrency,
cache,
WorkspaceCache::default(),
DryRun::Disabled,
printer,
preview,

View file

@ -264,6 +264,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
},
concurrency,
cache,
&workspace_cache,
printer,
preview,
)
@ -309,6 +310,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
installer_metadata,
concurrency,
cache,
workspace_cache.clone(),
DryRun::Disabled,
printer,
preview,
@ -407,7 +409,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
installer_metadata,
concurrency,
cache,
workspace_cache,
workspace_cache.clone(),
DryRun::Disabled,
printer,
preview,
@ -465,7 +467,6 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
};
// Discover and sync the base environment.
let workspace_cache = WorkspaceCache::default();
let temp_dir;
let base_interpreter = if let Some(script_interpreter) = script_interpreter {
// If we found a PEP 723 script and the user provided a project-only setting, warn.
@ -721,6 +722,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
},
concurrency,
cache,
&workspace_cache,
printer,
preview,
)
@ -807,6 +809,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
installer_metadata,
concurrency,
cache,
workspace_cache.clone(),
DryRun::Disabled,
printer,
preview,

View file

@ -324,7 +324,7 @@ pub(crate) async fn sync(
installer_metadata,
concurrency,
cache,
workspace_cache,
workspace_cache.clone(),
dry_run,
printer,
preview,
@ -371,6 +371,7 @@ pub(crate) async fn sync(
Box::new(DefaultResolveLogger),
concurrency,
cache,
&workspace_cache,
printer,
preview,
)
@ -452,6 +453,7 @@ pub(crate) async fn sync(
installer_metadata,
concurrency,
cache,
workspace_cache,
dry_run,
printer,
preview,
@ -587,6 +589,7 @@ pub(super) async fn do_sync(
installer_metadata: bool,
concurrency: Concurrency,
cache: &Cache,
workspace_cache: WorkspaceCache,
dry_run: DryRun,
printer: Printer,
preview: PreviewMode,
@ -748,7 +751,7 @@ pub(super) async fn do_sync(
&build_hasher,
exclude_newer,
sources,
WorkspaceCache::default(),
workspace_cache.clone(),
concurrency,
preview,
);

View file

@ -146,6 +146,7 @@ pub(crate) async fn tree(
Box::new(DefaultResolveLogger),
concurrency,
cache,
&WorkspaceCache::default(),
printer,
preview,
)

View file

@ -315,6 +315,7 @@ async fn print_frozen_version(
Box::new(DefaultResolveLogger),
concurrency,
cache,
&WorkspaceCache::default(),
printer,
preview,
)
@ -443,6 +444,7 @@ async fn lock_and_sync(
// Initialize any shared state.
let state = UniversalState::default();
let workspace_cache = WorkspaceCache::default();
// Lock and sync the environment, if necessary.
let lock = match project::lock::LockOperation::new(
@ -453,6 +455,7 @@ async fn lock_and_sync(
Box::new(DefaultResolveLogger),
concurrency,
cache,
&workspace_cache,
printer,
preview,
)
@ -510,6 +513,7 @@ async fn lock_and_sync(
installer_metadata,
concurrency,
cache,
workspace_cache,
DryRun::Disabled,
printer,
preview,