diff --git a/.github/workflows/pypi-package.yml b/.github/workflows/pypi-package.yml index 306af50..8704fe3 100644 --- a/.github/workflows/pypi-package.yml +++ b/.github/workflows/pypi-package.yml @@ -25,12 +25,6 @@ jobs: persist-credentials: false - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - - name: Compile translations - run: | - pip install --upgrade pip - pip install -r requirements.txt - python babel_runner.py compile - - uses: hynek/build-and-inspect-python-package@fe0a0fb1925ca263d076ca4f2c13e93a6e92a33e # v2.17.0 # Upload to real PyPI on GitHub Releases. diff --git a/babel_runner.py b/babel_runner.py index 677f6da..f4c8122 100755 --- a/babel_runner.py +++ b/babel_runner.py @@ -8,6 +8,8 @@ import tomllib from pathlib import Path +from hatchling.builders.hooks.plugin.interface import BuildHookInterface + # Global variables used by pybabel below (paths relative to PROJECT_DIR) DOMAIN = "python-docs-theme" COPYRIGHT_HOLDER = "Python Software Foundation" @@ -106,6 +108,11 @@ def compile_catalogs(locale: str) -> None: subprocess.run(cmd, cwd=PROJECT_DIR, check=True) +class CustomBuildHook(BuildHookInterface): + def initialize(self, version: str, build_data: dict[str, object]) -> None: + compile_catalogs("") + + def main() -> None: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument( diff --git a/pyproject.toml b/pyproject.toml index ef39594..897ff85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,8 @@ [build-system] -build-backend = "flit_core.buildapi" +build-backend = "hatchling.build" requires = [ - "flit-core>=3.7", + "babel", + "hatchling", ] [project] @@ -36,9 +37,12 @@ urls.Download = "https://pypi.org/project/python-docs-theme/" urls.Homepage = "https://github.com/python/python-docs-theme/" entry-points."sphinx.html_themes".python_docs_theme = "python_docs_theme" -[tool.flit] -module.name = "python_docs_theme" -sdist.include = [ "python_docs_theme/" ] +[tool.hatch] +build.artifacts = [ "python_docs_theme/locale/**/*.mo" ] +build.hooks.custom.path = "babel_runner.py" +build.targets.wheel.packages = [ "python_docs_theme" ] +build.targets.wheel.exclude = [ "python_docs_theme/locale/**/*.po" ] +version.path = "python_docs_theme/__init__.py" [tool.ruff] fix = true diff --git a/python_docs_theme/locale/de/LC_MESSAGES/python-docs-theme.po b/python_docs_theme/locale/de/LC_MESSAGES/python-docs-theme.po index 49dddf7..7ec069d 100644 --- a/python_docs_theme/locale/de/LC_MESSAGES/python-docs-theme.po +++ b/python_docs_theme/locale/de/LC_MESSAGES/python-docs-theme.po @@ -7,7 +7,6 @@ # Translators: # Cristián Maureira-Fredes, 2025 # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: python-docs-theme 2025.5\n" diff --git a/requirements.txt b/requirements.txt index bb631b5..ea5adbd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ # for babel_runner.py Babel +hatchling Jinja2