class CleanCommand(Command):
    description = (
        'custom clean command that forcefully removes dist/build directories')
user_options = []

def initialize_options(self):
    self.cwd = None

def finalize_options(self):
    self.cwd = os.getcwd()

def run(self):
    assert os.getcwd() == self.cwd, 'Must be in package root: %s' % self.cwd
os.system('rm -rf ./build ./dist')
Custom distutils commands