-
Notifications
You must be signed in to change notification settings - Fork 27
Support resolving Python environments #35
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a526f7c
Support resolving Python environments
DonJayamanne bf8f8cb
Fixes
DonJayamanne 34412a5
Find sysprefix
DonJayamanne b0f0b98
More fixes
DonJayamanne 55795cd
fixes
DonJayamanne c874ea5
Update crates/pet-core/src/telemetry/inaccurate_python_info.rs
DonJayamanne 6140199
Update crates/pet-core/src/telemetry/inaccurate_python_info.rs
DonJayamanne 1c1f5f3
Update crates/pet-core/src/telemetry/mod.rs
DonJayamanne 0b02cef
Update crates/pet-telemetry/src/lib.rs
DonJayamanne 91eb85f
Update crates/pet-telemetry/src/lib.rs
DonJayamanne 6f43bfb
Update crates/pet-core/src/telemetry/mod.rs
DonJayamanne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
pub fn add(left: usize, right: usize) -> usize { | ||
left + right | ||
} | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use pet_core::python_environment::PythonEnvironment; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
pub trait Cache { | ||
fn get<P: AsRef<P>>(&self, executable: P) -> Option<PythonEnvironment>; | ||
fn set<P: AsRef<P>>(&self, environment: PythonEnvironment); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
pub trait Cache { | ||
fn get<P: AsRef<P>>(&self, executable: P) -> Option<PythonEnvironment>; | ||
fn set<P: AsRef<P>>(&self, environment: PythonEnvironment); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
use crate::python_environment::PythonEnvironmentCategory; | ||
|
||
/// Information about an environment that was discovered to be inaccurate. | ||
/// If the discovered information is None, then it means that the information was not found. | ||
/// And we will not report that as an inaccuracy. | ||
pub struct InaccuratePythonEnvironmentInfo { | ||
/// Python Env category | ||
pub category: PythonEnvironmentCategory, | ||
/// Whether the actual exe is not what we expected. | ||
pub invalid_executable: Option<bool>, | ||
/// Whether the actual exe was not even in the list of symlinks that we expected. | ||
pub executable_not_in_symlinks: Option<bool>, | ||
/// Whether the prefix is not what we expected. | ||
pub invalid_prefix: Option<bool>, | ||
/// Whether the version is not what we expected. | ||
pub invalid_version: Option<bool>, | ||
/// Whether the architecture is not what we expected. | ||
pub invalid_arch: Option<bool>, | ||
} | ||
|
||
impl std::fmt::Display for InaccuratePythonEnvironmentInfo { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
writeln!(f, "Environment {:?} incorrectly identified", self.category).unwrap_or_default(); | ||
if self.invalid_executable.unwrap_or_default() { | ||
writeln!(f, " Executable is incorrect").unwrap_or_default(); | ||
} | ||
if self.executable_not_in_symlinks.unwrap_or_default() { | ||
writeln!(f, " Executable is not in the list of symlinks").unwrap_or_default(); | ||
} | ||
if self.invalid_prefix.unwrap_or_default() { | ||
writeln!(f, " Prefix is incorrect").unwrap_or_default(); | ||
} | ||
if self.invalid_version.unwrap_or_default() { | ||
writeln!(f, " Version is incorrect").unwrap_or_default(); | ||
} | ||
if self.invalid_arch.unwrap_or_default() { | ||
writeln!(f, " Architecture is incorrect").unwrap_or_default(); | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
use inaccurate_python_info::InaccuratePythonEnvironmentInfo; | ||
|
||
pub mod inaccurate_python_info; | ||
|
||
pub type NumberOfCustomSearchPaths = u32; | ||
|
||
pub enum TelemetryEvent { | ||
/// Total time taken to search for Global environments. | ||
GlobalEnvironmentsSearchCompleted(std::time::Duration), | ||
/// Total time taken to search for Global Virtual environments. | ||
GlobalVirtualEnvironmentsSearchCompleted(std::time::Duration), | ||
/// Total time taken to search for environments in the PATH environment variable. | ||
GlobalPathVariableEnvironmentsSearchCompleted(std::time::Duration), | ||
/// Total time taken to search for environments in specific paths provided by the user. | ||
/// This generally maps to workspace folders in Python extension. | ||
AllSearchPathsEnvironmentsSearchCompleted(std::time::Duration, NumberOfCustomSearchPaths), | ||
/// Total time taken to search for all environments in all locations. | ||
/// This is the max of all of the other `SearchCompleted` durations. | ||
SearchCompleted(std::time::Duration), | ||
/// Sent when an the information for an environment discovered is not accurate. | ||
InaccuratePythonEnvironmentInfo(InaccuratePythonEnvironmentInfo), | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ version = "0.1.0" | |
edition = "2021" | ||
|
||
[dependencies] | ||
log = "0.4.21" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Minor refactor