From 1b1600c40e96f66ffa0982e6186b3b1a81e6934e Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Mon, 3 Jun 2024 15:13:44 +0200 Subject: [PATCH] feat: add back the use of extra env vars to the build dispatch (#3981) Seems like a recent Pull removed this, couldn't directly find out which. I'm adding it back as we rely on this API, and I do not see another way of accessing this, or am I mistaken? Thanks! --- crates/uv-dispatch/src/lib.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/uv-dispatch/src/lib.rs b/crates/uv-dispatch/src/lib.rs index 44b2bcbb9..456c5e44a 100644 --- a/crates/uv-dispatch/src/lib.rs +++ b/crates/uv-dispatch/src/lib.rs @@ -2,7 +2,7 @@ //! [installer][`uv_installer`] and [build][`uv_build`] through [`BuildDispatch`] //! implementing [`BuildContext`]. -use std::ffi::OsString; +use std::ffi::{OsStr, OsString}; use std::path::Path; use anyhow::{bail, Context, Result}; @@ -97,6 +97,21 @@ impl<'a> BuildDispatch<'a> { self.options = options; self } + + /// Set the environment variables to be used when building a source distribution. + #[must_use] + pub fn with_build_extra_env_vars(mut self, sdist_build_env_variables: I) -> Self + where + I: IntoIterator, + K: AsRef, + V: AsRef, + { + self.build_extra_env_vars = sdist_build_env_variables + .into_iter() + .map(|(key, value)| (key.as_ref().to_owned(), value.as_ref().to_owned())) + .collect(); + self + } } impl<'a> BuildContext for BuildDispatch<'a> {