mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 09:22:38 +02:00
move from setuptools to hatch (#1258)
Co-authored-by: Alexis Métaireau <alexis@notmyidea.org>
This commit is contained in:
parent
9f7ecf6614
commit
edefb51cfb
45 changed files with 53 additions and 15 deletions
|
@ -14,9 +14,7 @@ CONTRIBUTORS
|
||||||
docker-compose.*
|
docker-compose.*
|
||||||
Dockerfile
|
Dockerfile
|
||||||
docs
|
docs
|
||||||
LICENSE
|
|
||||||
Makefile
|
Makefile
|
||||||
MANIFEST.in
|
MANIFEST.in
|
||||||
README.md
|
|
||||||
SECURITY.md
|
SECURITY.md
|
||||||
tox.ini
|
tox.ini
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
*.pyc
|
*.pyc
|
||||||
*.egg-info
|
*.egg-info
|
||||||
|
*.mo
|
||||||
dist
|
dist
|
||||||
.venv
|
.venv
|
||||||
docs/_build/
|
docs/_build/
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
include *.md
|
|
||||||
recursive-include ihatemoney *.py *.yaml *.po *.mo *.html *.css *.js *.eot *.svg *.woff *.txt *.png *.webp *.ini *.cfg *.j2 *.jpg *.gif *.ico *.xml
|
|
||||||
include LICENSE CONTRIBUTORS
|
|
6
Makefile
6
Makefile
|
@ -36,7 +36,7 @@ remove-install-stamp:
|
||||||
update: remove-install-stamp install ## Update the dependencies
|
update: remove-install-stamp install ## Update the dependencies
|
||||||
|
|
||||||
.PHONY: serve
|
.PHONY: serve
|
||||||
serve: install ## Run the ihatemoney server
|
serve: install build-translations ## Run the ihatemoney server
|
||||||
@echo 'Running ihatemoney on http://localhost:5000'
|
@echo 'Running ihatemoney on http://localhost:5000'
|
||||||
FLASK_DEBUG=1 FLASK_APP=ihatemoney.wsgi $(VENV)/bin/flask run --host=0.0.0.0
|
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
|
build-translations: ## Build the translations
|
||||||
$(VENV)/bin/pybabel compile -d ihatemoney/translations
|
$(VENV)/bin/pybabel compile -d ihatemoney/translations
|
||||||
|
|
||||||
.PHONY: update-translations
|
.PHONY: extract-translations
|
||||||
update-translations: ## Extract new translations from source code
|
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 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/
|
$(VENV)/bin/pybabel update -i ihatemoney/messages.pot -d ihatemoney/translations/
|
||||||
|
|
||||||
|
|
|
@ -274,10 +274,9 @@ In order to issue a new release, follow the following steps:
|
||||||
|
|
||||||
make compress-assets
|
make compress-assets
|
||||||
|
|
||||||
- Build the translations:
|
- Extract the translations:
|
||||||
|
|
||||||
make update-translations
|
make extract-translations
|
||||||
make build-translations
|
|
||||||
|
|
||||||
- If you're not completely sure of yourself at this point, you can
|
- 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
|
optionally: create a new branch, push it, open a pull request, check
|
||||||
|
|
11
hatch_build.py
Normal file
11
hatch_build.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
||||||
|
|
||||||
|
|
||||||
|
class CustomBuildHook(BuildHookInterface):
|
||||||
|
def initialize(self, version, build_data):
|
||||||
|
sys.path.insert(0, "./ihatemoney")
|
||||||
|
from babel_utils import compile_catalogs
|
||||||
|
|
||||||
|
compile_catalogs()
|
11
ihatemoney/babel_utils.py
Normal file
11
ihatemoney/babel_utils.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from babel.messages.frontend import compile_catalog
|
||||||
|
|
||||||
|
|
||||||
|
def compile_catalogs():
|
||||||
|
cmd = compile_catalog()
|
||||||
|
cmd.directory = Path(__file__).parent / "translations"
|
||||||
|
cmd.statistics = True
|
||||||
|
cmd.finalize_options()
|
||||||
|
cmd.run()
|
|
@ -3,10 +3,16 @@ from unittest.mock import MagicMock
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from ihatemoney.babel_utils import compile_catalogs
|
||||||
from ihatemoney.currency_convertor import CurrencyConverter
|
from ihatemoney.currency_convertor import CurrencyConverter
|
||||||
from ihatemoney.run import create_app, db
|
from ihatemoney.run import create_app, db
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True, scope="session")
|
||||||
|
def babel_catalogs():
|
||||||
|
compile_catalogs()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def app(request: pytest.FixtureRequest):
|
def app(request: pytest.FixtureRequest):
|
||||||
"""Create the Flask app with database"""
|
"""Create the Flask app with database"""
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools", "setuptools-scm"]
|
requires = ["hatchling"]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "ihatemoney"
|
name = "ihatemoney"
|
||||||
|
@ -85,5 +85,19 @@ doc = [
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
ihatemoney = "ihatemoney.manage:cli"
|
ihatemoney = "ihatemoney.manage:cli"
|
||||||
|
|
||||||
[tool.setuptools]
|
[tool.hatch.build.hooks.custom]
|
||||||
packages = ["ihatemoney"]
|
dependencies = [
|
||||||
|
# Babel is needed to compile translations catalogs at package build time
|
||||||
|
"Babel>=2.13.1"
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.hatch.build]
|
||||||
|
artifacts = ["ihatemoney/translations/**/*.mo"]
|
||||||
|
include = [
|
||||||
|
"ihatemoney/",
|
||||||
|
"LICENSE",
|
||||||
|
"CONTRIBUTORS",
|
||||||
|
"CHANGELOG.md",
|
||||||
|
"README.md",
|
||||||
|
"SECURITY.md",
|
||||||
|
]
|
||||||
|
|
1
tox.ini
1
tox.ini
|
@ -1,4 +1,5 @@
|
||||||
[tox]
|
[tox]
|
||||||
|
isolated_build = true
|
||||||
envlist = py312,py311,py310,py39,py38,py37,lint_docs
|
envlist = py312,py311,py310,py39,py38,py37,lint_docs
|
||||||
skip_missing_interpreters = True
|
skip_missing_interpreters = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue