Skip to content

Commit e7a4f7e

Browse files
authored
Ignore Win Store Python in Windows Registry search (#23492)
1 parent 47ad791 commit e7a4f7e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

native_locator/src/windows_registry.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use crate::messaging::{PythonEnvironment, PythonEnvironmentCategory};
1212
#[cfg(windows)]
1313
use crate::utils::PythonEnv;
1414
#[cfg(windows)]
15+
use crate::windows_store::is_windows_app_folder_in_program_files;
16+
#[cfg(windows)]
1517
use std::path::PathBuf;
1618
#[cfg(windows)]
1719
use winreg::RegKey;
@@ -37,6 +39,16 @@ fn get_registry_pythons_from_key_for_company(
3739
let env_path: String =
3840
install_path_key.get_value("").ok().unwrap_or_default();
3941
let env_path = PathBuf::from(env_path);
42+
if is_windows_app_folder_in_program_files(&env_path) {
43+
trace!(
44+
"Found Python ({}) in {}\\Software\\Python\\{}\\{}, but skipping as this is a Windows Store Python",
45+
env_path.to_str().unwrap_or_default(),
46+
key_container,
47+
company,
48+
installed_python,
49+
);
50+
continue;
51+
}
4052
trace!(
4153
"Found Python ({}) in {}\\Software\\Python\\{}\\{}",
4254
env_path.to_str().unwrap_or_default(),

native_locator/src/windows_store.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ pub fn is_windows_python_executable(path: &PathBuf) -> bool {
2727
name.starts_with("python3.") && name.ends_with(".exe")
2828
}
2929

30+
#[cfg(windows)]
31+
pub fn is_windows_app_folder_in_program_files(path: &PathBuf) -> bool {
32+
path.to_str().unwrap_or_default().to_string().to_lowercase()[1..].starts_with(":\\program files\\windowsapps")
33+
}
34+
3035
#[cfg(windows)]
3136
fn list_windows_store_python_executables(
3237
environment: &dyn known::Environment,

0 commit comments

Comments
 (0)