-
-
Notifications
You must be signed in to change notification settings - Fork 947
Expand file tree
/
Copy pathMakefile
More file actions
293 lines (244 loc) · 11.7 KB
/
Copy pathMakefile
File metadata and controls
293 lines (244 loc) · 11.7 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
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
SHELL := /bin/bash
CROWDIN_BRANCH := release
# 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 staticdeps staticdeps-cext strip-staticdeps writeversion setrequirements buildconfig pex i18n-extract-frontend i18n-extract-backend i18n-transfer-context i18n-extract i18n-django-compilemessages i18n-upload i18n-pretranslate i18n-pretranslate-approve-all i18n-download i18n-regenerate-fonts i18n-stats i18n-install-font i18n-download-translations i18n-download-glossary i18n-upload-glossary docker-demoserver docker-devserver docker-envlist
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 "strip-staticdeps: strips debug symbols from C extensions"
@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 "setrequirements: creates a customized requirements.txt"
@echo "buildconfig: customizes the default plugins and Django settings module"
@echo ""
@echo "Development"
@echo "-----------"
@echo ""
@echo "lint: lint and format the codebase with prek hooks"
@echo "test: run tests quickly with the default Python"
@echo "test-all: run tests with the default Python (CI tests all versions)"
@echo "test-with-postgres: run tests quickly with a temporary postgresql backend"
@echo "coverage: run tests, recording and printing out Python code coverage"
@echo "docs: generate developer documentation"
@echo "start-foreground-with-postgres: run Kolibri in foreground mode with a temporary postgresql backend"
@echo ""
@echo "Internationalization"
@echo "--------------------"
@echo ""
@echo "i18n-extract: extract all strings from application (both front- and back-end)"
@echo "i18n-upload: upload sources to Crowdin"
@echo "i18n-pretranslate: pretranslate on Crowdin"
@echo "i18n-pretranslate-approve: pretranslate and pre-approve on Crowdin"
@echo "i18n-download: download strings from Crowdin"
@echo "i18n-download-source-fonts: retrieve source Google Noto fonts"
@echo "i18n-regenerate-fonts: regenerate font files"
@echo "i18n-stats: 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"
@echo "i18n-download-glossary: Download the glossary file from crowdin and update locally
@echo "i18n-upload-glossary: Upload the local file to crowdin
clean: clean-build clean-pyc clean-assets clean-staticdeps
clean-assets:
pnpm run clean
clean-build:
rm -f kolibri/VERSION
rm -f kolibri/_version.py
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
clean-test-pypi:
pip install pypi-cleanup==0.1.8
pypi-cleanup --host https://test.pypi.org --package kolibri --leave-most-recent-only --yes --do-it --username aronleqtest
lint:
prek run --all-files
test:
uv run python -O -m pytest
test-all:
@echo "Run tests for a specific Python version with: uv run --python 3.X pytest"
@echo "CI runs tests across all supported Python versions."
uv run pytest
test-morango-integ:
export INTEGRATION_TEST=1; \
python -O -m pytest kolibri/core/auth/test/test_morango_integration.py
%-with-postgres:
@echo -e "\e[33mWARNING: for testing purposes only; postgresql database backend is ephemeral\e[0m"
@echo -e "\e[36mINFO: run 'docker compose -v' to remove the database volume\e[0m"
export KOLIBRI_DATABASE_ENGINE=postgres; \
export KOLIBRI_DATABASE_NAME=default; \
export KOLIBRI_DATABASE_USER=postgres; \
export KOLIBRI_DATABASE_PASSWORD=postgres; \
export KOLIBRI_DATABASE_HOST=127.0.0.1; \
export KOLIBRI_DATABASE_PORT=15432; \
set -ex; \
function _on_interrupt() { docker compose down; }; \
trap _on_interrupt SIGINT SIGTERM SIGKILL ERR; \
docker compose up --detach; \
container_id=$$(docker compose ps -q postgres); \
until [ "$$(docker inspect --format='{{.State.Health.Status}}' $$container_id)" = "healthy" ]; do \
echo "$(date) - waiting for postgres (health=$$(docker inspect --format='{{.State.Health.Status}}' $$container_id))..."; \
sleep 1; \
done; \
$(MAKE) -e $(subst -with-postgres,,$@); \
docker compose down -v
start-foreground:
kolibri start --foreground
assets:
pnpm install
pnpm run build
pnpm run compress
coverage:
uv run coverage run -m pytest
uv run 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/*
clean-staticdeps:
rm -rf kolibri/dist/* || true # remove everything
git checkout -- kolibri/dist # restore __init__.py
staticdeps: clean-staticdeps
# Resolve the bundled runtime dependencies from the `base` group in
# pyproject.toml, pinned to Python 3.6 compatible versions.
uv pip install --python-version 3.6 --target kolibri/dist --group base
# requirements.txt only carries any EXTRA_REQUIREMENTS injected by
# setrequirements (empty by default).
uv pip install --python-version 3.6 --target kolibri/dist -r "requirements.txt"
rm -rf kolibri/dist/*.egg-info
rm -r kolibri/dist/man kolibri/dist/bin || true # remove the two folders introduced by pip 10
staticdeps-cext:
rm -rf kolibri/dist/cext || true # remove everything
uv run --script build_tools/install_cexts.py --file "requirements/cext.txt" # pip install c extensions
uv pip install --python-version 3.6 --target kolibri/dist/cext -r "requirements/cext_noarch.txt" --no-deps
rm -rf kolibri/dist/*.egg-info
strip-staticdeps:
find kolibri/dist -name "*.so" -exec strip --strip-unneeded {} \;
find kolibri/dist -name "*.so" -exec aarch64-linux-gnu-strip --strip-unneeded {} \;
find kolibri/dist -name "*.so" -exec arm-linux-gnueabihf-strip --strip-unneeded {} \;
staticdeps-compileall:
bash -c 'python --version'
# Seems like the compileall module does not return a non-zero exit code when failing
bash -c 'if ( python -m compileall -x py2only kolibri -q | grep SyntaxError ) ; then echo "Failed to compile kolibri/dist/" ; exit 1 ; else exit 0 ; fi'
set-no-uv-python-version-for-tests:
@DESC=$$(git describe --tags --always | sed 's/^v//'); \
VERSION=$$(echo $$DESC | sed -E 's/^([0-9.]+)-([0-9]+)-g(.+)/\1.dev\2+g\3/'); \
echo '# file generated by Makefile for testing Python versions without uv support' > kolibri/_version.py; \
echo "__version__ = version = \"$$VERSION\"" >> kolibri/_version.py; \
echo "Set version to $$VERSION"
writeversion:
uv run python -c "import kolibri; print(kolibri.__version__)" > kolibri/VERSION
@echo ""
@echo "Current version is now `cat kolibri/VERSION`"
preseeddb:
./build_tools/preseed_home.sh
setrequirements:
rm -r requirements.txt || true # remove requirements.txt
git checkout -- requirements.txt # restore requirements.txt
uv run --script build_tools/customize_requirements.py
buildconfig:
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: setrequirements writeversion staticdeps staticdeps-cext strip-staticdeps buildconfig i18n-extract-frontend assets i18n-django-compilemessages preseeddb
uv build
ls -l dist
pex:
ls dist/*.whl | while read whlfile; do version=$$(uv run --script ./build_tools/read_whl_version.py $$whlfile); uvx --from "pex==2.1.153" pex $$whlfile --disable-cache -o dist/kolibri-`echo $$version | sed 's/+/_/g'`.pex -m kolibri --python-shebang=/usr/bin/python3; done
i18n-extract-backend:
cd kolibri && uv run python -m kolibri manage makemessages -- -l en --ignore 'node_modules/*' --ignore 'kolibri/dist/*' --all
i18n-extract-frontend:
pnpm run makemessages
i18n-extract: i18n-extract-frontend i18n-extract-backend
i18n-transfer-context:
pnpm transfercontext
i18n-django-compilemessages:
# Change working directory to kolibri/ such that compilemessages
# finds only the .po files nested there.
cd kolibri && PYTHONPATH="..:$$PYTHONPATH" uv run python -m kolibri manage compilemessages --skip-update
i18n-upload: i18n-extract
pnpm exec crowdin upload sources --branch ${CROWDIN_BRANCH}
i18n-pretranslate:
pnpm exec crowdin pre-translate --branch ${CROWDIN_BRANCH} --translate-untranslated-only --method=tm
i18n-pretranslate-approve-all:
pnpm exec crowdin pre-translate --branch ${CROWDIN_BRANCH} --translate-untranslated-only --method=tm --auto-approve-option=all
i18n-download-translations: i18n-extract-frontend
touch kolibri/locale/.crowdin-download-marker
pnpm exec crowdin download --branch ${CROWDIN_BRANCH}
@if [ -z "$$(find kolibri/locale/*/LC_MESSAGES -type f \( -name '*.po' -o -name '*.csv' \) -newer kolibri/locale/.crowdin-download-marker 2>/dev/null)" ]; then \
echo "❌ ERROR: No translation files were downloaded - Crowdin download may have failed silently"; \
echo "Check the output above for errors during the download process"; \
rm -f kolibri/locale/.crowdin-download-marker; \
exit 1; \
fi
@echo "✅ Translation files downloaded successfully"
rm -f kolibri/locale/.crowdin-download-marker
uv run python build_tools/i18n/cleanup_unsupported_languages.py
pnpm exec kolibri-i18n code-gen --output-dir ./packages/kolibri/utils/internal
$(MAKE) i18n-django-compilemessages
pnpm exec kolibri-i18n create-message-files --pluginFile ./build_tools/build_plugins.txt --ignore '**/node_modules/!(kolibri-common)/**','**/static/**'
i18n-download-source-fonts:
uv run --script build_tools/i18n/fonts.py download-source-fonts
i18n-regenerate-fonts:
uv run --script build_tools/i18n/fonts.py generate-fonts
i18n-download: i18n-download-translations i18n-regenerate-fonts
i18n-install-font:
uv run --script build_tools/i18n/fonts.py add-source-font ${name}
i18n-download-glossary:
pnpm exec crowdin glossary download
i18n-upload-glossary:
pnpm exec crowdin glossary upload
# Build a docker image for the latest version of Kolibri, tag it as `latest`
docker-build:
$(MAKE) -C docker build
# Build a docker image for a specific version of Kolibri: make build-0.19.3
docker-build-%:
$(MAKE) -C docker build-$(subst docker-build-,,$@)