Skip to content

Commit

Permalink
Merge pull request avocado-framework#3184 from ana/makefile_setup.py_…
Browse files Browse the repository at this point in the history
…update

Fix default target in Makefile and add custom command clean to setup.py
  • Loading branch information
chunfuwen authored Aug 24, 2021
2 parents 9c2bc11 + 8d4c91b commit 3cbaf9b
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 -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 3cbaf9b

Please sign in to comment.