Skip to content

Commit c7b9bb3

Browse files
authored
clean pycache after downloading template, fixes #4135 (#5014)
* clean pycache after downloading template, fixes #4135 * simplify logic
1 parent a25cead commit c7b9bb3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

reflex/utils/prerequisites.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -905,11 +905,12 @@ def initialize_app_directory(
905905

906906
console.debug(f"Using {template_name=} {template_dir=} {template_code_dir_name=}.")
907907

908-
# Remove all pyc and __pycache__ dirs in template directory.
909-
for pyc_file in template_dir.glob("**/*.pyc"):
910-
pyc_file.unlink()
911-
for pycache_dir in template_dir.glob("**/__pycache__"):
912-
pycache_dir.rmdir()
908+
# Remove __pycache__ dirs in template directory and current directory.
909+
for pycache_dir in [
910+
*template_dir.glob("**/__pycache__"),
911+
*Path.cwd().glob("**/__pycache__"),
912+
]:
913+
shutil.rmtree(pycache_dir, ignore_errors=True)
913914

914915
for file in template_dir.iterdir():
915916
# Copy the file to current directory but keep the name the same.

0 commit comments

Comments
 (0)