From 3ea3a85694a3837d2dbdc46a459a3452a0274f49 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sun, 23 Jun 2019 17:06:21 +0200 Subject: [PATCH] Never delete any files in the .git directory when cleaning manually This is how results can be removed from os.walk(), according to https://docs.python.org/3/library/os.html#os.walk. --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 31cb76015..bc5c3ae25 100755 --- a/setup.py +++ b/setup.py @@ -790,7 +790,9 @@ def clean(): os.unlink(x) safe_remove('build', 'compile_commands.json', 'linux-package', 'kitty.app') - for root, dirs, files in os.walk('.'): + exclude = ('.git',) + for root, dirs, files in os.walk('.', topdown=True): + dirs[:] = [d for d in dirs if d not in exclude] remove_dirs = {d for d in dirs if d == '__pycache__'} [(shutil.rmtree(os.path.join(root, d)), dirs.remove(d)) for d in remove_dirs] for f in files: