diff --git a/crates/uv-dispatch/src/lib.rs b/crates/uv-dispatch/src/lib.rs index ddc2d5ed5..606836a06 100644 --- a/crates/uv-dispatch/src/lib.rs +++ b/crates/uv-dispatch/src/lib.rs @@ -175,7 +175,7 @@ impl<'a> BuildDispatch<'a> { impl BuildContext for BuildDispatch<'_> { type SourceDistBuilder = SourceBuild; - fn interpreter(&self) -> &Interpreter { + async fn interpreter(&self) -> &Interpreter { self.interpreter } diff --git a/crates/uv-distribution/src/source/mod.rs b/crates/uv-distribution/src/source/mod.rs index f269c1b87..3d9361797 100644 --- a/crates/uv-distribution/src/source/mod.rs +++ b/crates/uv-distribution/src/source/mod.rs @@ -2386,11 +2386,13 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> { let base_python = if cfg!(unix) { self.build_context .interpreter() + .await .find_base_python() .map_err(Error::BaseInterpreter)? } else { self.build_context .interpreter() + .await .to_base_python() .map_err(Error::BaseInterpreter)? }; @@ -2485,7 +2487,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> { // Ensure that the _installed_ Python version is compatible with the `requires-python` // specifier. if let Some(requires_python) = source.requires_python() { - let installed = self.build_context.interpreter().python_version(); + let installed = self.build_context.interpreter().await.python_version(); let target = release_specifiers_to_ranges(requires_python.clone()) .bounding_range() .map(|bounding_range| bounding_range.0.cloned()) @@ -2507,11 +2509,13 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> { let base_python = if cfg!(unix) { self.build_context .interpreter() + .await .find_base_python() .map_err(Error::BaseInterpreter)? } else { self.build_context .interpreter() + .await .to_base_python() .map_err(Error::BaseInterpreter)? }; diff --git a/crates/uv-types/src/traits.rs b/crates/uv-types/src/traits.rs index 875742da9..68e6583ae 100644 --- a/crates/uv-types/src/traits.rs +++ b/crates/uv-types/src/traits.rs @@ -62,8 +62,10 @@ use crate::BuildArena; pub trait BuildContext { type SourceDistBuilder: SourceBuildTrait; + // Note: this function is async deliberately, because downstream code may need to + // run async code to get the interpreter, to resolve the Python version. /// Return a reference to the interpreter. - fn interpreter(&self) -> &Interpreter; + fn interpreter(&self) -> impl Future + '_; /// Return a reference to the cache. fn cache(&self) -> &Cache;