-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
351 lines (267 loc) · 10.3 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# If the first argument is "run"...
# WIP...
ifeq (run,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "run"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
THIS_FILE := $(lastword $(MAKEFILE_LIST))
git_username="Charles Watkins" pip install build27
git_email="chris17453@gmail.com"
conf_dir="source/conf"
RELEASE_DIR=pypy
DDB_NAME=ddb
PYTHON=python
.DEFAULT: help
.PHONY: all test clean profile script build 24 26 27 34 36 build24 build26 build27 build34 build36
help:
@echo "[Maintenence]"
@echo " make bump | bump the package version"
@echo " make clean | delete pypi packages and cython files"
@echo " make set_git | update the git author config"
@echo " make upload | upload any build packages to pypi"
@echo " make init | init git, create base directories"
@echo "[Install]"
@echo " make install | install the latest ddb from pypi in your user directory"
@echo " make uninstall | uninstall ddb from your user directory"
@echo "[SVN]"
@echo " make svn_start | start svn docker"
@echo " make svn_stop | stop svn docker"
@echo "[Build]"
@echo " make build | build distribution package"
@echo " make meta | rebuild the meta classes from the language file"
@echo " make script | make standalone single file"
@echo " make standalone | compile into a linux single file executable"
@echo " make profile | callgraphs and profilling"
@echo "[Test]"
@echo " make test | run unit test"
@echo " make lock-test | locking test"
@echo " make watch-lock-test | watch the locking test"
@echo "[Docker]"
@echo " make build24 | build python 2.4 (cent5) distribution package"
@echo " make build26 | build python 2.6 (cent6) distribution package"
@echo " make build27 | build cython 2.7 (cent7) distribution package"
@echo " make build34 | build cython 3.4 (cent7) distribution package"
@echo " make build36 | build cython 3.6 (cent7) distribution package"
@echo " make dev24 | run a container with the python 2.4 (cent5) build"
@echo " make dev26 | run a container with the python 2.6 (cent6) build"
@echo " make dev27 | run a container with the cython 2.7 (cent7) build"
@echo " make dev34 | run a container with the cython 3.4 (cent7) build"
@echo " make dev36 | run a container with the cython 3.6 (cent7) build"
clean:
@find . -type f -name "*.c" -exec rm -f {} \;
@find . -type f -name "*.so" -exec rm -f {} \;
set_git:
@git config --global user.email $(git_email)
@git config --global user.name $(git_username)
@git commit --amend --reset-author
init: set_git
@echo dependencies for building... dnf install python-devel libyaml-devel gcc make
@if [[ ! -d 'dist' ]]; then mkdir dist ; fi
@if [[ ! -d '.git' ]]; then git init; fi
@git config --global user.email $(git_email)
@git config --global user.name $(git_username)
# bumpversion
# twine
# and other deps should be in the pipfile
@pipenv install
@ln -s source/ddb/lexer/language.py tools/language.py
#echo [bumpversion]>.bumpversion.cfg
#echo current_version = $(shell cat setup.py | grep version | grep -Po "['].*[']" | tr -d "'")>>.bumpversion.cfg
##echo files = setup.py>S>.bumpversion.cfg
##echo commit = False>>.bumpversion.cfg
#e#cho tag = False>>.bumpversion.cfg
pipfile:
pipenv install twine --dev
pipenv install ctyhon --dev
# for binary executable
pipenv install pyinstaller --dev
bump:
@./$(conf_dir)/bump.sh
@git add -A
@git commit -m 'Bump Version $(shell cat source/conf/version)'
test:
@echo "Resetting Database"
@cp test/data/MOCK_DATA_MASTER.csv test/data/MOCK_DATA.csv -f
@cp test/data/MOCK_DATA_MASTER.csv test/data/MOCK_DATA2.csv -f
@echo "Running test with $(DDB_PYTHON)"
@$(DDB_PYTHON) -m test.test
@echo "Test done"
test-single:export RELEASE_DIR = standalone
test-single:export DDB_RELEASE = standalone
test-single:export DDB_NAME = ddb
test-single:
@echo "Resetting Database"
@cp test/data/MOCK_DATA_MASTER.csv test/data/MOCK_DATA.csv -f
@cp test/data/MOCK_DATA_MASTER.csv test/data/MOCK_DATA2.csv -f
@echo "Running test with python"
@python -m test.test
@echo "Test done"
lock-test:
@cd test; python test-locking.py
watch-lock-test:
@test/watch_locks.sh
profile:
@python -m test.profile
svn_stop:
@test/svn_stop.sh
svn_start:
@test/svn_start.sh
#build: bump svn_start meta
# @find . -type f -name "*.tar.gz" -exec rm -f {} \;
## makes ansible single script
# #@python $(conf_dir)/build.py
# @cd source; python setup.py build_ext --inplace sdist --dist-dir ../builds/pypi/
# # --use-cython
# # @$(MAKE) -f $(THIS_FILE) standalone
# @$(MAKE) -f $(THIS_FILE) test
bytecode:
@python tools/generate_bytecode.py>source/ddb/lexer/bytecode.py
lexer:
@python tools/generate_bytecode.py>source/ddb/lexer/bytecode.py
@python source/ddb/lexer/lexer-2.py
# builds the docker iamges
setup-docker:
docker-compose -f source/docker/docker-compose.yml build
build:
@$(MAKE) -f $(THIS_FILE) build24
@$(MAKE) -f $(THIS_FILE) build26
@$(MAKE) -f $(THIS_FILE) build27
#@$(MAKE) -f $(THIS_FILE) build34
@$(MAKE) -f $(THIS_FILE) build36
#@$(MAKE) -f $(THIS_FILE) pypi
pyc:
@find . -type f -name "*.pyc" -exec rm -f {} \;
release: meta script
@echo "This should be ran inside of a the build containers"
@echo "USING PYTHON " $(PYTHON)
@echo "Building $(DDB_NAME) in $(RELEASE_DIR)"
@find . -type f -name "*.tar.gz" -exec rm -f {} \;
@cd source; $(PYTHON) setup.py build_ext sdist --dist-dir ../builds/$(RELEASE_DIR)/ --build-python --name=$(DDB_NAME)
# @$(MAKE) -f $(THIS_FILE) standalone
@$(MAKE) -f $(THIS_FILE) test
create-cython-package:
# create build dir if needed
@rm -rf builds/$(DDB_NAME)
@mkdir -p builds/$(DDB_NAME)/$(DDB_NAME)
# remove everything from the build dir
@cp source/setup.py builds/$(DDB_NAME)/
@cp source/README.md builds/$(DDB_NAME)/
@cp source/MANIFEST.in builds/$(DDB_NAME)/
@sed -i 's/ddb/$(DDB_NAME)/g' builds/$(DDB_NAME)/MANIFEST.in
@cd source/ddb; find . -name '*.py' | cpio -pdm ../../builds/$(DDB_NAME)/$(DDB_NAME)/
cython-release: meta create-cython-package
@echo "This should be ran inside of a the build containers"
@echo "USING PYTHON BINARY: " $(PYTHON)
@echo "Removing old release packages"
@find builds/$(RELEASE_DIR) -type f -name "*.tar.gz" -exec rm -f {} \;
@echo "Building $(DDB_NAME) in $(RELEASE_DIR)"
#@$(PYTHON) $(conf_dir)/build.py
@cd builds/$(DDB_NAME); $(PYTHON) setup.py build_ext sdist --dist-dir ../../builds/$(RELEASE_DIR)/ --build-cython --name=$(DDB_NAME)
# @$(MAKE) -f $(THIS_FILE) standalone
@$(MAKE) -f $(THIS_FILE) test
single: export DDB_RELEASE_DIR=../builds/single
single: script
@echo "START Single Buid"
@echo "Making Project Directory"
@mkdir -p builds/single/ddb
@echo "Making Release Directory"
@mkdir -p builds/$(RELEASE_DIR)
@echo "Copying files"
@cp source/setup-single.py builds/single/ -f
@cp source/README.md builds/single/ -f
@cp builds/standalone/ddb.py builds/single/ddb/ -f
@cp source/ddb/version.py builds/single/ddb/ -f
@touch builds/single/ddb/__init__.py
@echo "Removing old release packages"
@find builds/$(RELEASE_DIR) -type f -name "*.tar.gz" -exec rm -f {} \;
@echo "Running Setup"
@cd builds/single; $(PYTHON) setup-single.py build_ext sdist --dist-dir ../$(RELEASE_DIR)/ --name=$(DDB_NAME)
@echo "Done Building"
@$(MAKE) -f $(THIS_FILE) test-single
#build: meta bump cython-release
#internal docker build commands
# build python 2.4 on cent 5
24: RELEASE_DIR = release/2.4
24: DDB_NAME = ddb24python
24: PYTHON = python
24: export DDB_PYTHON=python
24: export DDB_RELEASE=2.4
24: single
# build python 2.6 on cent 6
26: RELEASE_DIR = release/2.6
26: DDB_NAME = ddb26python
26: PYTHON = python
26: export DDB_PYTHON=python
26: export DDB_RELEASE=2.6
26: single
# build python 2.7 on cent 7
27: RELEASE_DIR = release/2.7
27: DDB_NAME = ddb27cython
27: PYTHON = python
27: export DDB_PYTHON=python
27: export DDB_RELEASE=2.7
27: cython-release
# build python 3.4 on cent 7
34: RELEASE_DIR = release/3.4
34: DDB_NAME = ddb34cython
34: PYTHON = python3.4
34: export DDB_PYTHON=python3.4
34: export DDB_RELEASE=3.4
34: cython-release
# build python 3.6 on cent 7
36: RELEASE_DIR = release/3.6
36: DDB_NAME = ddb3cython
36: PYTHON = python3.6
36: export DDB_PYTHON=python3.6
36: export DDB_RELEASE=3.6
36: cython-release
#Individual docker build commands ran from host
build24:
@docker-compose -f source/docker/docker-compose.yml up ddb24
build26:
@docker-compose -f source/docker/docker-compose.yml up ddb26
build27:
@docker-compose -f source/docker/docker-compose.yml up ddb27
build34:
@docker-compose -f source/docker/docker-compose.yml up ddb34
build36:
@docker-compose -f source/docker/docker-compose.yml up ddb36
dev24:
@docker run -v $(shell pwd):/ddb -it watkinslabs/ddb24 bash
dev26:
@docker run -v $(shell pwd):/ddb -it watkinslabs/ddb26 bash
dev27:
@docker run -v $(shell pwd):/ddb -it watkinslabs/ddb27 bash
dev34:
@docker run -v $(shell pwd):/ddb -it watkinslabs/ddb34 bash
dev36:
@docker run -v $(shell pwd):/ddb -it watkinslabs/ddb36 bash
script:
@python $(conf_dir)/build.py
@sed -i "s/u'\([^']*\)*'.format(/stringer(u'\1',/g" builds/standalone/ddb.py
@sed -i 's/u"\([^"]*\)*".format(/stringer(u"\1",/g' builds/standalone/ddb.py
@sed -i "s/'\([^']*\)*'.format(/stringer('\1',/g" builds/standalone/ddb.py
@sed -i 's/"\([^"]*\)*".format(/stringer("\1",/g' builds/standalone/ddb.py
test-script:
@python builds/standalone/ddb.py
standalone:
@pyinstaller ddb.spec
upload:
#@pipenv run twine upload builds/pypi/*.gz
@pipenv run twine upload builds/release/2.4/*.gz
@pipenv run twine upload builds/release/2.6/*.gz
@pipenv run twine upload builds/release/2.7/*.gz
@pipenv run twine upload builds/release/3.4/*.gz +
@pipenv run twine upload builds/release/3.6/*.gz
install: uninstall
pip install source/. --user
install-build:
pip install builds/pypi/ddb*.gz --user
uninstall:
pip uninstall ddb -y
meta:
@python -m tools.generate_meta_class >source/ddb/meta/meta.py
big_data:
@python tools/generate_data.py>test/data/MOCK_DATA_LARGE.csv