Skip to content

Add native locator for finding pythons - #23208

Merged
Karthik Nadig (karthiknadig) merged 6 commits into
microsoft:native_locatorfrom
karthiknadig:rust-locator
May 3, 2024
Merged

Add native locator for finding pythons#23208
Karthik Nadig (karthiknadig) merged 6 commits into
microsoft:native_locatorfrom
karthiknadig:rust-locator

Conversation

@karthiknadig

Copy link
Copy Markdown
Member

No description provided.

Comment thread .vscodeignore
tmp/**
typings/**
types/**
native_locator/src/**

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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 Karthik Nadig (karthiknadig) added the feature-request Request for new features or functionality label Apr 9, 2024
Comment thread 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 {

Copy link
Copy Markdown

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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks Wolf Vollprecht (@wolfv) that simplifies it :)

@karthiknadig
Karthik Nadig (karthiknadig) changed the base branch from main to native_locator May 3, 2024 18:24
@karthiknadig
Karthik Nadig (karthiknadig) marked this pull request as ready for review May 3, 2024 18:39
@karthiknadig
Karthik Nadig (karthiknadig) merged commit 5dde2e1 into microsoft:native_locator May 3, 2024
@karthiknadig
Karthik Nadig (karthiknadig) deleted the rust-locator branch May 3, 2024 18:39
@vscodenpa VS Code Bot (vscodenpa) added this to the May 2024 milestone May 3, 2024
Anthony Kim (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