-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
72 lines (61 loc) · 1.88 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
# set shell to bash
SHELL = bash
# figure out absolute path of source repo
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
testoutput:
echo -e '$(ROOT_DIR)'
# gather uname info
UNAME := $(shell uname)
# set python interpreter to venv
PYTHON='$(ROOT_DIR)/venv/bin/python'
# gather sub directory list
SUBDIRS:=${shell find ./ -type d -print | grep -v venv }
.PHONY: subdirs $(SUBDIRS)
# helpful debug sequence
print-% : ; @echo $* = $($*)
subdirs: $(SUBDIRS)
# instantiate VENV
venv: venv/bin/activate
venv/bin/activate: requirements.txt
test -d venv || virtualenv venv
venv/bin/pip install -Ur requirements.txt
touch venv/bin/activate
.PHONY: clean destroyvenv
# remove venv
destroyvenv:
rm -rf venv
# clean repo of build files
clean: destroyvenv
rm -rf build
rm -rf dist
rm -rf *.egg-info
rm -rf .tox
rm -rf tests/.tox
rm -f code_quality.html
rm -f pylint_report.txt
rm -f nosetests.xml
unset APP_VERSION
# only build on Linux
ifeq ($(UNAME), Linux)
# build specific subdir
rpm: venv
# run code_quality tests
# ./tests/code_quality.sh $(@)
# build the python app
$(PYTHON) setup.py install --verbose
# set the venv relocatable / helps with portability
virtualenv --relocatable $(ROOT_DIR)/venv
# change activate path to /opt path
sed -i -e 's/^VIRTUAL_ENV.*/directory_bin="\/opt\/$(@)\/bin\/"\n\
directory_env="\/opt\/resume\/"\n\
VIRTUAL_ENV="\/opt\/resume\/venv\/"\n/' venv/bin/activate
# set the app version var
$(eval APP_VERSION := $(shell cat $(ROOT_DIR)/setup.py | grep version | cut -d \' -f2 ))
# build RPM
fpm -s dir -t rpm --rpm-os linux --name mattjoyce-resume --version $(APP_VERSION) --iteration 1 --rpm-auto-add-directories --description "matt joyce resume" ./venv/=/opt/resume/venv/
# put the rpm in a build dir
test -d $(ROOT_DIR)/build || mkdir $(ROOT_DIR)/build
mv *.rpm build/
# remove the venv we built in
rm -rf $(ROOT_DIR)/venv
endif