From 8f8089b22f17044a16890c180a358a067fa1a437 Mon Sep 17 00:00:00 2001 From: Prodesire Date: Sat, 16 Dec 2017 01:21:15 +0800 Subject: [PATCH] add makefile which can help test and clean easily with make command --- makefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 makefile diff --git a/makefile b/makefile new file mode 100644 index 0000000..b132e85 --- /dev/null +++ b/makefile @@ -0,0 +1,45 @@ +# Env +export PYTHONDONTWRITEBYTECODE=1 +TEST_PATH=./tests +DEFAULT_PYTHON2=`python -c "import sys;print(sys.version_info.major)" | grep 2` +PY2=$(if $(DEFAULT_PYTHON2),python,python2) +PY3=$(if $(DEFAULT_PYTHON2),python3,python) + +# Func +.PHONY: clean-pyc clean-build + +help: + @echo $(PYVER) + @echo "test" + @echo " Run pytest with Python 2 and 3." + @echo "test-py2" + @echo " Run pytest with Python 2." + @echo "test-py3" + @echo " Run pytest with Python 3." + @echo "clean" + @echo " Remove python and build artifacts." + @echo "clean-pyc" + @echo " Remove python artifacts." + @echo "clean-build" + @echo " Remove build artifacts." + +test: test-py2 test-py3 + +test-py2: clean-pyc + $(PY2) -m pytest --color=yes $(TEST_PATH) + +test-py3: clean-pyc + $(PY3) -m pytest --color=yes $(TEST_PATH) + +clean: clean-pyc clean-build + +clean-pyc: + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -rf {} + + +clean-build: + rm -rf build/ + rm -rf dist/ + rm -rf *.egg-info