-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
83 lines (64 loc) · 2.47 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# basic:
SHELL:=$(shell which bash)
PROJECT_NAME=PyConjugateGradients
PWD:=$(shell pwd)
PYTHONPATH=$(PWD)
TEST_DIR=tests/
VENV=venv/bin
PIP=$(VENV)/pip3
PIP_FLAGS=--trusted-host=http://pypi.python.org/simple/
PYTEST=$(VENV)/py.test
PYLINT=$(VENV)/pylint
COVERAGE=$(VENV)/coverage
MYPY=$(VENV)/mypy
MYPYFLAGS=--ignore-missing-imports --follow-imports=skip
HOST_PYTHON_VER:=$(shell which python3)
CONDA_VENV_NAME=$(PROJECT_NAME)
CONDA_ROOT=/home/anaconda3
CONDA_PYTHON=$(CONDA_ROOT)/bin/python3.5
CONDA_PYLINT=$(CONDA_ROOT)/bin/pylint
CONDA_COVERAGE=coverage
CONDA_PYTEST=py.test
CONDA_MYPY=mypy
.PHONY: all venv clean test test_pytest test_gen_coverage_rep test_pylint test_mypy git-status commit-id
all: venv test clean
conda:
$(CONDA_ROOT)/bin/conda create --name $(CONDA_VENV_NAME)
$(CONDA_ROOT)/bin/conda install --name $(CONDA_VENV_NAME) pip
@echo anaconda virtual env create, perform calls:
@echo source $(CONDA_ROOT)/bin/activate $(CONDA_VENV_NAME)
@echo pip install -Ur requirements.txt
conda_remove:
$(CONDA_ROOT)/bin/conda remove --name $(PROJECT_NAME) --all
venv: venv/bin/activate
venv/bin/activate: requirements.txt
test -d venv || virtualenv -p $(HOST_PYTHON_VER) venv
$(PIP) $(PIP_FLAGS) install -Ur requirements.txt
touch venv/bin/activate
test_pytest:
PYTHONPATH=$(PYTHONPATH) $(PYTEST) --verbose --color=yes --cov=$(PROJECT_NAME) --cov-report html --cov-config .coveragerc --tb=short $(TEST_DIR)
test_pylint:
find $(PROJECT_NAME) -name '*.py' | xargs $(PYLINT) --rcfile=$(PWD)/.pylintrc
test_gen_coverage_rep:
$(COVERAGE) report
test_mypy:
find $(PROJECT_NAME) -name '*.py' | xargs $(MYPY) $(MYPYFLAGS)
conda_test_pytest:
PYTHONPATH=$(PYTHONPATH) $(CONDA_PYTEST) --verbose --color=yes --cov=$(PROJECT_NAME) --cov-report html --cov-config .coveragerc --tb=short $(TEST_DIR)
conda_test_pylint:
find $(PROJECT_NAME) -name '*.py' | xargs $(CONDA_PYLINT) --rcfile=$(PWD)/.pylintrc
conda_test_gen_coverage_rep:
$(CONDA_COVERAGE) report
conda_test_mypy:
find $(PROJECT_NAME) -name '*.py' | xargs $(CONDA_MYPY) $(MYPYFLAGS)
conda_test: conda_test_pylint conda_test_mypy conda_test_pytest conda_test_gen_coverage_rep clean
test: test_pylint test_mypy test_pytest test_gen_coverage_rep
clean:
rm -rf htmlcov
rm -rf .coverage
rm -rf .cache
rm -rf .mypy_cache
find -name '$(PROJECT_NAME).log' | xargs rm -rf
find $(PROJECT_NAME) -name '*.pyc' | xargs rm -rf
find $(PROJECT_NAME) -name '__pycache__' -type d | xargs rm -rf
find $(TEST_DIR) -name '__pycache__' -type d | xargs rm -rf