diff --git a/.gitignore b/.gitignore index 1ec6964a7..ef4cc7718 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.pyc *.egg-info +*.mo dist .venv docs/_build/ diff --git a/Dockerfile b/Dockerfile index 3a54cf479..fd79b9942 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,10 @@ ENV DEBUG="False" \ ADD . /src +ADD LICENSE /src + +ADD README.md /src + RUN echo "**** install build dependencies ****" &&\ apk add --no-cache --virtual=build-dependencies \ gcc \ diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 80b2334ea..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include *.rst -recursive-include ihatemoney *.rst *.py *.yaml *.po *.mo *.html *.css *.js *.eot *.svg *.woff *.txt *.png *.webp *.ini *.cfg *.j2 *.jpg *.gif *.ico *.xml -include LICENSE CONTRIBUTORS CHANGELOG.rst diff --git a/Makefile b/Makefile index 47bbdc02d..bf917b601 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ remove-install-stamp: update: remove-install-stamp install ## Update the dependencies .PHONY: serve -serve: install ## Run the ihatemoney server +serve: install build-translations ## Run the ihatemoney server @echo 'Running ihatemoney on http://localhost:5000' FLASK_DEBUG=1 FLASK_APP=ihatemoney.wsgi $(VENV)/bin/flask run --host=0.0.0.0 @@ -74,8 +74,8 @@ compress-assets: compress-showcase ## Compress static assets build-translations: ## Build the translations $(VENV)/bin/pybabel compile -d ihatemoney/translations -.PHONY: update-translations -update-translations: ## Extract new translations from source code +.PHONY: extract-translations +extract-translations: ## Extract new translations from source code $(VENV)/bin/pybabel extract --add-comments "I18N:" --strip-comments --omit-header --no-location --mapping-file ihatemoney/babel.cfg -o ihatemoney/messages.pot ihatemoney $(VENV)/bin/pybabel update -i ihatemoney/messages.pot -d ihatemoney/translations/ diff --git a/docs/contributing.md b/docs/contributing.md index a86f73211..78d5a8063 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -274,10 +274,9 @@ In order to issue a new release, follow the following steps: make compress-assets -- Build the translations: +- Extract the translations: - make update-translations - make build-translations + make extract-translations - If you're not completely sure of yourself at this point, you can optionally: create a new branch, push it, open a pull request, check diff --git a/hatch_build.py b/hatch_build.py new file mode 100644 index 000000000..04d11e29a --- /dev/null +++ b/hatch_build.py @@ -0,0 +1,14 @@ +from pathlib import Path + +from hatchling.builders.hooks.plugin.interface import BuildHookInterface + + +class CustomBuildHook(BuildHookInterface): + def initialize(self, version, build_data): + from babel.messages.frontend import compile_catalog + + cmd = compile_catalog() + cmd.directory = Path(__file__).parent / "ihatemoney" / "translations" + cmd.statistics = True + cmd.finalize_options() + cmd.run() diff --git a/ihatemoney/tests/conftest.py b/ihatemoney/tests/conftest.py index 08d6e8912..01c2cec07 100644 --- a/ihatemoney/tests/conftest.py +++ b/ihatemoney/tests/conftest.py @@ -1,5 +1,7 @@ +from pathlib import Path from unittest.mock import MagicMock +from babel.messages.frontend import compile_catalog from flask import Flask import pytest @@ -7,6 +9,15 @@ from ihatemoney.run import create_app, db +@pytest.fixture(autouse=True, scope="session") +def babel_catalogs(): + cmd = compile_catalog() + cmd.directory = Path(__file__).parent.parent / "translations" + cmd.quiet = True + cmd.finalize_options() + cmd.run() + + @pytest.fixture def app(request: pytest.FixtureRequest): """Create the Flask app with database""" diff --git a/ihatemoney/translations/bn/LC_MESSAGES/messages.mo b/ihatemoney/translations/bn/LC_MESSAGES/messages.mo deleted file mode 100644 index 7b4bd7178..000000000 Binary files a/ihatemoney/translations/bn/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/bn_BD/LC_MESSAGES/messages.mo b/ihatemoney/translations/bn_BD/LC_MESSAGES/messages.mo deleted file mode 100644 index 6cc61e8f1..000000000 Binary files a/ihatemoney/translations/bn_BD/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ca/LC_MESSAGES/messages.mo b/ihatemoney/translations/ca/LC_MESSAGES/messages.mo deleted file mode 100644 index a6b269a54..000000000 Binary files a/ihatemoney/translations/ca/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/cs/LC_MESSAGES/messages.mo b/ihatemoney/translations/cs/LC_MESSAGES/messages.mo deleted file mode 100644 index c00a86aff..000000000 Binary files a/ihatemoney/translations/cs/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/de/LC_MESSAGES/messages.mo b/ihatemoney/translations/de/LC_MESSAGES/messages.mo deleted file mode 100644 index 9b03f6ca8..000000000 Binary files a/ihatemoney/translations/de/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/el/LC_MESSAGES/messages.mo b/ihatemoney/translations/el/LC_MESSAGES/messages.mo deleted file mode 100644 index e7746e1fc..000000000 Binary files a/ihatemoney/translations/el/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/eo/LC_MESSAGES/messages.mo b/ihatemoney/translations/eo/LC_MESSAGES/messages.mo deleted file mode 100644 index d46cd40a3..000000000 Binary files a/ihatemoney/translations/eo/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/es/LC_MESSAGES/messages.mo b/ihatemoney/translations/es/LC_MESSAGES/messages.mo deleted file mode 100644 index a8f107778..000000000 Binary files a/ihatemoney/translations/es/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/es_419/LC_MESSAGES/messages.mo b/ihatemoney/translations/es_419/LC_MESSAGES/messages.mo deleted file mode 100644 index 47409380f..000000000 Binary files a/ihatemoney/translations/es_419/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/fa/LC_MESSAGES/messages.mo b/ihatemoney/translations/fa/LC_MESSAGES/messages.mo deleted file mode 100644 index 43a3a59c2..000000000 Binary files a/ihatemoney/translations/fa/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/fr/LC_MESSAGES/messages.mo b/ihatemoney/translations/fr/LC_MESSAGES/messages.mo deleted file mode 100644 index 0ead04b00..000000000 Binary files a/ihatemoney/translations/fr/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/he/LC_MESSAGES/messages.mo b/ihatemoney/translations/he/LC_MESSAGES/messages.mo deleted file mode 100644 index a9ddfde3e..000000000 Binary files a/ihatemoney/translations/he/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/hi/LC_MESSAGES/messages.mo b/ihatemoney/translations/hi/LC_MESSAGES/messages.mo deleted file mode 100644 index 74ae7cf0c..000000000 Binary files a/ihatemoney/translations/hi/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/hu/LC_MESSAGES/messages.mo b/ihatemoney/translations/hu/LC_MESSAGES/messages.mo deleted file mode 100644 index fe90ccbc1..000000000 Binary files a/ihatemoney/translations/hu/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/id/LC_MESSAGES/messages.mo b/ihatemoney/translations/id/LC_MESSAGES/messages.mo deleted file mode 100644 index 3901d26fb..000000000 Binary files a/ihatemoney/translations/id/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/it/LC_MESSAGES/messages.mo b/ihatemoney/translations/it/LC_MESSAGES/messages.mo deleted file mode 100644 index df64c7437..000000000 Binary files a/ihatemoney/translations/it/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ja/LC_MESSAGES/messages.mo b/ihatemoney/translations/ja/LC_MESSAGES/messages.mo deleted file mode 100644 index e0a0e5212..000000000 Binary files a/ihatemoney/translations/ja/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/kn/LC_MESSAGES/messages.mo b/ihatemoney/translations/kn/LC_MESSAGES/messages.mo deleted file mode 100644 index 4a9277e15..000000000 Binary files a/ihatemoney/translations/kn/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ms/LC_MESSAGES/messages.mo b/ihatemoney/translations/ms/LC_MESSAGES/messages.mo deleted file mode 100644 index 9c58d4dee..000000000 Binary files a/ihatemoney/translations/ms/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/nb_NO/LC_MESSAGES/messages.mo b/ihatemoney/translations/nb_NO/LC_MESSAGES/messages.mo deleted file mode 100644 index 52ea457f8..000000000 Binary files a/ihatemoney/translations/nb_NO/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/nl/LC_MESSAGES/messages.mo b/ihatemoney/translations/nl/LC_MESSAGES/messages.mo deleted file mode 100644 index 5a0e9c1c8..000000000 Binary files a/ihatemoney/translations/nl/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/pl/LC_MESSAGES/messages.mo b/ihatemoney/translations/pl/LC_MESSAGES/messages.mo deleted file mode 100644 index 9787b92f2..000000000 Binary files a/ihatemoney/translations/pl/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/pt/LC_MESSAGES/messages.mo b/ihatemoney/translations/pt/LC_MESSAGES/messages.mo deleted file mode 100644 index 0e7ed0e8f..000000000 Binary files a/ihatemoney/translations/pt/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/pt_BR/LC_MESSAGES/messages.mo b/ihatemoney/translations/pt_BR/LC_MESSAGES/messages.mo deleted file mode 100644 index 3d649d6b9..000000000 Binary files a/ihatemoney/translations/pt_BR/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ru/LC_MESSAGES/messages.mo b/ihatemoney/translations/ru/LC_MESSAGES/messages.mo deleted file mode 100644 index 2987fec02..000000000 Binary files a/ihatemoney/translations/ru/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/sr/LC_MESSAGES/messages.mo b/ihatemoney/translations/sr/LC_MESSAGES/messages.mo deleted file mode 100644 index 1100d08cf..000000000 Binary files a/ihatemoney/translations/sr/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/sv/LC_MESSAGES/messages.mo b/ihatemoney/translations/sv/LC_MESSAGES/messages.mo deleted file mode 100644 index de111ecf8..000000000 Binary files a/ihatemoney/translations/sv/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ta/LC_MESSAGES/messages.mo b/ihatemoney/translations/ta/LC_MESSAGES/messages.mo deleted file mode 100644 index 25e6adb95..000000000 Binary files a/ihatemoney/translations/ta/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/te/LC_MESSAGES/messages.mo b/ihatemoney/translations/te/LC_MESSAGES/messages.mo deleted file mode 100644 index 9949f84af..000000000 Binary files a/ihatemoney/translations/te/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/th/LC_MESSAGES/messages.mo b/ihatemoney/translations/th/LC_MESSAGES/messages.mo deleted file mode 100644 index 413741026..000000000 Binary files a/ihatemoney/translations/th/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/tr/LC_MESSAGES/messages.mo b/ihatemoney/translations/tr/LC_MESSAGES/messages.mo deleted file mode 100644 index 24f6ff0e2..000000000 Binary files a/ihatemoney/translations/tr/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/uk/LC_MESSAGES/messages.mo b/ihatemoney/translations/uk/LC_MESSAGES/messages.mo deleted file mode 100644 index dfb9b4751..000000000 Binary files a/ihatemoney/translations/uk/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ur/LC_MESSAGES/messages.mo b/ihatemoney/translations/ur/LC_MESSAGES/messages.mo deleted file mode 100644 index e9bb034d5..000000000 Binary files a/ihatemoney/translations/ur/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/vi/LC_MESSAGES/messages.mo b/ihatemoney/translations/vi/LC_MESSAGES/messages.mo deleted file mode 100644 index c26a756a7..000000000 Binary files a/ihatemoney/translations/vi/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/zh_Hans/LC_MESSAGES/messages.mo b/ihatemoney/translations/zh_Hans/LC_MESSAGES/messages.mo deleted file mode 100644 index 0dcc89dd9..000000000 Binary files a/ihatemoney/translations/zh_Hans/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/pyproject.toml b/pyproject.toml index 5212054b1..fee31f8f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["setuptools", "setuptools-scm"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "ihatemoney" @@ -84,5 +84,18 @@ doc = [ [project.scripts] ihatemoney = "ihatemoney.manage:cli" -[tool.setuptools] -packages = ["ihatemoney"] +[tool.hatch.build.hooks.custom] +dependencies = [ + "Babel>=2.10.1" +] + +[tool.hatch.build] +artifacts = ["ihatemoney/translations/**/*.mo"] +include = [ + "ihatemoney/", + "LICENSE", + "CONTRIBUTORS", + "CHANGELOG.md", + "README.md", + "SECURITY.md", +] diff --git a/tox.ini b/tox.ini index e79ede311..206a9c6bd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,5 @@ [tox] +isolated_build = true envlist = py311,py310,py39,py38,py37,lint_docs skip_missing_interpreters = True