forked from symphonyoss/python-symphony
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (60 loc) · 2.07 KB
/
Makefile
File metadata and controls
72 lines (60 loc) · 2.07 KB
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))))
# 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 -rf build
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
$(SUBDIRS): venv
# run code_quality tests
# tox
# build the python app
cd $(@); $(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\/$(shell basename $(CURDIR))\/bin\/"\n\
directory_env="\/opt\/$(shell basename $(CURDIR)))\/"\n\
VIRTUAL_ENV="\/opt\/$(shell basename $(CURDIR))\/venv\/"\n/' venv/bin/activate
# set the app version var
$(eval APP_VERSION := $(shell cat $(@)/setup.py | grep version | cut -d \' -f2 ))
# build RPM
fpm -s dir -t rpm --rpm-os linux --name symphony-es-$(shell basename $(CURDIR)) --version $(APP_VERSION) --iteration 1 --after-install ./post-install/run.sh --rpm-auto-add-directories --description "$(shell basename $(CURDIR))" ./venv/=/opt/$(shell basename $(CURDIR))/venv/ ./post-install/=/opt/$(shell basename $(CURDIR))/post-install/
# 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