Skip to content
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

Merged
merged 6 commits into from
May 3, 2024

Conversation

karthiknadig
Copy link
Member

No description provided.

@@ -67,3 +67,6 @@ test/**
tmp/**
typings/**
types/**
native_locator/src/**
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why exclude the source?

Copy link
Member Author

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?

Copy link

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.

@karthiknadig karthiknadig self-assigned this Apr 9, 2024
@karthiknadig karthiknadig added the feature-request Request for new features or functionality label Apr 9, 2024
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 {
Copy link

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
        }
    })
}

Copy link
Member Author

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 :)

@karthiknadig karthiknadig changed the base branch from main to native_locator May 3, 2024 18:24
@karthiknadig karthiknadig marked this pull request as ready for review May 3, 2024 18:39
@karthiknadig karthiknadig merged commit 5dde2e1 into microsoft:native_locator May 3, 2024
21 of 30 checks passed
@karthiknadig karthiknadig deleted the rust-locator branch May 3, 2024 18:39
@vscodenpa vscodenpa added this to the May 2024 milestone May 3, 2024
anthonykim1 pushed a commit to anthonykim1/vscode-python that referenced this pull request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants