fix(build-backend): improve bytecode cleanup to only remove .pyc/.pyo files if corresponding .py exists

This commit is contained in:
Ivan
2026-05-06 00:35:38 -05:00
parent afbc80b8fa
commit 91902dda10
+5 -1
View File
@@ -101,7 +101,11 @@ function stripPythonBytecodeArtifacts(dir) {
stripPythonBytecodeArtifacts(full);
}
} else if (ent.name.endsWith(".pyc") || ent.name.endsWith(".pyo")) {
fs.unlinkSync(full);
const stem = ent.name.replace(/\.pyc$/i, "").replace(/\.pyo$/i, "");
const siblingPy = path.join(dir, `${stem}.py`);
if (fs.existsSync(siblingPy)) {
fs.unlinkSync(full);
}
}
}
}