mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
remove *.pyc during rustpython-pylib build
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
fn main() {
|
||||
rerun_if_changed("../Lib/python_builtins/*");
|
||||
process_python_libs("../Lib/python_builtins/*");
|
||||
|
||||
#[cfg(not(feature = "stdlib"))]
|
||||
rerun_if_changed("../Lib/core_modules/*");
|
||||
process_python_libs("../Lib/core_modules/*");
|
||||
|
||||
#[cfg(feature = "stdlib")]
|
||||
rerun_if_changed("../../Lib/**/*");
|
||||
process_python_libs("../../Lib/**/*");
|
||||
|
||||
if cfg!(windows) {
|
||||
if let Ok(real_path) = std::fs::read_to_string("Lib") {
|
||||
@@ -14,7 +14,8 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
fn rerun_if_changed(pattern: &str) {
|
||||
// remove *.pyc files and add *.py to watch list
|
||||
fn process_python_libs(pattern: &str) {
|
||||
let glob = glob::glob(pattern).unwrap_or_else(|e| panic!("failed to glob {pattern:?}: {e}"));
|
||||
for entry in glob.flatten() {
|
||||
if entry.is_dir() {
|
||||
@@ -22,6 +23,9 @@ fn rerun_if_changed(pattern: &str) {
|
||||
}
|
||||
let display = entry.display();
|
||||
if display.to_string().ends_with(".pyc") {
|
||||
if std::fs::remove_file(&entry).is_err() {
|
||||
println!("cargo:warning=failed to remove {display}")
|
||||
}
|
||||
continue;
|
||||
}
|
||||
println!("cargo:rerun-if-changed={display}");
|
||||
|
||||
Reference in New Issue
Block a user