Skip to content

Commit 3a4e235

Browse files
authored
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/
1 parent 2d409a3 commit 3a4e235

File tree

12 files changed

+182
-146
lines changed

12 files changed

+182
-146
lines changed

.devcontainer/on_create_command.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
set -ex
55

6-
pip install -U pip setuptools wheel setuptools_scm
7-
pip install -r requirements-dev.txt
6+
curl -LsSf https://astral.sh/uv/install.sh | sh
7+
. $HOME/.cargo/env
8+
uv tool install -U ruff
9+
uv tool install -U tox --with tox-uv
810

911
# Install Transifex CLI tool into /usr/local/bin
1012
# refer to Installation instructions https://github.com/transifex/cli#installation

.github/workflows/ci.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Test
2+
on:
3+
push:
4+
paths-ignore:
5+
- 'doc/**'
6+
pull_request:
7+
paths-ignore:
8+
- 'doc/**'
9+
release:
10+
types: [released]
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
tests:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
max-parallel: 5
22+
matrix:
23+
python-version: [3.9, '3.10', '3.11', '3.12', '3.13', '3.14']
24+
25+
steps:
26+
- name: Print github context
27+
env:
28+
GITHUB_CONTEXT: ${{ toJson(github) }}
29+
run: echo $GITHUB_CONTEXT
30+
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 1
35+
36+
- name: Set up Python ${{ matrix.python-version }}
37+
uses: astral-sh/setup-uv@v3
38+
with:
39+
enable-cache: true
40+
cache-dependency-glob: "pyproject.toml"
41+
cache-suffix: ${{ matrix.python-version }}
42+
43+
- name: Install Python
44+
run: uv python install ${{ matrix.python-version }}
45+
env:
46+
UV_PYTHON_PREFERENCE: only-managed
47+
48+
- name: Install Transifex CLI
49+
run: |
50+
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
51+
mv tx /usr/local/bin/tx
52+
53+
- name: Tox tests
54+
run: uv run --only-dev tox -- -v --durations=25
55+
56+
build:
57+
name: build distribution
58+
if: github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master'
59+
needs:
60+
- tests
61+
runs-on: ubuntu-latest
62+
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 1
68+
69+
- name: Set up Python
70+
uses: astral-sh/setup-uv@v3
71+
72+
- name: build package
73+
run: uv build
74+
75+
- name: upload artifact
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: distributions
79+
path: dist/
80+
81+
pypi-publish:
82+
name: Upload release to PyPI
83+
if: github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/')
84+
needs:
85+
- build
86+
runs-on: ubuntu-latest
87+
environment:
88+
name: pypi
89+
url: https://pypi.org/p/sphinx-intl
90+
permissions:
91+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
92+
93+
steps:
94+
- name: Download all the dists
95+
uses: actions/download-artifact@v4
96+
with:
97+
name: distributions
98+
path: dist/
99+
100+
- name: Publish package distributions to PyPI
101+
uses: pypa/gh-action-pypi-publish@release/v1
102+
with:
103+
verbose: true
104+
105+
# for test
106+
password: ${{ secrets.TESTPYPI_TOKEN }}
107+
repository_url: https://test.pypi.org/legacy/
108+
109+
# for production
110+
# password: ${{ secrets.PYPI_TOKEN }}
111+
112+
github-release:
113+
name: GitHub release
114+
if: github.repository_owner == 'sphinx-doc'
115+
runs-on: ubuntu-latest
116+
needs:
117+
- pypi-publish
118+
environment: release
119+
permissions:
120+
contents: write # for softprops/action-gh-release to create GitHub release
121+
122+
steps:
123+
- uses: actions/checkout@v4
124+
with:
125+
persist-credentials: false
126+
- name: Get release version
127+
id: get_version
128+
uses: actions/github-script@v7
129+
with:
130+
script: core.setOutput('version', context.ref.replace("refs/tags/", ""))
131+
132+
- name: Create GitHub release
133+
uses: softprops/action-gh-release@v2
134+
if: startsWith(github.ref, 'refs/tags/')
135+
with:
136+
name: "sphinx-intl ${{ steps.get_version.outputs.version }}"
137+
body: "Changelog: https://sphinx-intl.readthedocs.io/en/master/changes.html"

