Avoid resetting dispatch and in-flight state with reinstalls (#4771)

## Summary

This used to be necessary because we purged the cache in the
`InstallPlan` if the user passed `--reinstall`. _However_, we later
changed the cache to be append-only.

## Test Plan

I ran through the test plan in https://github.com/astral-sh/uv/pull/933,
which includes an integration test and running `uv pip install
--reinstall` with:

```text
setuptools
devpi @ e334eb4dc9/devpi-2.2.0.tar.gz
```
This commit is contained in:
Charlie Marsh 2024-07-03 10:31:51 -04:00 committed by GitHub
parent dcdf26eead
commit b6575fe487
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 98 deletions

View file

@ -291,8 +291,8 @@ pub(crate) async fn pip_install(
// Track in-flight downloads, builds, etc., across resolutions. // Track in-flight downloads, builds, etc., across resolutions.
let in_flight = InFlight::default(); let in_flight = InFlight::default();
// Create a build dispatch for resolution. // Create a build dispatch.
let resolve_dispatch = BuildDispatch::new( let build_dispatch = BuildDispatch::new(
&client, &client,
&cache, &cache,
interpreter, interpreter,
@ -340,7 +340,7 @@ pub(crate) async fn pip_install(
&client, &client,
&flat_index, &flat_index,
&index, &index,
&resolve_dispatch, &build_dispatch,
concurrency, concurrency,
options, options,
printer, printer,
@ -358,35 +358,6 @@ pub(crate) async fn pip_install(
Err(err) => return Err(err.into()), Err(err) => return Err(err.into()),
}; };
// Re-initialize the in-flight map.
let in_flight = InFlight::default();
// If we're running with `--reinstall`, initialize a separate `BuildDispatch`, since we may
// end up removing some distributions from the environment.
let install_dispatch = if reinstall.is_none() {
resolve_dispatch
} else {
BuildDispatch::new(
&client,
&cache,
interpreter,
&index_locations,
&flat_index,
&index,
&git,
&in_flight,
index_strategy,
setup_py,
config_settings,
build_isolation,
link_mode,
&build_options,
exclude_newer,
concurrency,
preview,
)
};
// Sync the environment. // Sync the environment.
operations::install( operations::install(
&resolution, &resolution,
@ -402,7 +373,7 @@ pub(crate) async fn pip_install(
&client, &client,
&in_flight, &in_flight,
concurrency, concurrency,
&install_dispatch, &build_dispatch,
&cache, &cache,
&environment, &environment,
dry_run, dry_run,

View file

@ -244,8 +244,8 @@ pub(crate) async fn pip_sync(
// Ignore development dependencies. // Ignore development dependencies.
let dev = Vec::default(); let dev = Vec::default();
// Create a build dispatch for resolution. // Create a build dispatch.
let resolve_dispatch = BuildDispatch::new( let build_dispatch = BuildDispatch::new(
&client, &client,
&cache, &cache,
interpreter, interpreter,
@ -295,7 +295,7 @@ pub(crate) async fn pip_sync(
&client, &client,
&flat_index, &flat_index,
&index, &index,
&resolve_dispatch, &build_dispatch,
concurrency, concurrency,
options, options,
printer, printer,
@ -313,35 +313,6 @@ pub(crate) async fn pip_sync(
Err(err) => return Err(err.into()), Err(err) => return Err(err.into()),
}; };
// Re-initialize the in-flight map.
let in_flight = InFlight::default();
// If we're running with `--reinstall`, initialize a separate `BuildDispatch`, since we may
// end up removing some distributions from the environment.
let install_dispatch = if reinstall.is_none() {
resolve_dispatch
} else {
BuildDispatch::new(
&client,
&cache,
interpreter,
&index_locations,
&flat_index,
&index,
&git,
&in_flight,
index_strategy,
setup_py,
config_settings,
build_isolation,
link_mode,
&build_options,
exclude_newer,
concurrency,
preview,
)
};
// Sync the environment. // Sync the environment.
operations::install( operations::install(
&resolution, &resolution,
@ -357,7 +328,7 @@ pub(crate) async fn pip_sync(
&client, &client,
&in_flight, &in_flight,
concurrency, concurrency,
&install_dispatch, &build_dispatch,
&cache, &cache,
&environment, &environment,
dry_run, dry_run,

View file

@ -469,7 +469,7 @@ pub(crate) async fn update_environment(
}; };
// Create a build dispatch. // Create a build dispatch.
let resolve_dispatch = BuildDispatch::new( let build_dispatch = BuildDispatch::new(
&client, &client,
cache, cache,
interpreter, interpreter,
@ -509,7 +509,7 @@ pub(crate) async fn update_environment(
&client, &client,
&flat_index, &flat_index,
&state.index, &state.index,
&resolve_dispatch, &build_dispatch,
concurrency, concurrency,
options, options,
printer, printer,
@ -521,35 +521,6 @@ pub(crate) async fn update_environment(
Err(err) => return Err(err.into()), Err(err) => return Err(err.into()),
}; };
// Re-initialize the in-flight map.
let in_flight = InFlight::default();
// If we're running with `--reinstall`, initialize a separate `BuildDispatch`, since we may
// end up removing some distributions from the environment.
let install_dispatch = if reinstall.is_none() {
resolve_dispatch
} else {
BuildDispatch::new(
&client,
cache,
interpreter,
index_locations,
&flat_index,
&state.index,
&state.git,
&in_flight,
*index_strategy,
setup_py,
config_setting,
build_isolation,
*link_mode,
build_options,
*exclude_newer,
concurrency,
preview,
)
};
// Sync the environment. // Sync the environment.
pip::operations::install( pip::operations::install(
&resolution, &resolution,
@ -565,7 +536,7 @@ pub(crate) async fn update_environment(
&client, &client,
&in_flight, &in_flight,
concurrency, concurrency,
&install_dispatch, &build_dispatch,
cache, cache,
&venv, &venv,
dry_run, dry_run,