Skip to content

Commit be95282

Browse files
azmeukalmet
andauthored
move from setuptools to hatch (spiral-project#1258)
Co-authored-by: Alexis Métaireau <alexis@notmyidea.org>
1 parent 834cf8a commit be95282

File tree

45 files changed

+53
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+53
-15
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ CONTRIBUTORS
1414
docker-compose.*
1515
Dockerfile
1616
docs
17-
LICENSE
1817
Makefile
1918
MANIFEST.in
20-
README.md
2119
SECURITY.md
2220
tox.ini

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.pyc
22
*.egg-info
3+
*.mo
34
dist
45
.venv
56
docs/_build/

MANIFEST.in

Lines changed: 0 additions & 3 deletions
This file was deleted.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ remove-install-stamp:
3636
update: remove-install-stamp install ## Update the dependencies
3737

3838
.PHONY: serve
39-
serve: install ## Run the ihatemoney server
39+
serve: install build-translations ## Run the ihatemoney server
4040
@echo 'Running ihatemoney on http://localhost:5000'
4141
FLASK_DEBUG=1 FLASK_APP=ihatemoney.wsgi $(VENV)/bin/flask run --host=0.0.0.0
4242

@@ -74,8 +74,8 @@ compress-assets: compress-showcase ## Compress static assets
7474
build-translations: ## Build the translations
7575
$(VENV)/bin/pybabel compile -d ihatemoney/translations
7676

77-
.PHONY: update-translations
78-
update-translations: ## Extract new translations from source code
77+
.PHONY: extract-translations
78+
extract-translations: ## Extract new translations from source code
7979
$(VENV)/bin/pybabel extract --add-comments "I18N:" --strip-comments --omit-header --no-location --mapping-file ihatemoney/babel.cfg -o ihatemoney/messages.pot ihatemoney
8080
$(VENV)/bin/pybabel update -i ihatemoney/messages.pot -d ihatemoney/translations/
8181

docs/contributing.md

Lines changed: 2 additions & 3 deletions

hatch_build.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sys
2+
3+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
4+
5+
6+
class CustomBuildHook(BuildHookInterface):
7+
def initialize(self, version, build_data):
8+
sys.path.insert(0, "./ihatemoney")
9+
from babel_utils import compile_catalogs
10+
11+
compile_catalogs()

ihatemoney/babel_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pathlib import Path
2+
3+
from babel.messages.frontend import compile_catalog
4+
5+
6+
def compile_catalogs():
7+
cmd = compile_catalog()
8+
cmd.directory = Path(__file__).parent / "translations"
9+
cmd.statistics = True
10+
cmd.finalize_options()
11+
cmd.run()

ihatemoney/tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
from flask import Flask
44
import pytest
55

6+
from ihatemoney.babel_utils import compile_catalogs
67
from ihatemoney.currency_convertor import CurrencyConverter
78
from ihatemoney.run import create_app, db
89

910

11+
@pytest.fixture(autouse=True, scope="session")
12+
def babel_catalogs():
13+
compile_catalogs()
14+
15+
1016
@pytest.fixture
1117
def app(request: pytest.FixtureRequest):
1218
"""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.
-411 Bytes
Binary file not shown.
Binary file not shown.

pyproject.toml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["setuptools", "setuptools-scm"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "ihatemoney"
@@ -85,5 +85,19 @@ doc = [
8585
[project.scripts]
8686
ihatemoney = "ihatemoney.manage:cli"
8787

88-
[tool.setuptools]
89-
packages = ["ihatemoney"]
88+
[tool.hatch.build.hooks.custom]
89+
dependencies = [
90+
# Babel is needed to compile translations catalogs at package build time
91+
"Babel>=2.13.1"
92+
]
93+
94+
[tool.hatch.build]
95+
artifacts = ["ihatemoney/translations/**/*.mo"]
96+
include = [
97+
"ihatemoney/",
98+
"LICENSE",
99+
"CONTRIBUTORS",
100+
"CHANGELOG.md",
101+
"README.md",
102+
"SECURITY.md",
103+
]

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[tox]
2+
isolated_build = true
23
envlist = py312,py311,py310,py39,py38,py37,lint_docs
34
skip_missing_interpreters = True
45

0 commit comments

Comments
 (0)