Skip to content

Add sysPrefixPath to native locator #23360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions native_locator/src/common_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fn report_path_python(dispatcher: &mut impl messaging::MessageDispatcher, path:
messaging::PythonEnvironmentCategory::System,
version,
None,
env_path.clone(),
env_path,
));
}
Expand Down
4 changes: 3 additions & 1 deletion native_locator/src/conda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ pub fn find_and_report(
let envs = get_distinct_conda_envs(conda_binary.to_path_buf(), environment);
for env in envs {
let executable = find_python_binary_path(Path::new(&env.path));
let env_path = env.path.to_string_lossy().to_string();
let params = messaging::PythonEnvironment::new(
env.name.to_string(),
match executable {
Expand All @@ -405,7 +406,8 @@ pub fn find_and_report(
"python".to_string(),
])
},
Some(env.path.to_string_lossy().to_string()),
Some(env_path.clone()),
Some(env_path),
);
let message = messaging::PythonEnvironmentMessage::new(params);
dispatcher.send_message(message);
Expand Down
3 changes: 3 additions & 0 deletions native_locator/src/messaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub struct PythonEnvironment {
pub version: Option<String>,
pub activated_run: Option<Vec<String>>,
pub env_path: Option<String>,
pub sys_prefix_path: Option<String>,
}

impl PythonEnvironment {
Expand All @@ -74,6 +75,7 @@ impl PythonEnvironment {
version: Option<String>,
activated_run: Option<Vec<String>>,
env_path: Option<String>,
sys_prefix_path: Option<String>,
) -> Self {
Self {
name,
Expand All @@ -82,6 +84,7 @@ impl PythonEnvironment {
version,
activated_run,
env_path,
sys_prefix_path
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion native_locator/src/pyenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub fn find_and_report(
if path.is_dir() {
if let Some(executable) = find_python_binary_path(&path) {
let version = path.file_name().unwrap().to_string_lossy().to_string();
let env_path = path.to_string_lossy().to_string();
dispatcher.send_message(messaging::PythonEnvironment::new(
"Python".to_string(),
vec![executable.into_os_string().into_string().unwrap()],
Expand All @@ -104,7 +105,8 @@ pub fn find_and_report(
"shell".to_string(),
version,
]),
Some(path.into_os_string().into_string().unwrap()),
Some(env_path.clone()),
Some(env_path),
));
}
}
Expand Down
1 change: 1 addition & 0 deletions native_locator/src/windows_python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn report_path_python(path: &str, dispatcher: &mut impl messaging::MessageDispat
version,
None,
None,
None,
));
}

Expand Down
2 changes: 1 addition & 1 deletion native_locator/tests/common_python_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ fn find_python_in_path_this() {
common_python::find_and_report(&mut dispatcher, &known);

assert_eq!(dispatcher.messages.len(), 1);
let expected_json = json!({"name":"Python","pythonExecutablePath":[unix_python_exe.clone()],"category":"system","version":null,"activatedRun":null,"envPath":unix_python.clone()});
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()});
assert_messages(&[expected_json], &dispatcher);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface NativeEnvInfo {
version?: string;
activatedRun?: string[];
envPath?: string;
sysPrefixPath?: string;
}

interface EnvManager {
Expand Down
Loading