Use borrowed data in BuildDispatch (#679)

This PR uses borrowed data in `BuildDispatch` which makes creating a
`BuildDispatch` extremely cheap (only one allocation, for the Python
executable). I can be talked out of this, it will have no measurable
impact.
This commit is contained in:
Charlie Marsh 2023-12-18 11:43:03 -05:00 committed by GitHub
parent c400ab7d07
commit dbf055fe6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 94 additions and 101 deletions

View file

@ -139,12 +139,12 @@ pub(crate) async fn pip_compile(
let options = ResolutionOptions::new(resolution_mode, prerelease_mode, exclude_newer);
let build_dispatch = BuildDispatch::new(
client.clone(),
cache.clone(),
interpreter,
&client,
&cache,
&interpreter,
&index_urls,
venv.python_executable(),
no_build,
index_urls,
)
.with_options(options);

View file

@ -133,12 +133,12 @@ pub(crate) async fn pip_install(
let options = ResolutionOptions::new(resolution_mode, prerelease_mode, exclude_newer);
let build_dispatch = BuildDispatch::new(
client.clone(),
cache.clone(),
interpreter,
&client,
&cache,
&interpreter,
&index_urls,
venv.python_executable(),
no_build,
index_urls.clone(),
)
.with_options(options);
@ -200,7 +200,7 @@ pub(crate) async fn pip_install(
site_packages,
reinstall,
link_mode,
index_urls,
&index_urls,
&tags,
&client,
&build_dispatch,
@ -264,7 +264,7 @@ async fn build_editables(
cache: &Cache,
tags: &Tags,
client: &RegistryClient,
build_dispatch: &BuildDispatch,
build_dispatch: &BuildDispatch<'_>,
mut printer: Printer,
) -> Result<Vec<BuiltEditable>, Error> {
let start = std::time::Instant::now();
@ -321,7 +321,7 @@ async fn resolve(
tags: &Tags,
markers: &MarkerEnvironment,
client: &RegistryClient,
build_dispatch: &BuildDispatch,
build_dispatch: &BuildDispatch<'_>,
options: ResolutionOptions,
mut printer: Printer,
) -> Result<ResolutionGraph, Error> {
@ -386,10 +386,10 @@ async fn install(
site_packages: SitePackages<'_>,
reinstall: &Reinstall,
link_mode: LinkMode,
index_urls: IndexUrls,
index_urls: &IndexUrls,
tags: &Tags,
client: &RegistryClient,
build_dispatch: &BuildDispatch,
build_dispatch: &BuildDispatch<'_>,
cache: &Cache,
venv: &Virtualenv,
mut printer: Printer,
@ -413,7 +413,7 @@ async fn install(
editables,
site_packages,
reinstall,
&index_urls,
index_urls,
cache,
venv,
tags,

View file

@ -62,12 +62,12 @@ pub(crate) async fn pip_sync(
// Prep the build context.
let build_dispatch = BuildDispatch::new(
client.clone(),
cache.clone(),
venv.interpreter().clone(),
&client,
&cache,
venv.interpreter(),
&index_urls,
venv.python_executable(),
no_build,
index_urls.clone(),
);
// Determine the set of installed packages.
@ -341,7 +341,7 @@ async fn resolve_editables(
tags: &Tags,
cache: &Cache,
client: &RegistryClient,
build_dispatch: &BuildDispatch,
build_dispatch: &BuildDispatch<'_>,
mut printer: Printer,
) -> Result<ResolvedEditables> {
// Partition the editables into those that are already installed, and those that must be built.