Skip to content

Commit

Permalink
chore: move from setuptools to hatch_build
Browse files Browse the repository at this point in the history
packages are built with hatch instead of setuptools.
Translations catalogs are compiled at package build time, and before unit tests are
ran. Thus there is no need to keep them versioned in git anymore.
  • Loading branch information
azmeuk committed Nov 11, 2023
1 parent e507b44 commit 902beb8
Show file tree
Hide file tree
Showing 41 changed files with 42 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.pyc
*.egg-info
*.mo
dist
.venv
docs/_build/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

- 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
Expand Down
16 changes: 16 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os

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 = os.path.join(
os.path.dirname(__file__), "ihatemoney", "translations"
)
cmd.statistics = True
cmd.finalize_options()
cmd.run()
14 changes: 14 additions & 0 deletions ihatemoney/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import os
from unittest.mock import MagicMock

from babel.messages.frontend import compile_catalog
from flask import Flask
import pytest

from ihatemoney.currency_convertor import CurrencyConverter
from ihatemoney.run import create_app, db


@pytest.fixture(autouse=True, scope="session")
def babel_catalogs():
cmd = compile_catalog()
cmd.directory = os.path.join(
os.path.dirname(os.path.dirname(__file__)), "translations"
)
cmd.quiet = True
cmd.statistics = True
cmd.finalize_options()
cmd.run()


@pytest.fixture
def app(request: pytest.FixtureRequest):
"""Create the Flask app with database"""
Expand Down
Binary file removed ihatemoney/translations/bn/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file not shown.
Binary file removed ihatemoney/translations/ca/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/cs/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/de/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/el/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/eo/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/es/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file not shown.
Binary file removed ihatemoney/translations/fa/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file not shown.
Binary file removed ihatemoney/translations/he/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/hi/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/hu/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/id/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/it/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/ja/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/kn/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/ms/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file not shown.
Binary file removed ihatemoney/translations/nl/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/pl/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/pt/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file not shown.
Binary file removed ihatemoney/translations/ru/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/sr/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/sv/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/ta/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/te/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/th/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/tr/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/uk/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/ur/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file removed ihatemoney/translations/vi/LC_MESSAGES/messages.mo
Binary file not shown.
Binary file not shown.
13 changes: 9 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "ihatemoney"
Expand Down Expand Up @@ -84,5 +84,10 @@ doc = [
[project.scripts]
ihatemoney = "ihatemoney.manage:cli"

[tool.setuptools]
packages = ["ihatemoney"]
[tool.hatch.build.hooks.custom]
dependencies = [
"Babel>=2.6.0"
]

[tool.hatch.build]
artifacts = ["ihatemoney/translations/**/*.mo"]

0 comments on commit 902beb8

Please sign in to comment.