Skip to content

Commit

Permalink
setup.py: add custom command clean and fix default target
Browse files Browse the repository at this point in the history
Remove steps from the Makefile that are already made by the custom
clean command.
Move the include line below, otherwise 'make' will run the
clean target by default.

Signed-off-by: Ana Guerrero Lopez <[email protected]>
  • Loading branch information
ana committed Aug 18, 2021
1 parent efea7a0 commit 8d4c91b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ MOCK_CONFIG=default
ARCHIVE_BASE_NAME=avocado-vt
RPM_BASE_NAME=avocado-plugins-vt

include Makefile.include

all:
@echo
Expand All @@ -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 "pip>=6.0.1"
- $(PYTHON) -m pip install -r requirements.txt
Expand All @@ -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)
Expand Down
29 changes: 28 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,37 @@
# Author: Lucas Meneghel Rodrigues <[email protected]>

# 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
Expand Down Expand Up @@ -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},
)

0 comments on commit 8d4c91b

Please sign in to comment.