forked from Weasyl/weasyl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (113 loc) · 3.13 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Weasyl makefile
#
# Variables
#
# Virtual environment directory
VE ?= weasyl-env
# Whether to install from wheels
# Build specific binaries from source, where binaries have been problematic in the past
USE_WHEEL := --no-binary sanpera,lxml,psycopg2cffi
# Static directories
STATIC_DIRS := character fonts journal submission tile user media
# Temp directories
TEMP_DIRS := temp save log
# Mangle up some variables
STATIC_DIRS := $(addprefix static/,$(STATIC_DIRS))
# The endpoint to serve web requests on
WEB_ENDPOINT := tcp:8880:interface=127.0.0.1
#
# Rules
#
# Catch-all
.PHONY: all
all: setup
# Site config
config/site.config.txt:
cp -n config/site.config.txt.example $@
# Staff
config/weasyl-staff.py:
cp -n config/weasyl-staff.example.py $@
# Creates python environment
$(VE): etc/requirements.txt
test -e $@ || { virtualenv $@; \
$@/bin/pip install -U pip setuptools; }
$@/bin/pip install $(USE_WHEEL) -r etc/requirements.txt -e .
$@/bin/pip install $(USE_WHEEL) pytest==4.6.5 flake8
touch $@
.PHONY: install-libweasyl
install-libweasyl: $(VE)
$(VE)/bin/pip install $(USE_WHEEL) -Ue libweasyl
.PHONY: guest-install-libweasyl
guest-install-libweasyl: .vagrant
vagrant ssh -c 'cd weasyl && make install-libweasyl'
.vagrant:
vagrant plugin install vagrant-vbguest
vagrant up
.PHONY: setup-vagrant
setup-vagrant: .vagrant
.PHONY: upgrade-db
upgrade-db:
cd libweasyl && make upgrade-db
.PHONY: guest-upgrade-db
guest-upgrade-db: .vagrant
vagrant ssh -c 'cd weasyl && make upgrade-db'
# Static directories
$(STATIC_DIRS):
mkdir -p $@
# Temp directories
$(TEMP_DIRS):
mkdir -p $@
node_modules: package.json
npm install
touch node_modules
build/rev-manifest.json: node_modules
node build.js
# Phony setup target
.PHONY: setup
setup: $(VE) config/site.config.txt config/weasyl-staff.py build/rev-manifest.json $(STATIC_DIRS) $(TEMP_DIRS)
git rev-parse --short HEAD > version.txt
# Phony deploy targets
.PHONY: deploy deploy-web-worker
deploy: setup
deploy-web-worker: setup
# Phony target to run a local server
.PHONY: run
run: setup
WEASYL_APP_ROOT=. \
WEASYL_STORAGE_ROOT=. \
WEASYL_RELOAD_TEMPLATES=y \
WEASYL_RELOAD_ASSETS=y \
WEASYL_WEB_ENDPOINT=$(WEB_ENDPOINT) \
$(VE)/bin/twistd -ny weasyl/weasyl.tac
# Phony target to run a local server inside of vagrant
.PHONY: guest-run
guest-run: .vagrant
vagrant ssh -c 'cd weasyl && make run'
# Phony target to run tests
.PHONY: test
test: setup
WEASYL_APP_ROOT=. WEASYL_STORAGE_ROOT=testing $(VE)/bin/py.test weasyl/test
# Phony target for an interactive shell
.PHONY: shell
shell: setup
WEASYL_APP_ROOT=. WEASYL_STORAGE_ROOT=. $(VE)/bin/python
# Phony target to clean directory
.PHONY: clean
clean:
find . -type f -name '*.py[co]' -delete
rm -rf build
rm -rf $(STATIC_DIRS)
rm -rf $(TEMP_DIRS)
# Dist-clean target
.PHONY: distclean
distclean: clean
rm -f etc/site.config.txt
rm -rf $(VE)
# Phony target to run flake8 pre-commit
.PHONY: check
check:
git diff HEAD | $(VE)/bin/flake8 --config setup.cfg --statistics --diff
# Phony target to run flake8 on the last commit
.PHONY: check-commit
check-commit:
git show | $(VE)/bin/flake8 --config setup.cfg --statistics --diff