diff --git a/setup.py b/setup.py index 5e2d309dd..5b6ab972f 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,7 @@ from setuptools import setup, find_packages, Extension from setuptools.command.sdist import sdist +from distutils.command.clean import clean compress_source = 'src/borg/compress.pyx' crypto_ll_source = 'src/borg/crypto/low_level.pyx' @@ -567,11 +568,30 @@ def is_positional_group(group): write(option.ljust(padding), desc) +class Clean(clean): + def run(self): + super().run() + for source in cython_sources: + genc = source.replace('.pyx', '.c') + try: + os.unlink(genc) + print('rm', genc) + except FileNotFoundError: + pass + compiled_glob = source.replace('.pyx', '.cpython*') + for compiled in glob(compiled_glob): + try: + os.unlink(compiled) + print('rm', compiled) + except FileNotFoundError: + pass + cmdclass = { 'build_ext': build_ext, 'build_usage': build_usage, 'build_man': build_man, - 'sdist': Sdist + 'sdist': Sdist, + 'clean': Clean, } ext_modules = []