forked from learningequality/kolibri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
285 lines (240 loc) · 11.4 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
# List most target names as 'PHONY' to prevent Make from thinking it will be creating a file of the same name
.PHONY: help clean clean-assets clean-build clean-pyc clean-docs lint test test-all assets coverage docs release test-namespaced-packages staticdeps staticdeps-cext writeversion buildconfig pex i18n-extract-frontend i18n-extract-backend i18n-extract i18n-django-compilemessages i18n-upload i18n-pretranslate i18n-pretranslate-approve-all i18n-download i18n-regenerate-fonts i18n-stats i18n-install-font docker-clean docker-whl docker-deb docker-deb-test docker-windows docker-demoserver docker-devserver
help:
@echo "Usage:"
@echo ""
@echo "make <command>"
@echo ""
@echo "Building"
@echo "--------"
@echo ""
@echo "dist: create distributed source packages in dist/"
@echo "pex: builds a portable .pex file for each .whl in dist/"
@echo "assets: builds javascript assets"
@echo "staticdeps: downloads/updates all static Python dependencies bundled into the dist"
@echo "staticdeps-cext: downloads/updates Python C extensions for all supported platforms"
@echo "clean: restores code tree to a clean state"
@echo "clean-build: remove build artifacts"
@echo "clean-pyc: remove Python file artifacts"
@echo "clean-assets: removes JavaScript build assets"
@echo "writeversion: updates the kolibri/VERSION file"
@echo "release: package and upload a release"
@echo "buildconfig: [unsupported] runs a special script for building a source package with special requirements.txt"
@echo ""
@echo "Development"
@echo "-----------"
@echo ""
@echo "lint: check Python style with flake8"
@echo "test: run tests quickly with the default Python"
@echo "test-all: run tests on every Python version with Tox"
@echo "test-namespaced-packages: verify that we haven't fetched anything namespaced into kolibri/dist"
@echo "coverage: run tests, recording and printing out Python code coverage"
@echo "docs: generate developer documentation"
@echo ""
@echo "Internationalization"
@echo "--------------------"
@echo ""
@echo "i18n-extract: extract all strings from application (both front- and back-end)"
@echo "i18n-upload branch=<crowdin-branch>: upload sources to Crowdin"
@echo "i18n-pretranslate branch=<crowdin-branch>: pretranslate on Crowdin"
@echo "i18n-pretranslate-approve branch=<crowdin-branch>: pretranslate and pre-approve on Crowdin"
@echo "i18n-download branch=<crowdin-branch>: download strings from Crowdin"
@echo "i18n-download-source-fonts: retrieve source Google Noto fonts"
@echo "i18n-regenerate-fonts: regenerate font files"
@echo "i18n-update branch=<crowdin-branch>: i18n-download + i18n-regenerate-fonts"
@echo "i18n-stats branch=<crowdin-branch>: output information about translation status"
@echo "i18n-django-compilemessages: compiles .po files to .mo files for Django"
@echo "i18n-install-font name=<noto-font>: Downloads and installs a new or updated font"
clean: clean-build clean-pyc clean-assets
clean-assets:
yarn run clean
clean-build:
rm -f kolibri/VERSION
rm -fr build/
rm -fr dist/
rm -fr dist-packages-cache/
rm -fr dist-packages-temp/
rm -fr *.egg-info
rm -fr .eggs
rm -fr .cache
rm -f SQLITE_MAX_VARIABLE_NUMBER.cache
rm -fr kolibri/dist/* || true # remove everything
git checkout -- kolibri/dist # restore __init__.py
rm -r kolibri/utils/build_config/* || true # remove everything
git checkout -- kolibri/utils/build_config # restore __init__.py
rm -r requirements.txt || true # remove requirements.txt
git checkout -- requirements.txt # restore requirements.txt
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
clean-docs:
$(MAKE) -C docs clean
lint:
flake8 kolibri
test:
pytest
test-all:
tox
assets:
yarn install
yarn run build
coverage:
coverage run --source kolibri setup.py test
coverage report -m
docs: clean-docs
$(MAKE) -C docs html
release:
@ls -l dist/
@echo "Release process documentation:"
@echo ""
@echo "http://kolibri-dev.readthedocs.io/en/develop/references/release_process.html"
@echo ""
@echo ""
@echo "Quick check list:"
@echo ""
@echo "1. Release notes?"
@echo "2. Downloaded CrowdIn translations?"
@echo "3. Pushed CrowdIn translations to repo?"
@echo "4. Version info as tag and in kolibri.VERSION?"
@echo "5. Did you do a signed commit and push to Github?"
@echo "6. Check that the .whl and .tar.gz dists work?"
@echo ""
@echo "Do you want to upload everything in dist/*?"
@echo ""
@echo "CTRL+C to exit. ENTER to continue."
@read __
twine upload -s dist/*
test-namespaced-packages:
# This expression checks that everything in kolibri/dist has an __init__.py
# To prevent namespaced packages from suddenly showing up
# https://github.com/learningequality/kolibri/pull/2972
! find kolibri/dist -mindepth 1 -maxdepth 1 -type d -not -name __pycache__ -not -name cext -not -name py2only -exec ls {}/__init__.py \; 2>&1 | grep "No such file"
staticdeps:
test "${SKIP_PY_CHECK}" = "1" || python --version 2>&1 | grep -q 2.7 || ( echo "Only intended to run on Python 2.7" && exit 1 )
rm -rf kolibri/dist/* || true # remove everything
git checkout -- kolibri/dist # restore __init__.py
pip install -t kolibri/dist -r "requirements.txt"
rm -rf kolibri/dist/*.dist-info # pip installs from PyPI will complain if we have more than one dist-info directory.
rm -r kolibri/dist/man kolibri/dist/bin || true # remove the two folders introduced by pip 10
# Remove unnecessary python2-syntax'ed file
# https://github.com/learningequality/kolibri/issues/3152
rm -f kolibri/dist/kolibri_exercise_perseus_plugin/static/mathjax/kathjax.py
python build_tools/py2only.py # move `future` and `futures` packages to `kolibri/dist/py2only`
make test-namespaced-packages
staticdeps-cext:
rm -rf kolibri/dist/cext || true # remove everything
python build_tools/install_cexts.py --file "requirements/cext.txt" # pip install c extensions
pip install -t kolibri/dist/cext -r "requirements/cext_noarch.txt" --no-deps
rm -rf kolibri/dist/*.dist-info # pip installs from PyPI will complain if we have more than one dist-info directory.
rm -rf kolibri/dist/cext/*.dist-info # pip installs from PyPI will complain if we have more than one dist-info directory.
make test-namespaced-packages
writeversion:
python -c "import kolibri; print(kolibri.__version__)" > kolibri/VERSION
@echo ""
@echo "Current version is now `cat kolibri/VERSION`"
buildconfig:
rm -r requirements.txt || true # remove requirements.txt
git checkout -- requirements.txt # restore requirements.txt
python build_tools/customize_requirements.py
rm -r kolibri/utils/build_config/* || true # remove everything
git checkout -- kolibri/utils/build_config # restore __init__.py
python build_tools/customize_build.py
dist: writeversion staticdeps staticdeps-cext buildconfig i18n-extract-frontend assets i18n-django-compilemessages
python setup.py sdist --format=gztar --static > /dev/null # silence the sdist output! Too noisy!
python setup.py bdist_wheel --static
ls -l dist
pex: writeversion
ls dist/*.whl | while read whlfile; do pex $$whlfile --disable-cache -o dist/kolibri-`cat kolibri/VERSION | sed 's/+/_/g'`.pex -m kolibri --python-shebang=/usr/bin/python; done
i18n-extract-backend:
python -m kolibri manage makemessages -- -l en --ignore 'node_modules/*' --ignore 'kolibri/dist/*'
i18n-extract-frontend:
yarn run makemessages
i18n-extract: i18n-extract-frontend i18n-extract-backend
i18n-django-compilemessages:
# Change working directory to kolibri/ such that compilemessages
# finds only the .po files nested there.
cd kolibri && PYTHONPATH="..:$$PYTHONPATH" python -m kolibri manage compilemessages
i18n-upload: i18n-extract
python build_tools/i18n/crowdin.py upload-sources ${branch}
python build_tools/i18n/crowdin.py upload-translations ${branch}
i18n-pretranslate:
python build_tools/i18n/crowdin.py pretranslate ${branch}
i18n-pretranslate-approve-all:
python build_tools/i18n/crowdin.py pretranslate ${branch} --approve-all
i18n-download:
python build_tools/i18n/crowdin.py rebuild ${branch}
python build_tools/i18n/crowdin.py download ${branch}
node build_tools/i18n/intl_code_gen.js
$(MAKE) i18n-django-compilemessages
i18n-download-source-fonts:
python build_tools/i18n/fonts.py download-source-fonts
i18n-regenerate-fonts:
python build_tools/i18n/fonts.py generate-full-fonts
python build_tools/i18n/fonts.py generate-subset-fonts
i18n-update: i18n-download i18n-regenerate-fonts
i18n-stats:
python build_tools/i18n/crowdin.py stats ${branch}
i18n-install-font:
python build_tools/i18n/fonts.py add-source-font ${name}
docker-clean:
docker container prune -f
docker image prune -f
docker-whl: writeversion
docker image build -t "learningequality/kolibri-whl" -f docker/build_whl.dockerfile .
docker run \
--env-file ./docker/env.list \
-v $$PWD/dist:/kolibridist \
-v yarn_cache:/yarn_cache \
"learningequality/kolibri-whl"
docker-deb: writeversion
@echo "\n !! This assumes you have run 'make dockerenvdist' or 'make dist' !!\n"
docker image build -t "learningequality/kolibri-deb" -f docker/build_debian.dockerfile .
export KOLIBRI_VERSION=$$(cat kolibri/VERSION) && \
docker run --env-file ./docker/env.list -v $$PWD/dist:/kolibridist "learningequality/kolibri-deb"
docker-deb-test:
@echo "\n !! This assumes that there are *.deb files in dist/ for testing !!\n"
# docker image build -t "learningequality/kolibri-deb-test-trusty" -f docker/test_trusty.dockerfile .
# docker run --env-file ./docker/env.list -v $$PWD/dist:/kolibridist "learningequality/kolibri-deb-test-trusty"
docker image build -t "learningequality/kolibri-deb-test-xenial" -f docker/test_xenial.dockerfile .
docker run --env-file ./docker/env.list -v $$PWD/dist:/kolibridist "learningequality/kolibri-deb-test-xenial"
docker image build -t "learningequality/kolibri-deb-test-bionic" -f docker/test_bionic.dockerfile .
docker run --env-file ./docker/env.list -v $$PWD/dist:/kolibridist "learningequality/kolibri-deb-test-bionic"
docker-windows: writeversion
@echo "\n !! This assumes you have run 'make dockerenvdist' or 'make dist' !!\n"
docker image build -t "learningequality/kolibri-windows" -f docker/build_windows.dockerfile .
export KOLIBRI_VERSION=$$(cat kolibri/VERSION) && \
docker run --env-file ./docker/env.list -v $$PWD/dist:/kolibridist "learningequality/kolibri-windows"
docker-build-base: writeversion
docker image build . \
-f docker/base.dockerfile \
-t "learningequality/kolibribase"
docker-demoserver:
# Build the demoserver image
docker image build \
-f docker/demoserver.dockerfile \
-t "learningequality/demoserver" .
docker run --init \
-v $$PWD/docker/mnt:/docker/mnt \
-p 8080:8080 \
--env-file ./docker/env.list \
--env KOLIBRI_PEX_URL="default" \
--env KOLIBRI_CHANNELS_TO_IMPORT="7765d6aeabc35de790f8bc4532aeb529" \
"learningequality/demoserver"
echo "Check http://localhost:8080 you should have a demoserver running there."
docker-devserver:
# Build the kolibridev image: contains source code + pip install -e of kolibri
docker image build \
-f docker/dev.dockerfile \
-t "learningequality/kolibridev" .
docker run --init \
-v $$PWD/docker/mnt:/docker/mnt \
-p 8000:8000 \
-p 3000:3000 \
--env-file ./docker/env.list \
"learningequality/kolibridev" \
yarn run devserver
echo "Check http://localhost:8000 you should have devserver running there."
# Optionally add --env KOLIBRI_PROVISIONDEVICE_FACILITY="Dev Server" to skip setup wizard
# TODO: figure out how to add source code as "volume" so can live-edit,
# e.g. -v $$PWD/kolibri:/kolibri/kolibri ??