diff --git a/pycross/private/tools/wheel_installer.py b/pycross/private/tools/wheel_installer.py index 4c122d2d..570fe4ee 100644 --- a/pycross/private/tools/wheel_installer.py +++ b/pycross/private/tools/wheel_installer.py @@ -15,6 +15,15 @@ from pycross.private.tools.args import FlagFileArgumentParser +def remove_pycache_folders(root_dir: str) -> None: + """ + Recursively delete all __pycache__ directories in the specified directory. + """ + root_path = Path(root_dir) + for pycache_dir in root_path.rglob("__pycache__"): + shutil.rmtree(pycache_dir, ignore_errors=True) + + def setup_namespace_pkg_compatibility(wheel_dir: Path) -> None: """Converts native namespace packages to pkgutil-style packages @@ -77,6 +86,7 @@ def main(args: Any) -> None: ) finally: shutil.rmtree(link_dir, ignore_errors=True) + remove_pycache_folders(lib_dir) setup_namespace_pkg_compatibility(lib_dir)