-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add native locator for finding pythons #23208
Add native locator for finding pythons #23208
Conversation
@@ -67,3 +67,6 @@ test/** | |||
tmp/** | |||
typings/** | |||
types/** | |||
native_locator/src/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why exclude the source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the source in the VSIX?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh never mind, I mis-understood what this file was for.
native_locator/src/conda.rs
Outdated
fn get_conda_package_json_path(any_path: &Path, package: &str) -> Option<PathBuf> { | ||
let package_name = format!("{}-", package); | ||
let conda_meta_path = get_conda_meta_path(any_path); | ||
match conda_meta_path { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tested but you can probably simplify this to something like:
/// Get the path to the json file of a package in the conda environment from the 'conda-meta' directory.
fn get_conda_package_json_path(any_path: &Path, package: &str) -> Option<PathBuf> {
let package_name = format!("{}-", package);
let conda_meta_path = get_conda_meta_path(any_path)?;
std::fs::read_dir(conda_meta_path).ok()?.find_map(|entry| {
let path = entry.ok()?.path();
let file_name = path.file_name()?.to_string_lossy();
if file_name.starts_with(&package_name) && file_name.ends_with(".json") {
Some(path)
} else {
None
}
})
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @wolfv that simplifies it :)
No description provided.