-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
63 lines (50 loc) · 1.65 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
# System binaries
SYSTEM_PIP=$(shell which pip3)
SYSTEM_PYTHON=$(shell which python3)
SYSTEM_VIRTUALENV=$(shell which virtualenv)
# Project binaries
PYTHON=$(ENV_DIR)/bin/python3
PYLINT=$(ENV_DIR)/bin/pylint
PIP=$(ENV_DIR)/bin/pip3
COVERAGE_PY=$(ENV_DIR)/bin/coverage
# Directories
SRC_DIR=./src
LIB_DIR=./lib
TEST_DIR=./test
DIST_DIR=./dist
ENV_DIR=$(LIB_DIR)/env
# Flags
TEST_FILES=test_*.py
REQUIREMENTS=$(LIB_DIR)/requirements.txt
PYLINT_CONFIG=$(TEST_DIR)/pylint.rc
MODULES=$(SRC_DIR):$(TEST_DIR)
# Distribution
MAIN_FILE=$(SRC_DIR)/main.py
OUTFILE=$(DIST_DIR)/stenograpi.py
IGNORE_IMPORTS=grep -v 'from \(\.\|incoming\|stenograpi\)'
SOURCE_FILES=$(shell find src -name "*.py" -and -not -name "main.py")
# Environment variables
export PYTHONPATH=$(MODULES)
export PYTHONWARNINGS=ignore
export PYTHONDONTWRITEBYTECODE=true
dist: combine-to-one-script
install: pip-install
test: unit-test
lint: pylint
coverage: coverage-py
combine-to-one-script: $(SOURCE_FILES)
-@[ -e $(OUTFILE) ] && rm $(OUTFILE);
@for SOURCE_FILE in $(SOURCE_FILES); do cat $$SOURCE_FILE | $(IGNORE_IMPORTS) >> $(OUTFILE); done;
@cat $(MAIN_FILE) | $(IGNORE_IMPORTS) >> $(OUTFILE);
virtualenv-install:
$(SYSTEM_PIP) install virtualenv
$(SYSTEM_VIRTUALENV) -p $(SYSTEM_PYTHON) --no-site-packages $(ENV_DIR)
pip-install: virtualenv-install
@$(PYTHON) $(PIP) install -r $(REQUIREMENTS)
unit-test:
@$(PYTHON) -m unittest discover -s $(TEST_DIR) -p $(TEST_FILES)
pylint:
@$(PYTHON) $(PYLINT) --rcfile $(PYLINT_CONFIG) $(SRC_DIR)/* $(TEST_DIR)
coverage-py:
@$(PYTHON) $(COVERAGE_PY) run --source=$(SRC_DIR) -m unittest discover -s $(TEST_DIR) -p $(TEST_FILES)
.PHONY: dist install test lint coverage