From ca109461181a79f8a0efc8833e143aa8b4733532 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Sun, 1 Dec 2024 12:34:43 +0000 Subject: [PATCH 01/12] bump version --- CHANGES.rst | 21 +++++++++++++++++++++ sphinx_intl/__init__.py | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3071755..f2fd594 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,27 @@ CHANGES ======= +2.3.2 (unreleased) +================== + +Environments +------------ + +Incompatibility +--------------- + +Features +-------- + +Bug Fixes +--------- + +Documentation +------------- + +Internals +--------- + 2.3.1 (2024/12/01) ================== diff --git a/sphinx_intl/__init__.py b/sphinx_intl/__init__.py index 3a5935a..ef6497d 100644 --- a/sphinx_intl/__init__.py +++ b/sphinx_intl/__init__.py @@ -1 +1 @@ -__version__ = "2.3.1" +__version__ = "2.3.2" From 8783e214b4a21e5c364062239e8392fe2cef42bd Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Mon, 2 Dec 2024 17:16:24 -0300 Subject: [PATCH 02/12] Add suport for Python 3.14 (#115) * Add Python 3.14 to tox.ini * Add Python 3.14 to test.yml * Add Python 3.14 to pyproject.toml * Update CHANGES.rst --- .github/workflows/test.yml | 2 +- CHANGES.rst | 2 ++ pyproject.toml | 1 + tox.ini | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1cc9dbd..84fdbd4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.9, '3.10', '3.11', '3.12', '3.13'] + python-version: [3.9, '3.10', '3.11', '3.12', '3.13', '3.14'] max-parallel: 1 steps: diff --git a/CHANGES.rst b/CHANGES.rst index f2fd594..86e6515 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,8 @@ CHANGES Environments ------------ +* add python-3.14 support by @rffontenelle in https://github.com/sphinx-doc/sphinx-intl/pull/115 + Incompatibility --------------- diff --git a/pyproject.toml b/pyproject.toml index b937b8b..52b4821 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Framework :: Sphinx", ] diff --git a/tox.ini b/tox.ini index 3d76503..5845d21 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{39,310,311,312,313}, + py{39,310,311,312,313,314}, lint, mypy @@ -11,6 +11,7 @@ python = 3.11: py311 3.12: py312 3.13: py313 + 3.14: py314 [testenv] deps=-e.[test] From 6d366629024f685d4025e951b4c5255044797857 Mon Sep 17 00:00:00 2001 From: Dengda Zhu Date: Mon, 21 Jul 2025 05:28:58 +0800 Subject: [PATCH 03/12] FIX: set `exist_ok=True` in `os.makedirs()` (#120) --- sphinx_intl/catalog.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sphinx_intl/catalog.py b/sphinx_intl/catalog.py index b78aec2..a307a49 100644 --- a/sphinx_intl/catalog.py +++ b/sphinx_intl/catalog.py @@ -32,8 +32,7 @@ def dump_po(filename, catalog, **kwargs): :return: None """ dirname = os.path.dirname(filename) - if not os.path.exists(dirname): - os.makedirs(dirname) + os.makedirs(dirname, exist_ok=True) # (compatibility) line_width was the original argument used to forward # line width hints into write_po's `width` argument; if provided, @@ -55,8 +54,8 @@ def write_mo(filename, catalog, **kwargs): :return: None """ dirname = os.path.dirname(filename) - if not os.path.exists(dirname): - os.makedirs(dirname) + os.makedirs(dirname, exist_ok=True) + with open(filename, "wb") as f: mofile.write_mo(f, catalog, **kwargs) From 2cc10e088f0bff5e1684deb1309a0f9c1975f331 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 09:57:29 +0900 Subject: [PATCH 04/12] fixes #116: Update doesn't respect default value of locale_dirs from `-c` passed `conf.py` (#122) * fixes #116: Update doesn't respect default value of locale_dirs from `-c` passed `conf.py` * lint fix --- sphinx_intl/commands.py | 7 ++-- tests/test_locale_dirs_default.py | 65 +++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 tests/test_locale_dirs_default.py diff --git a/sphinx_intl/commands.py b/sphinx_intl/commands.py index d6f485c..725cd90 100644 --- a/sphinx_intl/commands.py +++ b/sphinx_intl/commands.py @@ -233,10 +233,9 @@ def main(ctx, config, tag): ctx.locale_dir = None if ctx.config: cfg = read_config(ctx.config, tag) - if "locale_dirs" in cfg: - ctx.locale_dir = os.path.join( - os.path.dirname(ctx.config), cfg["locale_dirs"][0] - ) + # Use explicit locale_dirs if set, otherwise use Sphinx's default ['locales'] + locale_dirs = cfg.get("locale_dirs", ["locales"]) + ctx.locale_dir = os.path.join(os.path.dirname(ctx.config), locale_dirs[0]) # for pot_dir ctx.pot_dir = None diff --git a/tests/test_locale_dirs_default.py b/tests/test_locale_dirs_default.py new file mode 100644 index 0000000..3e1e18b --- /dev/null +++ b/tests/test_locale_dirs_default.py @@ -0,0 +1,65 @@ +""" + test_locale_dirs_default + ~~~~~~~~~~~~~~~~~~~~~~~~ + + Test locale_dirs default value handling. + + :copyright: Copyright 2025 by Takayuki SHIMIZUKAWA. + :license: BSD, see LICENSE for details. +""" +import os +from unittest import mock +from pathlib import Path + +import pytest +from click.testing import CliRunner + +from sphinx_intl.commands import main + + +def test_locale_dirs_explicit_setting(tmp_path: Path): + """Test that explicit locale_dirs setting is respected in ctx.locale_dir.""" + # Arrange + conf_content = """locale_dirs = ['custom_locale']""" + conf_path = tmp_path / 'conf.py' + conf_path.write_text(conf_content) + pot_dir = tmp_path / '_build' / 'gettext' + pot_dir.mkdir(parents=True) + (pot_dir / 'test.pot').write_text('msgid "test"') + + # Act + with mock.patch('sphinx_intl.commands.basic.update') as mock_update: + result = CliRunner().invoke(main, ['-c', str(conf_path), 'update', '-p', str(pot_dir), '-l', 'ja']) + + # Assert + assert mock_update.called, "basic.update should have been called" + called_locale_dir = mock_update.call_args[0][0] + expected_locale_dir = str(tmp_path / 'custom_locale') + assert called_locale_dir == expected_locale_dir + + +def test_locale_dirs_default_value(tmp_path: Path): + """ + Test that default locale_dirs value ['locales'] is used when not specified. + + This also serves as a regression test for issue #116: locale_dir should be + set relative to conf.py location, not relative to the current working directory. + """ + # Arrange + # No locale_dirs setting - should use default ['locales'] + conf_content = """project = 'test'""" + conf_path = tmp_path / 'conf.py' + conf_path.write_text(conf_content) + pot_dir = tmp_path / '_build' / 'gettext' + pot_dir.mkdir(parents=True) + (pot_dir / 'test.pot').write_text('msgid "test"') + + # Act + with mock.patch('sphinx_intl.commands.basic.update') as mock_update: + result = CliRunner().invoke(main, ['-c', str(conf_path), 'update', '-p', str(pot_dir), '-l', 'ja']) + + # Assert + assert mock_update.called, "basic.update should have been called" + called_locale_dir = mock_update.call_args[0][0] + expected_locale_dir = str(tmp_path / 'locales') + assert called_locale_dir == expected_locale_dir From 2d409a350a43cc92ec32fc6cf18afe461725a140 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 09:59:22 +0900 Subject: [PATCH 05/12] Update CHANGES.rst refs #116, #122 --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 86e6515..9e87ded 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,6 +19,8 @@ Features Bug Fixes --------- +- #116: Update doesn't respect default value of locale_dirs from -c passed conf.py + Documentation ------------- From 3a4e235eb8a1bf1d4d841b6293e3161dcf2a6c98 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 11:45:01 +0900 Subject: [PATCH 06/12] using uv for dev setup, build, publish (#114) * using uv for dev setup, build, publish * fix github actions trigger * add missing tox-gh-actions * remove requirements-dev.txt * update release procedure to clarify version bumping for next release * update versions for dependencies * adapt LICENSE metadata to SPDX expression https://packaging.python.org/en/latest/specifications/license-expression/ --- .devcontainer/on_create_command.sh | 6 +- .github/workflows/ci.yml | 137 +++++++++++++++++++++++++++++ .github/workflows/test.yml | 80 ----------------- .gitignore | 2 + MANIFEST.in | 1 - checklist.rst | 14 ++- doc/dev.rst | 4 +- pyproject.toml | 34 ++++--- requirements-dev.txt | 6 -- setup.cfg | 17 ---- sphinx_intl/__init__.py | 8 +- tox.ini | 19 +--- 12 files changed, 182 insertions(+), 146 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 requirements-dev.txt delete mode 100644 setup.cfg diff --git a/.devcontainer/on_create_command.sh b/.devcontainer/on_create_command.sh index ddc1c92..8562b17 100755 --- a/.devcontainer/on_create_command.sh +++ b/.devcontainer/on_create_command.sh @@ -3,8 +3,10 @@ set -ex -pip install -U pip setuptools wheel setuptools_scm -pip install -r requirements-dev.txt +curl -LsSf https://astral.sh/uv/install.sh | sh +. $HOME/.cargo/env +uv tool install -U ruff +uv tool install -U tox --with tox-uv # Install Transifex CLI tool into /usr/local/bin # refer to Installation instructions https://github.com/transifex/cli#installation diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..67e47ea --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,137 @@ +name: Test +on: + push: + paths-ignore: + - 'doc/**' + pull_request: + paths-ignore: + - 'doc/**' + release: + types: [released] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + max-parallel: 5 + matrix: + python-version: [3.9, '3.10', '3.11', '3.12', '3.13', '3.14'] + + steps: + - name: Print github context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo $GITHUB_CONTEXT + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Set up Python ${{ matrix.python-version }} + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + cache-dependency-glob: "pyproject.toml" + cache-suffix: ${{ matrix.python-version }} + + - name: Install Python + run: uv python install ${{ matrix.python-version }} + env: + UV_PYTHON_PREFERENCE: only-managed + + - name: Install Transifex CLI + run: | + curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash + mv tx /usr/local/bin/tx + + - name: Tox tests + run: uv run --only-dev tox -- -v --durations=25 + + build: + name: build distribution + if: github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' + needs: + - tests + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Set up Python + uses: astral-sh/setup-uv@v3 + + - name: build package + run: uv build + + - name: upload artifact + uses: actions/upload-artifact@v4 + with: + name: distributions + path: dist/ + + pypi-publish: + name: Upload release to PyPI + if: github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/') + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/sphinx-intl + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: distributions + path: dist/ + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + + # for test + password: ${{ secrets.TESTPYPI_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + + # for production + # password: ${{ secrets.PYPI_TOKEN }} + + github-release: + name: GitHub release + if: github.repository_owner == 'sphinx-doc' + runs-on: ubuntu-latest + needs: + - pypi-publish + environment: release + permissions: + contents: write # for softprops/action-gh-release to create GitHub release + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Get release version + id: get_version + uses: actions/github-script@v7 + with: + script: core.setOutput('version', context.ref.replace("refs/tags/", "")) + + - name: Create GitHub release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + name: "sphinx-intl ${{ steps.get_version.outputs.version }}" + body: "Changelog: https://sphinx-intl.readthedocs.io/en/master/changes.html" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 84fdbd4..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Test -on: - push: - paths-ignore: - - 'doc/**' - pull_request: - paths-ignore: - - 'doc/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} - cancel-in-progress: true - -jobs: - tests: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: [3.9, '3.10', '3.11', '3.12', '3.13', '3.14'] - max-parallel: 1 - - steps: - - name: Print github context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo $GITHUB_CONTEXT - - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Setup python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - allow-prereleases: true - cache: 'pip' - - - name: Install tox and test related - run: | - python -m pip install --upgrade pip - pip install tox tox-gh-actions - - - name: Install Transifex CLI - run: | - curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash - mv tx /usr/local/bin/tx - - - name: Run tox - run: | - python -V - tox -- -v --durations=25 - - lint: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - env: [lint, mypy] - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Setup python - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - - name: Install tox and any other dependencies for test - run: | - python -m pip install --upgrade pip - pip install tox tox-gh-actions - - - name: Run tox - run: tox -e ${{ matrix.env }} diff --git a/.gitignore b/.gitignore index c1f2627..ac2022e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +uv.lock + # Created by https://www.toptal.com/developers/gitignore/api/python # Edit at https://www.toptal.com/developers/gitignore?templates=python diff --git a/MANIFEST.in b/MANIFEST.in index e90b104..a9047bf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,4 @@ include *.rst -include requirements-*.txt include tox.ini recursive-include tests * prune tests/__pycache__ diff --git a/checklist.rst b/checklist.rst index 488f137..ced37e1 100644 --- a/checklist.rst +++ b/checklist.rst @@ -2,12 +2,8 @@ Procedure: -1. check GitHub Actions test results: https://github.com/sphinx-doc/sphinx-intl/actions -2. update release version/date in ``CHANGES.rst`` -3. ``python -m build``, see details: setup.cfg -4. ``twine upload dist/`` -5. check PyPI page: https://pypi.org/p/sphinx-intl -6. tagging with version name that MUST following semver. e.g.: ``git tag 1.0.1`` -7. ``git push --tags`` to push tag -8. bump version in ``sphinx_intl/__init__.py`` and ``CHANGES.rst`` then commit/push - them onto GitHub +1. update release version/date in ``CHANGES.rst`` +2. create GitHub Release with new version tag, it will create a release on PyPI. + tag MUST following semver. e.g.: ``2.3.1`` +3. check PyPI page: https://pypi.org/p/sphinx-intl +4. prepareing for the next release: bump version in ``CHANGES.rst`` then commit/push it onto GitHub diff --git a/doc/dev.rst b/doc/dev.rst index cf94e24..62c6945 100644 --- a/doc/dev.rst +++ b/doc/dev.rst @@ -18,8 +18,8 @@ Setup development environment * Requires supported Python version * Do setup under sphinx-intl.git repository root as:: - $ pip install -U pip setuptools wheel setuptools_scm - $ pip install -r requirements-dev.txt + $ pip install -U uv + $ uv sync * Install Transifex CLI tool (refer to `Installation instructions `_):: diff --git a/pyproject.toml b/pyproject.toml index 52b4821..584b98d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,17 +7,16 @@ authors = [ description = "Sphinx utility that make it easy to translate and to apply translation." readme = "README.rst" requires-python = ">=3.9" -license = {file = "LICENSE"} +license = "BSD-2-Clause" +license-files = ["LICENSE"] dependencies = [ - "setuptools", - "click", - "babel", + "click>=8.0.0", + "babel>=2.9.0", "sphinx", ] classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Console", - "License :: OSI Approved :: BSD License", "Topic :: Documentation", "Topic :: Documentation :: Sphinx", "Topic :: Software Development", @@ -37,7 +36,15 @@ classifiers = [ [project.optional-dependencies] test = [ - "pytest", + "pytest>=8.3.5", +] + +[dependency-groups] +dev = [ + "pytest>=8.3.5", + "ruff>=0.11.10", + "tox-gh-actions>=3.3.0", + "tox-uv>=1.25.0", ] [project.urls] @@ -47,16 +54,19 @@ Documentation = "https://sphinx-intl.readthedocs.io" [project.scripts] sphinx-intl = "sphinx_intl.commands:main" +[build-system] +requires = ["setuptools>=64", "setuptools_scm>=8"] +build-backend = "setuptools.build_meta" + [tool.setuptools] include-package-data = true -[tool.setuptools.dynamic] -version = {attr = "sphinx_intl.__version__"} - -[build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" +[tool.setuptools_scm] +# this empty section means: use_scm_version=True [tool.mypy] ignore_missing_imports = true strict_optional = false + +[tool.uv.sources] +sphinx-intl = { workspace = true } diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 5b80acd..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,6 +0,0 @@ --e.[test] -build -twine -wheel -tox-uv -ruff diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 6f4d040..0000000 --- a/setup.cfg +++ /dev/null @@ -1,17 +0,0 @@ -# 1. initialize -# $ pip install -U build twine - -# 2. TEST build & release: -# $ rm -Rf build/ -# $ python -m build -# $ twine upload --repository-url https://test.pypi.org/legacy/ dist/* - -# 3. PRODUCTION build & release: -# $ rm -Rf build/ -# $ rm setup.cfg -# $ python -m build -# $ twine upload dist/* - -[egg_info] -tag_build = dev -tag_date = true diff --git a/sphinx_intl/__init__.py b/sphinx_intl/__init__.py index ef6497d..d4f135e 100644 --- a/sphinx_intl/__init__.py +++ b/sphinx_intl/__init__.py @@ -1 +1,7 @@ -__version__ = "2.3.2" +from importlib.metadata import version, PackageNotFoundError + +try: + __version__ = version("sphinx_intl") +except PackageNotFoundError: + # package is not installed + pass diff --git a/tox.ini b/tox.ini index 5845d21..abebb07 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ envlist = python = 3.9: py39 3.10: py310 - 3.11: py311 + 3.11: py311, lint, check 3.12: py312 3.13: py313 3.14: py314 @@ -42,22 +42,9 @@ commands=mypy sphinx_intl [testenv:dist] usedevelop=True -deps= - build - twine +deps=twine commands= - {envpython} -m build - twine check dist/* - -[testenv:release] -deps= - build - twine -allowlist_externals=mv -commands= - -mv setup.cfg setup.cfg_ - {envpython} -m build - -mv setup.cfg_ setup.cfg + uv build twine check dist/* [flake8] From 6caf6628a1baf21528c4ab8833eb698f34bb1515 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 03:04:00 +0000 Subject: [PATCH 07/12] fixes path for CI badges. --- README.rst | 4 ++-- doc/dev.rst | 2 +- doc/index.rst | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 276cb2e..54d3f27 100644 --- a/README.rst +++ b/README.rst @@ -24,9 +24,9 @@ Optional: support the Transifex service for translation with Sphinx_ . :alt: License :target: https://github.com/sphinx-doc/sphinx-intl/blob/master/LICENSE -.. image:: https://github.com/sphinx-doc/sphinx-intl/actions/workflows/test.yml/badge.svg?branch=master +.. image:: https://github.com/sphinx-doc/sphinx-intl/actions/workflows/ci.yml/badge.svg?branch=master :alt: GitHub Actions CI status - :target: https://github.com/sphinx-doc/sphinx-intl/actions/workflows/test.yml + :target: https://github.com/sphinx-doc/sphinx-intl/actions/workflows/ci.yml .. image:: https://img.shields.io/github/stars/sphinx-doc/sphinx-intl.svg?style=social&label=Stars :alt: GitHub stars diff --git a/doc/dev.rst b/doc/dev.rst index 62c6945..6b12a25 100644 --- a/doc/dev.rst +++ b/doc/dev.rst @@ -31,7 +31,7 @@ Testing Tests with supported python version that are in: * ``tox.ini`` -* ``.github/workflow/test.yml`` +* ``.github/workflow/ci.yml`` Run test -------- diff --git a/doc/index.rst b/doc/index.rst index 109dd28..9a1cfee 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -23,9 +23,9 @@ Optional: support the Transifex service for translation with Sphinx_ . :alt: License :target: https://github.com/sphinx-doc/sphinx-intl/blob/master/LICENSE -.. image:: https://github.com/sphinx-doc/sphinx-intl/actions/workflows/test.yml/badge.svg?branch=master +.. image:: https://github.com/sphinx-doc/sphinx-intl/actions/workflows/ci.yml/badge.svg?branch=master :alt: GitHub Actions CI status - :target: https://github.com/sphinx-doc/sphinx-intl/actions/workflows/test.yml + :target: https://github.com/sphinx-doc/sphinx-intl/actions/workflows/ci.yml .. image:: https://img.shields.io/github/stars/sphinx-doc/sphinx-intl.svg?style=social&label=Stars :alt: GitHub stars From 052367f5aa1e292580e52b44c5efa2e86c003da4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 2 Aug 2025 09:31:13 +0900 Subject: [PATCH 08/12] Bump astral-sh/setup-uv from 3 to 6 in the all-github-actions group (#124) Bumps the all-github-actions group with 1 update: [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv). Updates `astral-sh/setup-uv` from 3 to 6 - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v3...v6) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major dependency-group: all-github-actions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67e47ea..90de12d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: fetch-depth: 1 - name: Set up Python ${{ matrix.python-version }} - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v6 with: enable-cache: true cache-dependency-glob: "pyproject.toml" @@ -67,7 +67,7 @@ jobs: fetch-depth: 1 - name: Set up Python - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v6 - name: build package run: uv build From abd1dcaf93f7c9b3fb7326e0dbd18433cb0d5306 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Sat, 2 Aug 2025 13:26:56 +0900 Subject: [PATCH 09/12] #123: Release to PyPI with digital attestations (#125) * #123: Release to PyPI with digital attestations PEP 740 - Index support for digital attestations https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ * testing publish to testpypi * testing publish to testpypi * fix syntax error * fetch all commits and tags for setuptools_scm versioning. * setuptools_scm should omit local version that doesn't support PyPI * revert 7d45792e8f829cbc34db73b5d0f795e9c571d648, 63b5d1db177ce68b100c1dc4bfcdae34f3d29b21 * "github release" job uploads for existing tag. * update CHANGES * CI runs on master only * revert name to "Test". this name is used for badge on PyPI. --- .github/workflows/ci.yml | 85 ++++++++++++++++++++++++++-------------- CHANGES.rst | 1 + pyproject.toml | 4 +- 3 files changed, 59 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90de12d..a74582f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,8 @@ name: Test on: push: + branches: + - master paths-ignore: - 'doc/**' pull_request: @@ -31,7 +33,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - fetch-depth: 1 + persist-credentials: false - name: Set up Python ${{ matrix.python-version }} uses: astral-sh/setup-uv@v6 @@ -55,7 +57,7 @@ jobs: build: name: build distribution - if: github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' + if: ${{ github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' }} needs: - tests runs-on: ubuntu-latest @@ -64,7 +66,8 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - fetch-depth: 1 + persist-credentials: false + fetch-depth: 0 - name: Set up Python uses: astral-sh/setup-uv@v6 @@ -78,9 +81,32 @@ jobs: name: distributions path: dist/ - pypi-publish: + publish-to-testpypi: + name: Upload release to TestPyPI + if: ${{ github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' }} # only publish to TestPyPI on push to master + needs: + - build + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/p/sphinx-intl + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: distributions + path: dist/ + - name: Publish package distributions to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true + repository-url: https://test.pypi.org/legacy/ + + publish-to-pypi: name: Upload release to PyPI - if: github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/') + if: ${{ github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/') }} needs: - build runs-on: ubuntu-latest @@ -102,36 +128,35 @@ jobs: with: verbose: true - # for test - password: ${{ secrets.TESTPYPI_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - - # for production - # password: ${{ secrets.PYPI_TOKEN }} - github-release: - name: GitHub release - if: github.repository_owner == 'sphinx-doc' + name: Sign the Python 🐍 distribution 📦 with Sigstore and upload them to GitHub Release + if: ${{ github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest needs: - - pypi-publish + - publish-to-pypi environment: release permissions: - contents: write # for softprops/action-gh-release to create GitHub release - + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Get release version - id: get_version - uses: actions/github-script@v7 + - name: Download all the dists + uses: actions/download-artifact@v4 with: - script: core.setOutput('version', context.ref.replace("refs/tags/", "")) - - - name: Create GitHub release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') + name: distributions + path: dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v3.0.0 with: - name: "sphinx-intl ${{ steps.get_version.outputs.version }}" - body: "Changelog: https://sphinx-intl.readthedocs.io/en/master/changes.html" + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + "$GITHUB_REF_NAME" dist/** + --repo "$GITHUB_REPOSITORY" diff --git a/CHANGES.rst b/CHANGES.rst index 9e87ded..b7eeef9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,7 @@ Environments ------------ * add python-3.14 support by @rffontenelle in https://github.com/sphinx-doc/sphinx-intl/pull/115 +* Release to PyPI with digital attestations (PEP-740) by @shimizukawa in https://github.com/sphinx-doc/sphinx-intl/pull/125 Incompatibility --------------- diff --git a/pyproject.toml b/pyproject.toml index 584b98d..e86e3da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,9 @@ build-backend = "setuptools.build_meta" include-package-data = true [tool.setuptools_scm] -# this empty section means: use_scm_version=True +# https://setuptools-scm.readthedocs.io/en/latest/extending/#available-implementations_1 +# because pypi does not support local version like .devN+ +local_scheme = "no-local-version" [tool.mypy] ignore_missing_imports = true From 3dc8257efa1da950cae1ead5dbf280c614c84b09 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Sat, 2 Aug 2025 04:31:50 +0000 Subject: [PATCH 10/12] update changes for 2.3.2 release --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index b7eeef9..34984b7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,7 +2,7 @@ CHANGES ======= -2.3.2 (unreleased) +2.3.2 (2025/08/02) ================== Environments From 4a0194697a1b2811c402fcd0ac721ea880ce192f Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Sat, 2 Aug 2025 04:34:47 +0000 Subject: [PATCH 11/12] update changes for 2.3.2 release --- CHANGES.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 34984b7..e21c90d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,7 +20,7 @@ Features Bug Fixes --------- -- #116: Update doesn't respect default value of locale_dirs from -c passed conf.py +- #116: Update doesn't respect default value of locale_dirs from `-c` passed `conf.py` by @shimizukawa in https://github.com/sphinx-doc/sphinx-intl/pull/122 Documentation ------------- @@ -28,6 +28,10 @@ Documentation Internals --------- +* FIX: set `exist_ok=True` in `os.makedirs()` by @Dengda98 in https://github.com/sphinx-doc/sphinx-intl/pull/120 +* using uv for dev setup, build, publish by @shimizukawa in https://github.com/sphinx-doc/sphinx-intl/pull/114 +* Bump astral-sh/setup-uv from 3 to 6 in the all-github-actions group by @dependabot[bot] in https://github.com/sphinx-doc/sphinx-intl/pull/124 + 2.3.1 (2024/12/01) ================== From 1810688a811d43317f402e8b7b009455bf21381e Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Sat, 2 Aug 2025 04:45:10 +0000 Subject: [PATCH 12/12] fix CI for build condition --- .github/workflows/ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a74582f..9d20b6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,13 @@ jobs: build: name: build distribution - if: ${{ github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' }} + if: | + ${{ github.repository_owner == 'sphinx-doc' && + ( + ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) + || ( github.event_name == 'release' ) + ) + }} needs: - tests runs-on: ubuntu-latest