Add a clean action to setup.py

This commit is contained in:
Kovid Goyal 2017-10-17 13:35:54 +05:30
parent 66803e6873
commit 25913f77e0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 18 additions and 4 deletions

6
.gitignore vendored
View File

@ -1,7 +1,6 @@
*.js
*.pyj-cached
*.so *.so
.build-cache *.pyc
*.pyo
tags tags
build build
linux-package linux-package
@ -9,3 +8,4 @@ logo/*.iconset
test-launcher test-launcher
kitty-profile kitty-profile
dev dev
__pycache__

View File

@ -3,3 +3,6 @@ all:
test: test:
python3 setup.py test python3 setup.py test
clean:
python3 setup.py clean

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -264,7 +264,7 @@ def option_parser():
'action', 'action',
nargs='?', nargs='?',
default='build', default='build',
choices='build test linux-package osx-bundle'.split(), choices='build test linux-package osx-bundle clean'.split(),
help='Action to perform (default is build)' help='Action to perform (default is build)'
) )
p.add_argument( p.add_argument(
@ -425,6 +425,15 @@ Categories=System;
# }}} # }}}
def clean():
for f in subprocess.check_output('git ls-files --others --ignored --exclude-from=.gitignore'.split()).decode('utf-8').splitlines():
if f.startswith('logo/kitty.iconset') or f.startswith('dev/'):
continue
os.unlink(f)
if os.sep in f and not os.listdir(os.path.dirname(f)):
os.rmdir(os.path.dirname(f))
def main(): def main():
if sys.version_info < (3, 5): if sys.version_info < (3, 5):
raise SystemExit('python >= 3.5 required') raise SystemExit('python >= 3.5 required')
@ -447,6 +456,8 @@ def main():
elif args.action == 'osx-bundle': elif args.action == 'osx-bundle':
build(args, native_optimizations=False) build(args, native_optimizations=False)
package(args, for_bundle=True) package(args, for_bundle=True)
elif args.action == 'clean':
clean()
if __name__ == '__main__': if __name__ == '__main__':