-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fixes to in-memory caching and added tests for file caching #119
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
958979e
Fixes to in-memory caching
DonJayamanne 7dbafa9
Enable logging in tests
DonJayamanne 7d3bf95
oops
DonJayamanne cac5faa
ci logging
DonJayamanne 73792c8
more logging
DonJayamanne 36b055d
wip
DonJayamanne 4938efe
wip
DonJayamanne eb2e0e1
misc
DonJayamanne a04d3b5
Updates
DonJayamanne a5228f5
oops
DonJayamanne 897f5e0
fixes
DonJayamanne 94e39ee
logging
DonJayamanne 9d84c5c
tests
DonJayamanne bb07830
oops
DonJayamanne d19af57
fixes
DonJayamanne 7cd319b
fixes
DonJayamanne 024cadc
create multiple venvs
DonJayamanne 7b22622
updates
DonJayamanne 3dedc79
udpatges
DonJayamanne ac7c508
fix paths in JSON windows
DonJayamanne 817d3e2
logging
DonJayamanne 580c84c
wip
DonJayamanne 735dd3a
fixes
DonJayamanne 2cbe603
restore
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
This file contains 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 |
---|---|---|
|
@@ -13,7 +13,7 @@ target/ | |
.DS_Store | ||
|
||
# Testing directories | ||
.venv/ | ||
./.venv/ | ||
tmp/ | ||
temp/ | ||
docs/node_modules/ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
use crate::sym_links::get_known_symlinks; | ||
use lazy_static::lazy_static; | ||
use log::trace; | ||
use pet_core::python_environment::{ | ||
PythonEnvironment, PythonEnvironmentBuilder, PythonEnvironmentKind, | ||
}; | ||
|
@@ -12,19 +13,21 @@ use std::path::{Path, PathBuf}; | |
|
||
lazy_static! { | ||
static ref PYTHON_VERSION: Regex = | ||
Regex::new(r"/(\d+\.\d+\.\d+)/").expect("error parsing Version regex for Homebrew"); | ||
Regex::new(r"/(\d+\.\d+\.\d+)").expect("error parsing Version regex for Homebrew"); | ||
} | ||
|
||
pub fn get_python_info( | ||
python_exe_from_bin_dir: &Path, | ||
resolved_exe: &Path, | ||
) -> Option<PythonEnvironment> { | ||
// let user_friendly_exe = python_exe_from_bin_dir; | ||
let python_version = resolved_exe.to_string_lossy().to_string(); | ||
let version = match PYTHON_VERSION.captures(&python_version) { | ||
Some(captures) => captures.get(1).map(|version| version.as_str().to_string()), | ||
None => None, | ||
}; | ||
let version = get_version(resolved_exe); | ||
|
||
trace!( | ||
"Getting homebrew python info for {:?} => {:?} with version {:?}", | ||
python_exe_from_bin_dir, | ||
resolved_exe, | ||
version | ||
); | ||
|
||
let mut symlinks = vec![ | ||
python_exe_from_bin_dir.to_path_buf(), | ||
|
@@ -57,6 +60,14 @@ pub fn get_python_info( | |
Some(env) | ||
} | ||
|
||
fn get_version(resolved_exe: &Path) -> Option<String> { | ||
let python_version = resolved_exe.to_string_lossy().to_string(); | ||
match PYTHON_VERSION.captures(&python_version) { | ||
Some(captures) => captures.get(1).map(|version| version.as_str().to_string()), | ||
None => None, | ||
} | ||
} | ||
|
||
fn get_prefix(_resolved_file: &Path) -> Option<PathBuf> { | ||
// NOTE: | ||
// While testing found that on Mac Intel | ||
|
@@ -135,3 +146,26 @@ fn get_prefix(_resolved_file: &Path) -> Option<PathBuf> { | |
// } | ||
None | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
#[cfg(unix)] | ||
fn extract_version() { | ||
assert_eq!( | ||
get_version(&PathBuf::from( | ||
"/home/linuxbrew/.linuxbrew/Cellar/[email protected]/3.12.4/bin/python3" | ||
)), | ||
Some("3.12.4".to_string()) | ||
); | ||
|
||
assert_eq!( | ||
get_version(&PathBuf::from( | ||
"/home/linuxbrew/.linuxbrew/Cellar/[email protected]/3.11.9_1/bin/python3.11" | ||
)), | ||
Some("3.11.9".to_string()) | ||
); | ||
} | ||
} |
This file contains 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 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 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 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
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.
Found a bug, as a result of the CI containers getting updated..