Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions native_locator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@ serde_json = "1.0.93"
serde_repr = "0.1.10"
regex = "1.10.4"

[features]
test = []

[lib]
doctest = false
20 changes: 1 addition & 19 deletions native_locator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
process::Command,
};

fn get_version_impl(path: &str) -> Option<String> {
pub fn get_version(path: &str) -> Option<String> {
let output = Command::new(path)
.arg("-c")
.arg("import sys; print(sys.version)")
Expand All @@ -18,24 +18,6 @@ fn get_version_impl(path: &str) -> Option<String> {
Some(output.to_string())
}

#[cfg(not(feature = "test"))]
pub fn get_version(path: &str) -> Option<String> {
get_version_impl(path)
}

// Tests

#[cfg(feature = "test")]
pub fn get_version(path: &str) -> Option<String> {
use std::path::PathBuf;
let version_file = PathBuf::from(path.to_owned() + ".version");
if version_file.exists() {
let version = std::fs::read_to_string(version_file).ok()?;
return Some(version.trim().to_string());
}
get_version_impl(path)
}

pub fn find_python_binary_path(env_path: &Path) -> Option<PathBuf> {
let python_bin_name = if cfg!(windows) {
"python.exe"
Expand Down