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

Function build_module_search_paths

crates/vm/src/getpath.rs:324–356  ·  view source on GitHub ↗

Build the complete module_search_paths (sys.path)

(settings: &Settings, prefix: &str, exec_prefix: &str)

Source from the content-addressed store, hash-verified

322
323/// Build the complete module_search_paths (sys.path)
324fn build_module_search_paths(settings: &Settings, prefix: &str, exec_prefix: &str) -> Vec<String> {
325 let mut paths = Vec::new();
326
327 // 1. PYTHONPATH/RUSTPYTHONPATH from settings
328 paths.extend(settings.path_list.iter().cloned());
329
330 // 2. ZIP file path
331 let zip_path = PathBuf::from(prefix).join(platform::zip_landmark());
332 paths.push(zip_path.to_string_lossy().into_owned());
333
334 // 3. stdlib and platstdlib directories
335 #[cfg(not(windows))]
336 {
337 // POSIX: stdlib first, then lib-dynload
338 let stdlib_dir = PathBuf::from(prefix).join(platform::stdlib_subdir());
339 paths.push(stdlib_dir.to_string_lossy().into_owned());
340
341 let platstdlib = PathBuf::from(exec_prefix).join(platform::platstdlib_landmark());
342 paths.push(platstdlib.to_string_lossy().into_owned());
343 }
344
345 #[cfg(windows)]
346 {
347 // Windows: DLLs first, then Lib
348 let platstdlib = PathBuf::from(exec_prefix).join(platform::platstdlib_landmark());
349 paths.push(platstdlib.to_string_lossy().into_owned());
350
351 let stdlib_dir = PathBuf::from(prefix).join(platform::STDLIB_SUBDIR);
352 paths.push(stdlib_dir.to_string_lossy().into_owned());
353 }
354
355 paths
356}
357
358/// Get the current executable path
359fn get_executable_path() -> Option<PathBuf> {

Callers 1

init_path_configFunction · 0.85

Calls 10

newFunction · 0.85
zip_landmarkFunction · 0.85
stdlib_subdirFunction · 0.85
platstdlib_landmarkFunction · 0.85
into_ownedMethod · 0.80
extendMethod · 0.45
iterMethod · 0.45
joinMethod · 0.45
pushMethod · 0.45
to_string_lossyMethod · 0.45

Tested by

no test coverage detected