diff --git a/Makefile b/Makefile index cf5d857278..3ef2814c50 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,6 @@ MOCK_CONFIG=default ARCHIVE_BASE_NAME=avocado-vt RPM_BASE_NAME=avocado-plugins-vt -include Makefile.include all: @echo @@ -41,6 +40,8 @@ all: @echo "rpm-release: Generate binary RPMs for the latest tagged release" @echo +include Makefile.include + requirements: pip - $(PYTHON) -m pip install -r requirements.txt @@ -50,8 +51,6 @@ check: clean: $(PYTHON) setup.py clean - rm -rf build/ MANIFEST BUILD BUILDROOT SPECS RPMS SRPMS SOURCES PYPI_UPLOAD - find . -name '*.pyc' -delete develop: $(PYTHON) setup.py develop $(PYTHON_DEVELOP_ARGS) diff --git a/setup.py b/setup.py index 184f85de86..adadd87f08 100644 --- a/setup.py +++ b/setup.py @@ -13,11 +13,37 @@ # Author: Lucas Meneghel Rodrigues # pylint: disable=E0611 +import os +import shutil +from distutils.command.clean import clean +from pathlib import Path from setuptools import setup, find_packages VERSION = open('VERSION', 'r').read().strip() +class Clean(clean): + """Our custom command to get rid of scratch files after build.""" + + description = "Get rid of scratch, byte files and build stuff." + + def run(self): + super().run() + cleaning_list = ["MANIFEST", "BUILD", "BUILDROOT", "SPECS", + "RPMS", "SRPMS", "SOURCES", "PYPI_UPLOAD", "./build"] + + cleaning_list += list(Path('.').rglob("*.pyc")) + cleaning_list += list(Path('.').rglob("__pycache__")) + + for e in cleaning_list: + if not os.path.exists(e): + continue + if os.path.isfile(e): + os.remove(e) + if os.path.isdir(e): + shutil.rmtree(e) + + def pre_post_plugin_type(): try: from avocado.core.plugin_interfaces import JobPreTests as Pre @@ -68,5 +94,6 @@ def pre_post_plugin_type(): ], }, install_requires=["netifaces", "simplejson", "six", "netaddr", - "aexpect", "avocado-framework>=68.0"] + "aexpect", "avocado-framework>=68.0"], + cmdclass={'clean': Clean}, )