diff --git a/setup.py b/setup.py index 6098eb0..d46d133 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ import os -from setuptools import setup +import shutil +from setuptools import Command, setup def extensions(): @@ -92,6 +93,28 @@ def extensions(): ] +class CleanExtCommand(Command): + description = 'Clean all compiled python extensions from the current directory.' + + user_options = [] + + def initialize_options(self) -> None: + pass + + def finalize_options(self) -> None: + pass + + def run(self) -> None: + print("Removing build directory...") + shutil.rmtree(os.path.abspath("build/"), ignore_errors=True) + for dirname, subdirList, fileList in os.walk(os.path.abspath("bemani/")): + for filename in fileList: + if filename[-3:] == ".so": + fullname = os.path.join(dirname, filename) + print(f"Removing {fullname}") + os.remove(fullname) + + setup( name='bemani', version='1.0', @@ -170,6 +193,9 @@ setup( # remove the ext_modules line and run setuptools again. Everything should work, but # it will run slower. ext_modules=extensions(), + cmdclass={ + 'clean_ext': CleanExtCommand, + }, include_package_data=True, zip_safe=False, )