-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
90 lines (72 loc) · 2.19 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
84
85
86
87
88
89
90
# -*- coding: utf-8; mode: makefile-gmake -*-
.DEFAULT = help
TEST ?= .
# python version to use
PY ?=3
# list of python packages (folders) or modules (files) of this build
PYOBJECTS = tokenlib
# folder where the python distribution takes place
PYDIST ?= dist
# folder where the python intermediate build files take place
PYBUILD ?= build
SYSTEMPYTHON = `which python$(PY) python | head -n 1`
VIRTUALENV = virtualenv --python=$(SYSTEMPYTHON)
VENV_OPTS = "--no-site-packages"
TEST_FOLDER = ./tokenlib/tests
ENV = ./local/py$(PY)
ENV_BIN = $(ENV)/bin
PHONY += help
help::
@echo 'usage:'
@echo
@echo ' build - build virtualenv ($(ENV)) and install *developer mode*'
@echo ' lint - run pylint within "build" (developer mode)'
@echo ' test - run tests for all supported environments (tox)'
@echo ' dist - build packages in "$(PYDIST)/"'
@echo ' publish - upload "$(PYDIST)/*" files to PyPi'
@echo ' clean - remove most generated files'
@echo
@echo 'options:'
@echo
@echo ' PY=3 - python version to use (default 3)'
@echo ' TEST=. - choose test from $(TEST_FOLDER) (default "." runs all)'
@echo
@echo 'Example; a clean and fresh build (in local/py3), run all tests (py27, py35, lint)::'
@echo
@echo ' make clean build test'
@echo
PHONY += build
build: $(ENV)
$(ENV_BIN)/pip -v install -e .
PHONY += lint
lint: $(ENV)
$(ENV_BIN)/pylint $(PYOBJECTS) --rcfile ./.pylintrc
PHONY += test
test: $(ENV)
$(ENV_BIN)/tox -vv
$(ENV):
$(VIRTUALENV) $(VENV_OPTS) $(ENV)
$(ENV_BIN)/pip install -r requirements.txt
# for distribution, use python from virtualenv
PHONY += dist
dist: clean-dist $(ENV)
$(ENV_BIN)/python setup.py \
sdist -d $(PYDIST) \
bdist_wheel --bdist-dir $(PYBUILD) -d $(PYDIST)
PHONY += publish
publish: dist
$(ENV_BIN)/twine upload $(PYDIST)/*
PHONY += clean-dist
clean-dist:
rm -rf ./$(PYBUILD) ./$(PYDIST)
PHONY += clean
clean: clean-dist
rm -rf ./local ./.cache
rm -rf *.egg-info .coverage
rm -rf .eggs .tox html
find . -name '*~' -exec echo rm -f {} +
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name __pycache__ -exec rm -rf {} +
# END of Makefile
.PHONY: $(PHONY)