Add Git resolver in lieu of static hash map (#3954)

## Summary

This PR removes the static resolver map:

```rust
static RESOLVED_GIT_REFS: Lazy<Mutex<FxHashMap<RepositoryReference, GitSha>>> =
    Lazy::new(Mutex::default);
```

With a `GitResolver` struct that we now pass around on the
`BuildContext`. There should be no behavior changes here; it's purely an
internal refactor with an eye towards making it cleaner for us to
"pre-populate" the list of resolved SHAs.
This commit is contained in:
Charlie Marsh 2024-05-31 22:44:42 -04:00 committed by GitHub
parent a0652921fc
commit b7d77c04cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 475 additions and 384 deletions

View file

@ -19,6 +19,7 @@ use uv_client::RegistryClient;
use uv_configuration::{BuildKind, ConfigSettings, NoBinary, NoBuild, Reinstall, SetupPyStrategy};
use uv_configuration::{Concurrency, PreviewMode};
use uv_distribution::DistributionDatabase;
use uv_git::GitResolver;
use uv_installer::{Downloader, Installer, Plan, Planner, SitePackages};
use uv_interpreter::{Interpreter, PythonEnvironment};
use uv_resolver::{FlatIndex, InMemoryIndex, Manifest, Options, PythonRequirement, Resolver};
@ -33,6 +34,7 @@ pub struct BuildDispatch<'a> {
index_locations: &'a IndexLocations,
flat_index: &'a FlatIndex,
index: &'a InMemoryIndex,
git: &'a GitResolver,
in_flight: &'a InFlight,
setup_py: SetupPyStrategy,
build_isolation: BuildIsolation<'a>,
@ -56,6 +58,7 @@ impl<'a> BuildDispatch<'a> {
index_locations: &'a IndexLocations,
flat_index: &'a FlatIndex,
index: &'a InMemoryIndex,
git: &'a GitResolver,
in_flight: &'a InFlight,
setup_py: SetupPyStrategy,
config_settings: &'a ConfigSettings,
@ -73,6 +76,7 @@ impl<'a> BuildDispatch<'a> {
index_locations,
flat_index,
index,
git,
in_flight,
setup_py,
config_settings,
@ -102,6 +106,10 @@ impl<'a> BuildContext for BuildDispatch<'a> {
self.cache
}
fn git(&self) -> &GitResolver {
self.git
}
fn interpreter(&self) -> &Interpreter {
self.interpreter
}
@ -194,9 +202,9 @@ impl<'a> BuildContext for BuildDispatch<'a> {
extraneous: _,
} = Planner::new(&requirements).build(
site_packages,
&Reinstall::None,
&NoBinary::None,
&HashStrategy::None,
&Reinstall::default(),
&NoBinary::default(),
&HashStrategy::default(),
self.index_locations,
self.cache(),
venv,