()
| 1 | const CRATE_ROOT: &str = "../.."; |
| 2 | |
| 3 | fn main() { |
| 4 | process_python_libs(format!("{CRATE_ROOT}/vm/Lib/python_builtins/*").as_str()); |
| 5 | process_python_libs(format!("{CRATE_ROOT}/vm/Lib/core_modules/*").as_str()); |
| 6 | |
| 7 | #[cfg(feature = "freeze-stdlib")] |
| 8 | if cfg!(windows) { |
| 9 | process_python_libs(format!("{CRATE_ROOT}/Lib/**/*").as_str()); |
| 10 | } else { |
| 11 | process_python_libs("./Lib/**/*"); |
| 12 | } |
| 13 | |
| 14 | if cfg!(windows) { |
| 15 | // On Windows, the Lib entry can be either: |
| 16 | // 1. A text file containing the relative path (git without symlink support) |
| 17 | // 2. A proper symlink (git with symlink support) |
| 18 | // We handle both cases to resolve to the actual Lib directory. |
| 19 | let lib_path = if let Ok(real_path) = std::fs::read_to_string("Lib") { |
| 20 | // Case 1: Text file containing relative path |
| 21 | std::path::PathBuf::from(real_path.trim()) |
| 22 | } else { |
| 23 | // Case 2: Symlink or directory - canonicalize directly |
| 24 | std::path::PathBuf::from("Lib") |
| 25 | }; |
| 26 | |
| 27 | if let Ok(canonicalized_path) = std::fs::canonicalize(&lib_path) { |
| 28 | // Strip the extended path prefix (\\?\) that canonicalize adds on Windows |
| 29 | let path_str = canonicalized_path.to_str().unwrap(); |
| 30 | let path_str = path_str.strip_prefix(r"\\?\").unwrap_or(path_str); |
| 31 | println!("cargo:rustc-env=win_lib_path={path_str}"); |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | // remove *.pyc files and add *.py to watch list |
| 37 | fn process_python_libs(pattern: &str) { |
nothing calls this directly
no test coverage detected