Skip to content

Commit f4fbf4a

Browse files
committed
using uv for dev setup, build, publish
1 parent 5524d1b commit f4fbf4a

File tree

11 files changed

+176
-134
lines changed

11 files changed

+176
-134
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+
tags:
10+
- '*'
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']
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. 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: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,33 @@ test = [
3939
"pytest",
4040
]
4141

42+
[dependency-groups]
43+
dev = [
44+
"pytest",
45+
"ruff>=0.8.0",
46+
"tox-uv>=1.16.0",
47+
]
48+
4249
[project.urls]
4350
Homepage = "https://github.com/sphinx-doc/sphinx-intl"
4451
Documentation = "https://sphinx-intl.readthedocs.io"
4552

4653
[project.scripts]
4754
sphinx-intl = "sphinx_intl.commands:main"
4855

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

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

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

setup.cfg

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

sphinx_intl/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
__version__ = "2.3.0"
1+
from importlib.metadata import version, PackageNotFoundError
2+
3+
try:
4+
__version__ = version("sphinx_intl")
5+
except PackageNotFoundError:
6+
# package is not installed
7+
pass

0 commit comments

Comments
 (0)