remove *.pyc files and add *.py to watch list
(pattern: &str)
| 35 | |
| 36 | // remove *.pyc files and add *.py to watch list |
| 37 | fn process_python_libs(pattern: &str) { |
| 38 | let glob = glob::glob(pattern).unwrap_or_else(|e| panic!("failed to glob {pattern:?}: {e}")); |
| 39 | for entry in glob.flatten() { |
| 40 | if entry.is_dir() { |
| 41 | continue; |
| 42 | } |
| 43 | let display = entry.display(); |
| 44 | if display.to_string().ends_with(".pyc") { |
| 45 | if std::fs::remove_file(&entry).is_err() { |
| 46 | println!("cargo:warning=failed to remove {display}") |
| 47 | } |
| 48 | continue; |
| 49 | } |
| 50 | println!("cargo:rerun-if-changed={display}"); |
| 51 | } |
| 52 | } |