Build the complete module_search_paths (sys.path)
(settings: &Settings, prefix: &str, exec_prefix: &str)
| 322 | |
| 323 | /// Build the complete module_search_paths (sys.path) |
| 324 | fn 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 |
| 359 | fn get_executable_path() -> Option<PathBuf> { |
no test coverage detected