make clean should not clean bypy build artifacts

This commit is contained in:
Kovid Goyal 2021-06-28 06:39:12 +05:30
parent 73f641cb66
commit 90164dfee7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1145,9 +1145,13 @@ def clean() -> None:
'build', 'compile_commands.json', 'link_commands.json',
'linux-package', 'kitty.app', 'asan-launcher',
'kitty-profile', 'kitty/launcher')
exclude = ('.git',)
for root, dirs, files in os.walk('.', topdown=True):
dirs[:] = [d for d in dirs if d not in exclude]
def excluded(root: str, d: str) -> bool:
q = os.path.relpath(os.path.join(root, d), base).replace(os.sep, '/')
return q in ('.git', 'bypy/b')
for root, dirs, files in os.walk(base, topdown=True):
dirs[:] = [d for d in dirs if not excluded(root, d)]
remove_dirs = {d for d in dirs if d == '__pycache__' or d.endswith('.dSYM')}
for d in remove_dirs:
shutil.rmtree(os.path.join(root, d))