Fix #1438 (setup.py does not clean up properly)

This commit is contained in:
Kovid Goyal 2008-12-23 15:28:03 -08:00
parent 58a09d73f0
commit fb008667e5

View File

@ -252,6 +252,7 @@ if __name__ == '__main__':
description='''Compile all GUI forms and images''' description='''Compile all GUI forms and images'''
PATH = os.path.join('src', APPNAME, 'gui2') PATH = os.path.join('src', APPNAME, 'gui2')
IMAGES_DEST = os.path.join(PATH, 'images_rc.py') IMAGES_DEST = os.path.join(PATH, 'images_rc.py')
QRC = os.path.join(PATH, 'images.qrc')
@classmethod @classmethod
def find_forms(cls): def find_forms(cls):
@ -331,9 +332,9 @@ if __name__ == '__main__':
c = cls.form_to_compiled_form(form) c = cls.form_to_compiled_form(form)
if os.path.exists(c): if os.path.exists(c):
os.remove(c) os.remove(c)
images = cls.IMAGES_DEST for x in (cls.IMAGES_DEST, cls.QRC):
if os.path.exists(images): if os.path.exists(x):
os.remove(images) os.remove(x)
class clean(Command): class clean(Command):
description='''Delete all computer generated files in the source tree''' description='''Delete all computer generated files in the source tree'''
@ -349,17 +350,13 @@ if __name__ == '__main__':
os.remove(f) os.remove(f)
for root, dirs, files in os.walk('.'): for root, dirs, files in os.walk('.'):
for name in files: for name in files:
if name.endswith('~') or \ for t in ('.pyc', '.pyo', '~'):
name.endswith('.pyc') or \ if name.endswith(t):
name.endswith('.pyo'):
os.remove(os.path.join(root, name)) os.remove(os.path.join(root, name))
break
for dir in 'build', 'dist': for dir in ('build', 'dist', os.path.join('src', 'calibre.egg-info')):
for f in os.listdir(dir): shutil.rmtree(dir, ignore_errors=True)
if os.path.isdir(dir + os.sep + f):
shutil.rmtree(dir + os.sep + f)
else:
os.remove(dir + os.sep + f)
class build(_build): class build(_build):