From 3884ab5715937fdf01dbc1c6bfb91cacf00e20ce Mon Sep 17 00:00:00 2001 From: adisbladis Date: Fri, 18 Jul 2025 01:35:25 +1200 Subject: [PATCH] Fix bytecode compilation debug message introduced by #14369 (#14682) ## Summary When refactoring the addition PR I accidentally introduced a bug where the debug message would not be output if the default value is used. cc @zanieb --- crates/uv-installer/src/compile.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/crates/uv-installer/src/compile.rs b/crates/uv-installer/src/compile.rs index 4ee74f40d..8704d9542 100644 --- a/crates/uv-installer/src/compile.rs +++ b/crates/uv-installer/src/compile.rs @@ -91,27 +91,28 @@ pub async fn compile_tree( let pip_compileall_py = tempdir.path().join("pip_compileall.py"); let timeout: Option = match env::var(EnvVars::UV_COMPILE_BYTECODE_TIMEOUT) { - Ok(value) => { - if value == "0" { - debug!("Disabling bytecode compilation timeout"); - None - } else { - if let Ok(duration) = value.parse::().map(Duration::from_secs) { - debug!( - "Using bytecode compilation timeout of {}s", - duration.as_secs() - ); - Some(duration) - } else { + Ok(value) => match value.as_str() { + "0" => None, + _ => match value.parse::().map(Duration::from_secs) { + Ok(duration) => Some(duration), + Err(_) => { return Err(CompileError::EnvironmentError { var: "UV_COMPILE_BYTECODE_TIMEOUT", message: format!("Expected an integer number of seconds, got \"{value}\""), }); } - } - } + }, + }, Err(_) => Some(DEFAULT_COMPILE_TIMEOUT), }; + if let Some(duration) = timeout { + debug!( + "Using bytecode compilation timeout of {}s", + duration.as_secs() + ); + } else { + debug!("Disabling bytecode compilation timeout"); + } debug!("Starting {} bytecode compilation workers", worker_count); let mut worker_handles = Vec::new();