forked from Telefonica/toolium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
131 lines (112 loc) · 4.29 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
APP = toolium
VERSION ?= $(shell cat VERSION)
RELEASE ?= $(shell git log --pretty=oneline | wc -l | tr -d ' ')
ARCH = noarch
PACKAGE = $(APP)-$(VERSION)-$(RELEASE).$(ARCH).rpm
ROOT = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
MKD2PDF ?= $(shell which markdown-pdf)
VIRTUALENV ?= virtualenv
TEST = tests
SPHINXBUILD = sphinx-build
SPHINXSOURCEDIR = docs
SPHINXBUILDDIR = docs/build
ifeq ($(OS),Windows_NT)
BIN = Scripts
LIB = Lib
TGZ_EXT = zip
PYTHON ?= $(shell which python).exe
PYTHON_EXE ?= $(shell where python | head -n1)
else
BIN = bin
LIB = lib/python2.7
TGZ_EXT = tar.gz
PYTHON ?= $(shell which python2.7)
PYTHON_EXE = python2.7
endif
TMP=$(ROOT)/tmp
VENV_PREFIX = $(TMP)/.venv
VENV = $(VENV_PREFIX)/$(APP)
REQ = requirements.txt
TESTREQ = requirements_dev.txt
COVERAGE_ARGS=--with-coverage --cover-erase --cover-package=$(APP) \
--cover-branches --cover-xml \
--cover-xml-file=$(ROOT)/dist/coverage.xml
all: default
default:
@echo
@echo "Welcome to '$(APP)' software package:"
@echo
@echo "usage: make <command>"
@echo
@echo "commands:"
@echo " clean - Remove generated files and directories"
@echo " venv - Create and update virtual environments"
@echo " install - Install application"
@echo " sdist - Build a tar.gz software distribution of the package"
# @echo " rpm - Create $(PACKAGE) rpm"
@echo " egg - Create python egg"
@echo " unittest - Execute unit tests"
@echo " doc - Build sphinx documentation"
@echo " coverage - Execute unittests and code coverage"
@echo
init:
mkdir -p $(ROOT)/dist
# mkdir -p $(TMP)/rpmbuild/SOURCES
# mkdir -p $(TMP)/rpmbuild/BUILD
# mkdir -p $(TMP)/rpmbuild/RPMS
sdist: init venv
@echo ">>> Creating source distribution..."
$(VENV)/$(BIN)/python setup.py sdist
@echo ">>> OK. TGZ generated in $(ROOT)/dist"
@echo
disabled-rpm: init sdist
@echo ">>> Creating RPM package..."
cp $(ROOT)/dist/$(APP)-$(VERSION).${TGZ_EXT} $(TMP)/rpmbuild/SOURCES
rpmbuild -bb $(APP).spec \
--define "version $(VERSION)" \
--define "release $(RELEASE)" \
--define "arch $(ARCH)" \
--define "_target_os linux" \
--define "_topdir $(TMP)/rpmbuild" \
--define "buildroot $(TMP)/rpmbuild/BUILDROOT" \
--define "__python $(PYTHON)" \
--define "python_sitelib $(VENV)/$(LIB)/site-packages" \
--define "_sysconfdir /etc" \
--define "_bindir /usr/bin" \
--nodeps \
--buildroot=$(TMP)/rpmbuild/BUILDROOT
cp $(TMP)/rpmbuild/RPMS/$(ARCH)/$(PACKAGE) $(ROOT)/dist
@echo ">>> OK. RPM generated in $(ROOT)/dist"
@echo
venv: $(VENV)
$(VENV): $(REQ) $(TESTREQ)
mkdir -p $@; \
export GIT_SSL_NO_VERIFY=true; \
$(VIRTUALENV) --no-site-packages --distribute -p $(PYTHON) $@; \
$@/$(BIN)/pip install --upgrade -r $(REQ); \
$@/$(BIN)/pip install --upgrade -r $(TESTREQ); \
unittest: init venv
$(VENV)/$(BIN)/py.test toolium/test
coverage: init venv
$(VENV)/$(BIN)/nosetests $(COVERAGE_ARGS) $(UNIT_TEST_ARGS)
@echo ">>> OK. Coverage reports generated in $(ROOT)/dist"
# Just for development purposes. It uses your active python2.7
# Remember to update your requirements if needed
egg:
$(PYTHON_EXE) setup.py bdist_egg
# Just for development purposes. It uses your active python2.7
# Remember to update your requirements if needed
install:
$(PYTHON_EXE) setup.py install
doc: venv
@echo ">>> Cleaning sphinx doc files..."
rm -rf $(SPHINXBUILDDIR)/html
@echo ">>> Generating doc files..."
$(VENV)/$(BIN)/$(SPHINXBUILD) -b html $(SPHINXSOURCEDIR) $(SPHINXBUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(SPHINXBUILDDIR)/html."
clean:
@echo ">>> Cleaning temporal files..."
rm -rf $(TMP) dist/ *.egg-info/ build/
@echo
.PHONY: all clean venv install sdist egg unittest doc coverage