MCPcopy Index your code
hub / github.com/RustPython/RustPython / calculate_base_executable

Function calculate_base_executable

crates/vm/src/getpath.rs:292–305  ·  view source on GitHub ↗

Calculate base_executable

(executable: Option<&PathBuf>, home_dir: &Option<PathBuf>)

Source from the content-addressed store, hash-verified

290
291/// Calculate base_executable
292fn calculate_base_executable(executable: Option<&PathBuf>, home_dir: &Option<PathBuf>) -> String {
293 // If in venv and we have home, construct base_executable from home
294 if let (Some(exe), Some(home)) = (executable, home_dir)
295 && let Some(exe_name) = exe.file_name()
296 {
297 let base = home.join(exe_name);
298 return base.to_string_lossy().into_owned();
299 }
300
301 // Otherwise, base_executable == executable
302 executable
303 .map(|p| p.to_string_lossy().into_owned())
304 .unwrap_or_default()
305}
306
307/// Calculate stdlib_dir (sys._stdlib_dir)
308/// Returns None if the stdlib directory doesn't exist

Callers 1

init_path_configFunction · 0.85

Calls 4

into_ownedMethod · 0.80
joinMethod · 0.45
to_string_lossyMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected