mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 12:59:45 +00:00
Update windows-registry to 0.3.0 (#8696)
This commit is contained in:
parent
4bf01ed337
commit
d0afd10ca4
3 changed files with 29 additions and 22 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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" }
|
||||
|
|
|
|||
|
|
@ -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<PythonVersion>,
|
||||
}
|
||||
|
||||
/// Adding `windows_registry::Value::into_string()`.
|
||||
fn value_to_string(value: Value) -> Option<String> {
|
||||
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<Vec<WindowsPython>, windows_result::Error> {
|
||||
let mut registry_pythons = Vec::new();
|
||||
|
|
@ -72,11 +63,10 @@ pub(crate) fn registry_pythons() -> Result<Vec<WindowsPython>, windows_result::E
|
|||
|
||||
fn read_registry_entry(company: &str, tag: &str, tag_key: &Key) -> Option<WindowsPython> {
|
||||
// `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<Window
|
|||
// `SysVersion` is optional.
|
||||
let version = tag_key
|
||||
.get_value("SysVersion")
|
||||
.and_then(String::try_from)
|
||||
.ok()
|
||||
.and_then(|value| match value {
|
||||
Value::String(s) => Some(s),
|
||||
_ => None,
|
||||
})
|
||||
.and_then(|s| match PythonVersion::from_str(&s) {
|
||||
Ok(version) => Some(version),
|
||||
Err(err) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue