Skip to content

Commit 9f4ed59

Browse files
committed
Add sysPrefixPath to native locator (#23360)
1 parent 06839d1 commit 9f4ed59

File tree

7 files changed

+13
-3
lines changed

7 files changed

+13
-3
lines changed

native_locator/src/common_python.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ fn report_path_python(dispatcher: &mut impl messaging::MessageDispatcher, path:
3030
messaging::PythonEnvironmentCategory::System,
3131
version,
3232
None,
33+
env_path.clone(),
3334
env_path,
3435
));
3536
}

native_locator/src/conda.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ pub fn find_and_report(
380380
let envs = get_distinct_conda_envs(conda_binary.to_path_buf(), environment);
381381
for env in envs {
382382
let executable = find_python_binary_path(Path::new(&env.path));
383+
let env_path = env.path.to_string_lossy().to_string();
383384
let params = messaging::PythonEnvironment::new(
384385
env.name.to_string(),
385386
match executable {
@@ -405,7 +406,8 @@ pub fn find_and_report(
405406
"python".to_string(),
406407
])
407408
},
408-
Some(env.path.to_string_lossy().to_string()),
409+
Some(env_path.clone()),
410+
Some(env_path),
409411
);
410412
let message = messaging::PythonEnvironmentMessage::new(params);
411413
dispatcher.send_message(message);

native_locator/src/messaging.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub struct PythonEnvironment {
6464
pub version: Option<String>,
6565
pub activated_run: Option<Vec<String>>,
6666
pub env_path: Option<String>,
67+
pub sys_prefix_path: Option<String>,
6768
}
6869

6970
impl PythonEnvironment {
@@ -74,6 +75,7 @@ impl PythonEnvironment {
7475
version: Option<String>,
7576
activated_run: Option<Vec<String>>,
7677
env_path: Option<String>,
78+
sys_prefix_path: Option<String>,
7779
) -> Self {
7880
Self {
7981
name,
@@ -82,6 +84,7 @@ impl PythonEnvironment {
8284
version,
8385
activated_run,
8486
env_path,
87+
sys_prefix_path
8588
}
8689
}
8790
}

native_locator/src/pyenv.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub fn find_and_report(
9494
if path.is_dir() {
9595
if let Some(executable) = find_python_binary_path(&path) {
9696
let version = path.file_name().unwrap().to_string_lossy().to_string();
97+
let env_path = path.to_string_lossy().to_string();
9798
dispatcher.send_message(messaging::PythonEnvironment::new(
9899
"Python".to_string(),
99100
vec![executable.into_os_string().into_string().unwrap()],
@@ -104,7 +105,8 @@ pub fn find_and_report(
104105
"shell".to_string(),
105106
version,
106107
]),
107-
Some(path.into_os_string().into_string().unwrap()),
108+
Some(env_path.clone()),
109+
Some(env_path),
108110
));
109111
}
110112
}

native_locator/src/windows_python.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn report_path_python(path: &str, dispatcher: &mut impl messaging::MessageDispat
1515
version,
1616
None,
1717
None,
18+
None,
1819
));
1920
}
2021

native_locator/tests/common_python_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fn find_python_in_path_this() {
2727
common_python::find_and_report(&mut dispatcher, &known);
2828

2929
assert_eq!(dispatcher.messages.len(), 1);
30-
let expected_json = json!({"name":"Python","pythonExecutablePath":[unix_python_exe.clone()],"category":"system","version":null,"activatedRun":null,"envPath":unix_python.clone()});
30+
let expected_json = json!({"name":"Python","pythonExecutablePath":[unix_python_exe.clone()],"category":"system","version":null,"activatedRun":null,"envPath":unix_python.clone(),"sysPrefixPath":unix_python.clone()});
3131
assert_messages(&[expected_json], &dispatcher);
3232
}

src/client/pythonEnvironments/base/locators/lowLevel/nativeLocator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface NativeEnvInfo {
2525
version?: string;
2626
activatedRun?: string[];
2727
envPath?: string;
28+
sysPrefixPath?: string;
2829
}
2930

3031
interface EnvManager {

0 commit comments

Comments
 (0)