From 7a3f6e243e560597709134776f55d814b72ba6d4 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 02:05:31 +0000 Subject: [PATCH 1/7] using uv for dev setup, build, publish --- .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 | 22 +++-- setup.cfg | 17 ---- sphinx_intl/__init__.py | 8 +- tox.ini | 19 +--- 11 files changed, 176 insertions(+), 134 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/test.yml 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..aadd20b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,137 @@ +name: Test +on: + push: + paths-ignore: + - 'doc/**' + pull_request: + paths-ignore: + - 'doc/**' + tags: + - '*' + +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..629c5b5 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. 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..ec0c4b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,13 @@ test = [ "pytest", ] +[dependency-groups] +dev = [ + "pytest", + "ruff>=0.8.0", + "tox-uv>=1.16.0", +] + [project.urls] Homepage = "https://github.com/sphinx-doc/sphinx-intl" Documentation = "https://sphinx-intl.readthedocs.io" @@ -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/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 22770a08d8821fc495fa8bea9e9abb376fd12e20 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 02:05:31 +0000 Subject: [PATCH 2/7] fix github actions trigger --- .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 aadd20b..67e47ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,8 +6,8 @@ on: pull_request: paths-ignore: - 'doc/**' - tags: - - '*' + release: + types: [released] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} From 09561a02d780240de17825ba5445a9a96826e008 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 02:05:31 +0000 Subject: [PATCH 3/7] add missing tox-gh-actions --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ec0c4b9..40ddc65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ test = [ dev = [ "pytest", "ruff>=0.8.0", + "tox-gh-actions>=3.2.0", "tox-uv>=1.16.0", ] From c3af31fd2039cbfe17fc2c1562a89d2878e15315 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 02:05:31 +0000 Subject: [PATCH 4/7] remove requirements-dev.txt --- requirements-dev.txt | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 requirements-dev.txt 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 From 01aa7ddd5a7c62ebeeaf8e6e0543d8efef0f741d Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 02:05:31 +0000 Subject: [PATCH 5/7] update release procedure to clarify version bumping for next release --- checklist.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checklist.rst b/checklist.rst index 629c5b5..ced37e1 100644 --- a/checklist.rst +++ b/checklist.rst @@ -6,4 +6,4 @@ Procedure: 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. bump version in ``CHANGES.rst`` then commit/push it onto GitHub +4. prepareing for the next release: bump version in ``CHANGES.rst`` then commit/push it onto GitHub From cd4d4a71d7e8391597ab7d285d75a387a1c87ef9 Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 02:05:31 +0000 Subject: [PATCH 6/7] update versions for dependencies --- pyproject.toml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 40ddc65..318caaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,9 +9,8 @@ readme = "README.rst" requires-python = ">=3.9" license = {file = "LICENSE"} dependencies = [ - "setuptools", - "click", - "babel", + "click>=8.0.0", + "babel>=2.9.0", "sphinx", ] classifiers = [ @@ -37,15 +36,15 @@ classifiers = [ [project.optional-dependencies] test = [ - "pytest", + "pytest>=8.3.5", ] [dependency-groups] dev = [ - "pytest", - "ruff>=0.8.0", - "tox-gh-actions>=3.2.0", - "tox-uv>=1.16.0", + "pytest>=8.3.5", + "ruff>=0.11.10", + "tox-gh-actions>=3.3.0", + "tox-uv>=1.25.0", ] [project.urls] From 44b25b979a07b386a2b0c377804b767baba2b87a Mon Sep 17 00:00:00 2001 From: Takayuki SHIMIZUKAWA Date: Mon, 21 Jul 2025 02:16:19 +0000 Subject: [PATCH 7/7] adapt LICENSE metadata to SPDX expression https://packaging.python.org/en/latest/specifications/license-expression/ --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 318caaf..584b98d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,8 @@ 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 = [ "click>=8.0.0", "babel>=2.9.0", @@ -16,7 +17,6 @@ dependencies = [ classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Console", - "License :: OSI Approved :: BSD License", "Topic :: Documentation", "Topic :: Documentation :: Sphinx", "Topic :: Software Development",