Skip to content

Commit cdf9e58

Browse files
authored
🔧 Replace rye with tox and add sphinx-needs version matrix (#65)
Rye was only used for script shortcuts and dev dependency management, duplicating what tox already provides. Consolidating on tox as the single task runner simplifies onboarding (one tool to install), removes the custom setup_rye GitHub Action, and makes CI consistent with local development workflows. The test matrix now includes sphinx-needs as a third axis (py{312,313,314}-sphinx{7,8,9}-needs{5,6,7,8}), enabling detection of compatibility issues across the full support range. CI runs the boundary combinations — minimal (py312-sphinx7-needs5) and maximal (py314-sphinx8-needs8) — to catch regressions without excessive job count. - Remove [tool.rye] and [tool.rye.scripts] from pyproject.toml - Delete .github/actions/setup_rye/ composite action - Update CI workflows (ci, coverage, gh_pages) to use tox + tox-uv - Add sphinx-needs version factors to tox.ini test environments - Add tox demo environment replacing rye demo:clean chain - Update AGENTS.md, contributing.rst, and demo README
1 parent 32baf80 commit cdf9e58

13 files changed

Lines changed: 114 additions & 114 deletions

File tree

.github/actions/setup_rye/action.yml

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

.github/workflows/ci.yml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,63 @@ jobs:
3737

3838
steps:
3939
- uses: actions/checkout@v4
40-
- uses: ./.github/actions/setup_rye
41-
- run: rye run mypy:all
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version-file: ".python-version"
43+
- run: python -m pip install tox tox-uv
44+
- run: tox -e mypy
4245

4346
pytest:
44-
name: Pytest (${{ matrix.os }})
47+
name: "Pytest: ${{ matrix.tox-env }} (${{ matrix.os }})"
4548
strategy:
4649
fail-fast: false
4750
matrix:
4851
include:
52+
# minimal versions
4953
- os: ubuntu-latest
54+
python: "3.12"
55+
tox-env: py312-sphinx7-needs5
56+
# maximal versions
57+
- os: ubuntu-latest
58+
python: "3.14"
59+
tox-env: py314-sphinx8-needs8
60+
# minimal version on Windows
61+
- os: windows-latest
62+
python: "3.14"
63+
tox-env: py312-sphinx7-needs5
64+
# maximal versions on other OSes
5065
- os: ubuntu-24.04-arm
66+
python: "3.14"
67+
tox-env: py314-sphinx8-needs8
5168
- os: windows-latest
69+
python: "3.14"
70+
tox-env: py314-sphinx8-needs8
5271
- os: macos-latest
72+
python: "3.14"
73+
tox-env: py314-sphinx8-needs8
5374

54-
runs-on: ["${{ matrix.os }}"]
75+
runs-on: ${{ matrix.os }}
5576

5677
steps:
5778
- uses: actions/checkout@v4
58-
- uses: ./.github/actions/setup_rye
59-
- run: rye test -a
79+
- uses: actions/setup-python@v5
80+
with:
81+
python-version: "${{ matrix.python }}"
82+
allow-prereleases: true
83+
- run: python -m pip install tox tox-uv
84+
- run: tox -e "${{ matrix.tox-env }}"
6085

6186
docs:
6287
name: Documentation build
6388
runs-on: ubuntu-latest
6489

6590
steps:
6691
- uses: actions/checkout@v4
67-
- uses: ./.github/actions/setup_rye
68-
- name: Run documentation build
69-
run: rye run docs
92+
- uses: actions/setup-python@v5
93+
with:
94+
python-version-file: ".python-version"
95+
- run: python -m pip install tox tox-uv
96+
- run: tox -e docs-clean
7097

7198
all_good:
7299
# This job does nothing and is only used for the branch protection

.github/workflows/coverage.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ jobs:
1212

1313
- name: Set up Python
1414
uses: actions/setup-python@v5
15+
with:
16+
python-version-file: ".python-version"
1517

16-
- name: Setup rye
17-
uses: ./.github/actions/setup_rye
18+
- name: Install tox
19+
run: python -m pip install tox tox-uv
1820

1921
- name: Run tests
20-
run: rye test -a -- --cov --cov-branch --cov-report=xml
22+
run: tox -e py312-sphinx8-needs5 -- --cov --cov-branch --cov-report=xml
2123

2224
- name: Upload results to Codecov
2325
uses: codecov/codecov-action@v5

.github/workflows/gh_pages.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ jobs:
3131
- name: Setup Pages
3232
id: pages
3333
uses: actions/configure-pages@v5
34-
- uses: eifinger/setup-rye@v4
35-
- run: rye sync
34+
- uses: actions/setup-python@v5
35+
with:
36+
python-version-file: ".python-version"
37+
- run: python -m pip install tox tox-uv
3638
- name: Run documentation build
37-
run: rye run docs
39+
run: tox -e docs-clean
3840
- name: Upload artifact
3941
uses: actions/upload-pages-artifact@v3
4042
with:

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.DS_Store
2+
13
# python generated files
24
.ruff_cache
35
.pytest_cache
@@ -17,7 +19,7 @@ requirements-dev.lock
1719
# Sphinx build output
1820
**/_build
1921

20-
# rye is the primary tool, uv is only used for on-the-fly setups
22+
# uv lock file
2123
uv.lock
2224

2325
# coverage files
@@ -26,3 +28,5 @@ coverage.xml
2628
invalid_objs.json
2729

2830
.tox
31+
32+
output/

AGENTS.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,27 @@ All commands should be run via [`tox`](https://tox.wiki) for consistency. The pr
6767

6868
### Testing
6969

70+
Test environments follow the pattern `py{VERSION}-sphinx{MAJOR}-needs{MAJOR}`,
71+
e.g. `py312-sphinx8-needs5`. Use `tox -a` to list all available combinations.
72+
7073
```bash
7174
# Run default test environment
7275
tox
7376

74-
# Run tests for specific Python/Sphinx combination
75-
tox -e py312-sphinx8
77+
# Run tests for a specific Python/Sphinx/sphinx-needs combination
78+
tox -e py312-sphinx8-needs5
7679

7780
# Run a specific test file
78-
tox -e py312-sphinx8 -- tests/test_analyse.py
81+
tox -e py312-sphinx8-needs5 -- tests/test_analyse.py
7982

8083
# Run a specific test function
81-
tox -e py312-sphinx8 -- tests/test_analyse.py::test_function_name
84+
tox -e py312-sphinx8-needs5 -- tests/test_analyse.py::test_function_name
8285

8386
# Run with coverage
84-
tox -e py312-sphinx8 -- --cov=sphinx_codelinks
87+
tox -e py312-sphinx8-needs5 -- --cov=sphinx_codelinks
8588

8689
# Update snapshot test fixtures
87-
tox -e py312-sphinx8 -- --snapshot-update
90+
tox -e py312-sphinx8-needs5 -- --snapshot-update
8891
```
8992

9093
### Documentation
@@ -385,10 +388,10 @@ The CLI uses Typer for command definitions:
385388

386389
## Debugging
387390

388-
- Use `--pdb` with pytest to drop into debugger on failures: `tox -e py312-sphinx8 -- --pdb`
389-
- Use `-v` for verbose test output: `tox -e py312-sphinx8 -- -v`
391+
- Use `--pdb` with pytest to drop into debugger on failures: `tox -e py312-sphinx8-needs5 -- --pdb`
392+
- Use `-v` for verbose test output: `tox -e py312-sphinx8-needs5 -- -v`
390393
- Build docs with `-T` flag for full tracebacks: `tox -e docs-clean -- -T`
391-
- Set logging level in tests: `tox -e py312-sphinx8 -- --log-cli-level=DEBUG`
394+
- Set logging level in tests: `tox -e py312-sphinx8-needs5 -- --log-cli-level=DEBUG`
392395
- Use `debug.py` module functions for development debugging
393396

394397
## Common Patterns

docs/source/development/change_log.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Changelog
44
=========
55

6+
Upcoming
7+
--------
8+
9+
- ⬆️ Support and test sphinx-needs v5-8
10+
611
.. _`release:1.2.0`:
712

813
1.2.0

docs/source/development/contributing.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ Your PR should conform with the following rules:
2222
Install Dependencies
2323
--------------------
2424

25-
``CodeLinks`` uses `rye <https://rye.astral.sh/>`_ to manage the repository.
25+
``CodeLinks`` uses `tox <https://tox.wiki/>`_ (with `tox-uv <https://github.com/tox-dev/tox-uv>`_) to manage development tasks.
2626

27-
For development, use the following command to install Python dependencies into the virtual environment.
27+
Install tox with pip or uv:
2828

2929
.. code-block:: bash
3030
31-
rye sync
31+
pip install tox tox-uv
32+
uv tool install tox --with tox-uv
3233
3334
Formatting, Linting and Typing
3435
------------------------------
@@ -44,7 +45,7 @@ The CI also checks typing. Use the following command locally to see if your code
4445

4546
.. code-block:: bash
4647
47-
rye run mypy:all
48+
tox -e mypy
4849
4950
Build docs
5051
----------
@@ -53,7 +54,7 @@ To build the documentation stored in ``docs``, run:
5354

5455
.. code-block:: bash
5556
56-
rye run docs
57+
tox -e docs-clean
5758
5859
Test Cases
5960
----------
@@ -62,7 +63,7 @@ To run test cases locally:
6263

6364
.. code-block:: bash
6465
65-
rye test -a
66+
tox -e py312-sphinx8
6667
6768
Note some tests use `syrupy <https://github.com/tophat/syrupy>`__ to perform snapshot testing.
6869
These snapshots can be updated by running:

pyproject.toml

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies = [
1717
"click < 8.2", # click 8.2.* produces empty errors if no args are given
1818
"jsonschema",
1919
"sphinx>=7.4,<9",
20-
"sphinx-needs>=4.2.0", # unconstrained versions, to be pinned by user or Sphinx
20+
"sphinx-needs>=5,<9",
2121
"jinja2",
2222
"pygments",
2323
"docutils", # constrained by user or Sphinx
@@ -66,64 +66,9 @@ mypy = [
6666
ruff = ["ruff>=0.8.0"]
6767
build = ["simple-build>=0.0.2", "shiv>=1.0.8"]
6868

69-
[tool.rye]
70-
managed = true
71-
dev-dependencies = [
72-
"types-docutils",
73-
"types-Pygments",
74-
"syrupy>=4.9.1",
75-
"furo>=2024.5.6",
76-
"moto ~= 5.0",
77-
"mypy>=1.12.1",
78-
"myst-parser>=4.0.0",
79-
"pydantic ~= 2.9",
80-
"pip-licenses>=5.0.0",
81-
"psutil>=7.0.0",
82-
"pytest-cov>=5.0.0",
83-
"pytest>=8.2.2",
84-
"simple-build>=0.0.2",
85-
"sphinx-design>=0.6.1",
86-
"types-psutil>=7.0.0.20250218",
87-
"uv>=0.5.5",
88-
"pytest-docker>=3.1.2",
89-
"shiv>=1.0.8",
90-
"insta-science>=0.2.1",
91-
"types-jsonschema>=4.23.0.20241208",
92-
"toml>=0.10.2",
93-
"sphinx-code-tabs>=0.5.5",
94-
"sphinxcontrib-typer>=0.5.1",
95-
"sphinxcontrib-video>=0.4.1",
96-
]
97-
9869
[project.scripts]
9970
codelinks = "sphinx_codelinks.cmd:app"
10071

101-
[tool.rye.scripts]
102-
# linting and formatting
103-
"mypy:all" = "mypy ."
104-
"rye:lint" = "rye lint"
105-
"rye:format" = "rye format"
106-
"check" = { chain = ["rye:format", "rye:lint", "mypy:all"] }
107-
# docs html
108-
"docs:rm" = "rm -rf docs/_build/html"
109-
"docs" = "sphinx-build -nW --keep-going -b html -T -c docs docs/source docs/_build/html"
110-
"docs:clean" = { chain = ["docs:rm", "docs"] }
111-
# needextend demo
112-
"analyse" = "codelinks analyse tests/data/configs/minimum_config.toml"
113-
"analyse:rm" = "rm -rf output/marked_content.json"
114-
"write" = "codelinks write rst output/marked_content.json --outpath tests/data/needextend_demo/needextend.rst"
115-
"write:rm" = "rm -rf tests/data/needextend_demo/needextend.rst"
116-
"demo:rm" = "rm -rf tests/data/needextend_demo/_build"
117-
"demo:build" = "sphinx-build -nW --keep-going -b html -T -c tests/data/needextend_demo tests/data/needextend_demo tests/data/needextend_demo/_build/html"
118-
"demo:clean" = { chain = [
119-
"demo:rm",
120-
"analyse:rm",
121-
"write:rm",
122-
"analyse",
123-
"write",
124-
"demo:build",
125-
] }
126-
12772
[tool.ruff.lint]
12873
extend-select = [
12974
# "ANN",
@@ -162,15 +107,6 @@ force-sort-within-sections = true
162107
"PLR2004", # magic-value-comparison - valueable for tests
163108
"S101", # assert - needed for tests
164109
]
165-
"**/build_hooks_*/**" = [
166-
"S607", # start-process-with-partial-path - pyarmor call in rye context
167-
"S603", # subprocess-without-shell-equals-true - pyarmor call
168-
]
169-
"scripts/*.py" = [
170-
"T201", # print - used for output
171-
"S607", # start-process-with-partial-path - pyarmor call in rye context
172-
"S603", # subprocess-without-shell-equals-true - build scripts
173-
]
174110
"src/sphinx_codelinks/sphinx_extension/debug.py" = [
175111
"T201", # print - used for output
176112
"UP047", # on-pep695-generic-function - it's generic

tests/data/needextend_demo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
Run the following command in project root to have demo generated
44

55
```bash
6-
rye run demo:clean
6+
tox -e demo
77
```

0 commit comments

Comments
 (0)