From d0afd10ca4a7c6ebaacbe0a6188eec09d8f47022 Mon Sep 17 00:00:00 2001 From: konsti Date: Wed, 30 Oct 2024 13:00:33 +0100 Subject: [PATCH] Update windows-registry to 0.3.0 (#8696) --- Cargo.lock | 28 ++++++++++++++++++++++++---- Cargo.toml | 2 +- crates/uv-python/src/py_launcher.rs | 21 ++++----------------- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0c738773d..d1bb68812 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2809,7 +2809,7 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots", - "windows-registry", + "windows-registry 0.2.0", ] [[package]] @@ -5060,7 +5060,7 @@ dependencies = [ "uv-static", "uv-warnings", "which", - "windows-registry", + "windows-registry 0.3.0", "windows-result 0.2.0", "windows-sys 0.59.0", ] @@ -5649,7 +5649,7 @@ dependencies = [ "windows-implement 0.58.0", "windows-interface 0.58.0", "windows-result 0.2.0", - "windows-strings", + "windows-strings 0.1.0", "windows-targets 0.52.6", ] @@ -5704,7 +5704,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ "windows-result 0.2.0", - "windows-strings", + "windows-strings 0.1.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-registry" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafa604f2104cf5ae2cc2db1dee84b7e6a5d11b05f737b60def0ffdc398cbc0a" +dependencies = [ + "windows-result 0.2.0", + "windows-strings 0.2.0", "windows-targets 0.52.6", ] @@ -5736,6 +5747,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-strings" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978d65aedf914c664c510d9de43c8fd85ca745eaff1ed53edf409b479e441663" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 997df02e9..c5e7e483b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,7 +172,7 @@ url = { version = "2.5.2" } urlencoding = { version = "2.1.3" } walkdir = { version = "2.5.0" } which = { version = "6.0.3", features = ["regex"] } -windows-registry = { version = "0.2.0" } +windows-registry = { version = "0.3.0" } windows-result = { version = "0.2.0" } windows-sys = { version = "0.59.0", features = ["Win32_Foundation", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Ioctl", "Win32_System_IO"] } winreg = { version = "0.52.0" } diff --git a/crates/uv-python/src/py_launcher.rs b/crates/uv-python/src/py_launcher.rs index a4aa0ed27..af7482d19 100644 --- a/crates/uv-python/src/py_launcher.rs +++ b/crates/uv-python/src/py_launcher.rs @@ -3,7 +3,7 @@ use std::cmp::Ordering; use std::path::PathBuf; use std::str::FromStr; use tracing::debug; -use windows_registry::{Key, Value, CURRENT_USER, LOCAL_MACHINE}; +use windows_registry::{Key, CURRENT_USER, LOCAL_MACHINE}; /// A Python interpreter found in the Windows registry through PEP 514 or from a known Microsoft /// Store path. @@ -16,15 +16,6 @@ pub(crate) struct WindowsPython { pub(crate) version: Option, } -/// Adding `windows_registry::Value::into_string()`. -fn value_to_string(value: Value) -> Option { - match value { - Value::String(string) => Some(string), - Value::Bytes(bytes) => String::from_utf8(bytes.clone()).ok(), - Value::U32(_) | Value::U64(_) | Value::MultiString(_) | Value::Unknown(_) => None, - } -} - /// Find all Pythons registered in the Windows registry following PEP 514. pub(crate) fn registry_pythons() -> Result, windows_result::Error> { let mut registry_pythons = Vec::new(); @@ -72,11 +63,10 @@ pub(crate) fn registry_pythons() -> Result, windows_result::E fn read_registry_entry(company: &str, tag: &str, tag_key: &Key) -> Option { // `ExecutablePath` is mandatory for executable Pythons. - let Some(executable_path) = tag_key + let Ok(executable_path) = tag_key .open("InstallPath") .and_then(|install_path| install_path.get_value("ExecutablePath")) - .ok() - .and_then(value_to_string) + .and_then(String::try_from) else { debug!( r"Python interpreter in the registry is not executable: `Software\Python\{}\{}", @@ -88,11 +78,8 @@ fn read_registry_entry(company: &str, tag: &str, tag_key: &Key) -> Option Some(s), - _ => None, - }) .and_then(|s| match PythonVersion::from_str(&s) { Ok(version) => Some(version), Err(err) => {