.github/workflows/test.yml

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

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
uv.lock
2+
13
# Created by https://www.toptal.com/developers/gitignore/api/python
24
# Edit at https://www.toptal.com/developers/gitignore?templates=python
35

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
include *.rst
2-
include requirements-*.txt
32
include tox.ini
43
recursive-include tests *
54
prune tests/__pycache__

checklist.rst

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
33
Procedure:
44

5-
1. check GitHub Actions test results: https://github.com/sphinx-doc/sphinx-intl/actions
6-
2. update release version/date in ``CHANGES.rst``
7-
3. ``python -m build``, see details: setup.cfg
8-
4. ``twine upload dist/<target-package-file>``
9-
5. check PyPI page: https://pypi.org/p/sphinx-intl
10-
6. tagging with version name that MUST following semver. e.g.: ``git tag 1.0.1``
11-
7. ``git push --tags`` to push tag
12-
8. bump version in ``sphinx_intl/__init__.py`` and ``CHANGES.rst`` then commit/push
13-
them onto GitHub
5+
1. update release version/date in ``CHANGES.rst``
6+
2. create GitHub Release with new version tag, it will create a release on PyPI.
7+
tag MUST following semver. e.g.: ``2.3.1``
8+
3. check PyPI page: https://pypi.org/p/sphinx-intl
9+
4. prepareing for the next release: bump version in ``CHANGES.rst`` then commit/push it onto GitHub

doc/dev.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Setup development environment
1818
* Requires supported Python version
1919
* Do setup under sphinx-intl.git repository root as::
2020

21-
$ pip install -U pip setuptools wheel setuptools_scm
22-
$ pip install -r requirements-dev.txt
21+
$ pip install -U uv
22+
$ uv sync
2323

2424
* Install Transifex CLI tool (refer to `Installation instructions <https://github.com/transifex/cli>`_)::
2525

pyproject.toml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@ authors = [
77
description = "Sphinx utility that make it easy to translate and to apply translation."
88
readme = "README.rst"
99
requires-python = ">=3.9"
10-
license = {file = "LICENSE"}
10+
license = "BSD-2-Clause"
11+
license-files = ["LICENSE"]
1112
dependencies = [
12-
"setuptools",
13-
"click",
14-
"babel",
13+
"click>=8.0.0",
14+
"babel>=2.9.0",
1515
"sphinx",
1616
]
1717
classifiers = [
1818
"Development Status :: 5 - Production/Stable",
1919
"Environment :: Console",
20-
"License :: OSI Approved :: BSD License",
2120
"Topic :: Documentation",
2221
"Topic :: Documentation :: Sphinx",
2322
"Topic :: Software Development",
@@ -37,7 +36,15 @@ classifiers = [
3736

3837
[project.optional-dependencies]
3938
test = [
40-
"pytest",
39+
"pytest>=8.3.5",
40+
]
41+
42+
[dependency-groups]
43+
dev = [
44+
"pytest>=8.3.5",
45+
"ruff>=0.11.10",
46+
"tox-gh-actions>=3.3.0",
47+
"tox-uv>=1.25.0",
4148
]
4249

4350
[project.urls]
@@ -47,16 +54,19 @@ Documentation = "https://sphinx-intl.readthedocs.io"
4754
[project.scripts]
4855
sphinx-intl = "sphinx_intl.commands:main"
4956

57+
[build-system]
58+
requires = ["setuptools>=64", "setuptools_scm>=8"]
59+
build-backend = "setuptools.build_meta"
60+
5061
[tool.setuptools]
5162
include-package-data = true
5263

53-
[tool.setuptools.dynamic]
54-
version = {attr = "sphinx_intl.__version__"}
55-
56-
[build-system]
57-
requires = ["setuptools", "wheel"]
58-
build-backend = "setuptools.build_meta"
64+
[tool.setuptools_scm]
65+
# this empty section means: use_scm_version=True
5966

6067
[tool.mypy]
6168
ignore_missing_imports = true
6269
strict_optional = false
70+
71+
[tool.uv.sources]
72+
sphinx-intl = { workspace = true }

requirements-dev.txt

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

setup.cfg

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

0 commit comments

Comments
 (0)