diff --git a/src/exe_search.rs b/src/exe_search.rs index 872baf8..29be2f3 100644 --- a/src/exe_search.rs +++ b/src/exe_search.rs @@ -81,7 +81,7 @@ fn get_search_origins() -> HashSet<(PathBuf, bool)> { // Return True if the path points to a python executable. We assume this has already been proven to exist. fn is_exe(path: &Path) -> bool { - return match path.file_name().and_then(|f| f.to_str()) { + match path.file_name().and_then(|f| f.to_str()) { Some(file_name) if file_name.starts_with("python") => { let suffix = &file_name[6..]; if suffix.is_empty() || suffix.chars().all(|c| c.is_ascii_digit() || c == '.') @@ -95,7 +95,7 @@ fn is_exe(path: &Path) -> bool { } } _ => false, - }; + } } fn is_symlink(path: &Path) -> bool { @@ -109,13 +109,13 @@ const PY_SYS_EXE: &str = "import sys;print(sys.executable)"; // Use the default Python to get its executable path. fn get_exe_default() -> Option { - return match Command::new("python3").arg("-c").arg(PY_SYS_EXE).output() { + match Command::new("python3").arg("-c").arg(PY_SYS_EXE).output() { Ok(output) => match std::str::from_utf8(&output.stdout) { Ok(s) => Some(PathBuf::from(s.trim())), Err(_) => None, }, Err(_) => None, - }; + } } /// Try to find all Python executables given a starting directory. This will recursively search all directories that are not symlinks. fn find_exe_inner( diff --git a/src/scan_fs.rs b/src/scan_fs.rs index 43d443a..2550aab 100644 --- a/src/scan_fs.rs +++ b/src/scan_fs.rs @@ -35,13 +35,12 @@ pub(crate) enum Anchor { } //------------------------------------------------------------------------------ -/// Given a path to a Python binary, call out to Python to get all known site packages; some site packages may not exist; we do not filter them here. This will include "dist-packages" on Linux. If `force_usite` is false, we use ENABLE_USER_SITE to determine if we should include the user site packages; if `force_usite` is true, we always include usite. - const PY_SITE_PACKAGES: &str = "import site;print(site.ENABLE_USER_SITE);print(\"\\n\".join(site.getsitepackages()));print(site.getusersitepackages())"; +/// Given a path to a Python binary, call out to Python to get all known site packages; some site packages may not exist; we do not filter them here. This will include "dist-packages" on Linux. If `force_usite` is false, we use ENABLE_USER_SITE to determine if we should include the user site packages; if `force_usite` is true, we always include usite. fn get_site_package_dirs(executable: &Path, force_usite: bool) -> Vec { // let py = "import site;print(site.ENABLE_USER_SITE);print(\"\\n\".join(site.getsitepackages()));print(site.getusersitepackages())"; - return match Command::new(executable) + match Command::new(executable) .arg("-c") .arg(PY_SITE_PACKAGES) .output() @@ -70,7 +69,7 @@ fn get_site_package_dirs(executable: &Path, force_usite: bool) -> Vec