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

Function calculate_exec_prefix

crates/vm/src/getpath.rs:269–289  ·  view source on GitHub ↗

Calculate exec_prefix

(exe_dir: &Option<PathBuf>, prefix: &str)

Source from the content-addressed store, hash-verified

267
268/// Calculate exec_prefix
269fn calculate_exec_prefix(exe_dir: &Option<PathBuf>, prefix: &str) -> String {
270 #[cfg(windows)]
271 {
272 // Windows: exec_prefix == prefix
273 let _ = exe_dir; // silence unused warning
274 prefix.to_owned()
275 }
276
277 #[cfg(not(windows))]
278 {
279 // POSIX: search for lib-dynload directory
280 if let Some(dir) = exe_dir {
281 let landmark = platform::platstdlib_landmark();
282 if let Some(exec_prefix) = search_up_dir(dir, &[&landmark]) {
283 return exec_prefix.to_string_lossy().into_owned();
284 }
285 }
286 // Fallback: same as prefix
287 prefix.to_owned()
288 }
289}
290
291/// Calculate base_executable
292fn calculate_base_executable(executable: Option<&PathBuf>, home_dir: &Option<PathBuf>) -> String {

Callers 1

init_path_configFunction · 0.85

Calls 5

platstdlib_landmarkFunction · 0.85
search_up_dirFunction · 0.85
into_ownedMethod · 0.80
to_ownedMethod · 0.45
to_string_lossyMethod · 0.45

Tested by

no test coverage detected