Skip to content

Commit d13a4f0

Browse files
committed
chore: migrate to flit
1 parent fca3763 commit d13a4f0

File tree

8 files changed

+89
-496
lines changed

8 files changed

+89
-496
lines changed

.github/workflows/test-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
- name: Set up Python
2020
run: uv python install
2121
- name: Test and lint
22-
run: uv run nox -s test mypy ruff_check
22+
run: uv run nox -t test lint

docs/changelog.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ Changelog
44
Unreleased
55
**********
66

7-
A maintenance release with no new features, but with some code and legal clean-up.
7+
A maintenance release with no new features, but with important code clean-up, dependencies update and modernization.
88

9-
- minimal Python >= 3.11
10-
- minimal Sphinx >= 7.4
9+
- require Python >= 3.11
10+
- require Sphinx >= 7.4
1111
- change license from BSD3 to MIT
1212
- migrate from pip to uv
1313
- migrate from tox to nox
14+
- migrate from Build/Twine to Flit
1415

1516
0.1.6 (2025-03-22)
1617
******************

noxfile.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def install_dependencies(session: nox.Session, *args, **kwargs) -> None:
4545
# To invoke session(s), use "nox -s <name1>" or "nox -s <name1> <name2>"
4646

4747

48-
@nox.session(python=SUPPORTED_PYTHONS)
48+
@nox.session(python=SUPPORTED_PYTHONS, tags=["test"])
4949
@nox.parametrize("sphinx", SUPPORTED_SPHINX_VERSIONS)
5050
def test(session, sphinx):
5151
"""Run tests with different Python and Sphinx versions."""
@@ -56,23 +56,45 @@ def test(session, sphinx):
5656
session.run("pytest")
5757

5858

59-
@nox.session(python=SUPPORTED_PYTHONS[-1:]) # Use the last Python version
59+
@nox.session(tags=["lint"])
6060
def mypy(session: nox.Session) -> None:
6161
"""Run mypy."""
6262
install_dependencies(session)
6363
session.run("mypy", "sphinx_reredirects")
6464

6565

66-
@nox.session(python=SUPPORTED_PYTHONS[-1:]) # Use the last Python version
66+
@nox.session(tags=["lint"])
6767
def ruff_check(session: nox.Session) -> None:
6868
"""Run Ruff check."""
69-
install_dependencies(session)
69+
install_dependencies(session, "--only-dev")
7070
session.run("ruff", "check")
7171

7272

73-
@nox.session(python=SUPPORTED_PYTHONS[-1:]) # Use the last Python version
74-
def build(session: nox.Session) -> None:
75-
"""Build the package."""
76-
install_dependencies(session)
77-
session.run("rm", "-rf", "dist", external=True)
78-
session.run("flit", "build")
73+
@nox.session()
74+
def publish_to_test_pypi(session: nox.Session) -> None:
75+
"""Build and publish the package to test PyPI. You will be asked for token. See `docs/releasing.md` for full instructions."""
76+
install_dependencies(session, "--only-dev")
77+
78+
session.run(
79+
"flit",
80+
"publish",
81+
env={
82+
"FLIT_INDEX_URL": "https://test.pypi.org/legacy/",
83+
"FLIT_USERNAME": "__token__",
84+
},
85+
)
86+
87+
88+
@nox.session()
89+
def publish_to_real_pypi(session: nox.Session) -> None:
90+
"""Build and publish the package to real PyPI. You will be asked for token. See `docs/releasing.md` for full instructions."""
91+
install_dependencies(session, "--only-dev")
92+
93+
session.run(
94+
"flit",
95+
"publish",
96+
env={
97+
"FLIT_INDEX_URL": "https://pypi.org/legacy/",
98+
"FLIT_USERNAME": "__token__",
99+
},
100+
)

pyproject.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ maintainers = [
88
]
99
requires-python = ">=3.11"
1010
dependencies = [
11-
"sphinx>=7.4,<9.0"
11+
"sphinx>=7.4,<9.0",
1212
]
1313
classifiers = [
1414
"Framework :: Sphinx :: Extension",
@@ -31,12 +31,11 @@ repository = "https://github.com/documatt/sphinx-reredirects"
3131

3232
[dependency-groups]
3333
dev = [
34-
"flit>=3.12.0",
35-
"mypy>=1.16.0",
36-
"nox>=2025.5.1",
37-
"pytest>=8.3.5",
38-
"ruff>=0.11.12",
39-
"twine>=6.1.0",
34+
"flit==3.12.0",
35+
"mypy==1.16.0",
36+
"nox==2025.5.1",
37+
"pytest==8.3.5",
38+
"ruff==0.11.12",
4039
]
4140

4241
[build-system]

releasing.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# How to release new version
2+
3+
## Part 1: Git release
4+
5+
1. Choose a version value. git-cliff also calculate new version number based on Git history.
6+
7+
1. Create branch `release/v<version>`.
8+
9+
1. Update `CHANGELOG.md`. Either manually or with git-cliff tool (e.g., `git-cliff --prepend CHANGELOG.md --bump --unreleased`)
10+
11+
1. Fine tune `CHANGELOG.md`. Reorder, fix typos, reword, etc.
12+
13+
1. Set new version to `__version__` variable in `<package>/__init__.py`.
14+
15+
1. Create "release commit" containing changes to `<package>/__init__.py` with message `chore: release vX.Y.Z`. Release commit may contain other changes too, like to `CHANGELOG.md` and so on.
16+
17+
1. Create PR for branch. Wait for tests, linters. Do a code review. Merge to main branch.
18+
19+
1. Create tag `vX.Y.Z` on release commit.
20+
21+
```sh
22+
git tag -a vX.Y.Z
23+
git push origin HEAD
24+
```
25+
26+
## Part 2: PyPI release
27+
28+
1. Upload to TestPyPI.
29+
30+
```sh
31+
uv run nox -s publish_to_test_pypi
32+
```
33+
34+
and go to https://test.pypi.org/project/sphinx-reredirects/<version>/
35+
36+
1. If you are happy with it, upload to real PyPI.
37+
38+
```sh
39+
uv run nox -s publish_to_real_pypi
40+
```

releasing.rst

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

tox.ini

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

0 commit comments

Comments
 (0)