Skip to content

Commit 7e7c623

Browse files
authored
ci: Fix doc dependency resolving (#475)
* uv somehow decides to constrain libraries to be compatible with the whole range of python versions supported by torchjd (3.10-3.13) when resolving, so it does not install libraries that require python 3.11+ for example, even when using python 3.13. This leads to outdated library versions installed in the CI and locally, especially documentation-related libraries. * Adding --python-version=... forces uv to resolve libraries compatible with the specified python version only, fixing the issue * When using `uv run ...`, uv automatically re-syncs. There's no way to specify the python-version for which to resolve when this happens, so the idea is to prevent this resyncing by either using --no-sync everytime we call uv run, or by using the UV_NO_SYNC=1 environment variable. This is done in both ci files that have a uv run, and it's now recommended in CONTRIBUTING.md * Uncap furo (our sphinx theme): it just changes color of already-clicked links, which is not that bad IMO (and we can probably override this). It's also required for compatibility with more recent versions of other libraries. * Increase lower cap of sphinx-autodoc-typehints. Before 3.5.0, it's not compatible with Python 3.14.
1 parent 878bf9b commit 7e7c623

File tree

5 files changed

+39
-14
lines changed

5 files changed

+39
-14
lines changed

.github/workflows/build-deploy-docs.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
tags:
77
- 'v[0-9]*.[0-9]*.[0-9]*'
88

9+
env:
10+
UV_NO_SYNC: 1
11+
PYTHON_VERSION: '3.13'
12+
913
jobs:
1014
build-deploy-doc:
1115
name: Build & deploy doc
@@ -20,10 +24,10 @@ jobs:
2024
- name: Set up uv
2125
uses: astral-sh/setup-uv@v5
2226
with:
23-
python-version: '3.13'
27+
python-version: ${{ env.PYTHON_VERSION }}
2428

2529
- name: Install dependencies (default with full options & doc)
26-
run: uv pip install '.[full]' --group doc
30+
run: uv pip install --python-version=${{ env.PYTHON_VERSION }} '.[full]' --group doc
2731

2832
- name: Determine deployment folder
2933
id: deploy_folder

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
release:
55
types: [published]
66

7+
env:
8+
PYTHON_VERSION: 3.13
9+
710
jobs:
811
pypi-publish:
912
name: Publish to PyPI
@@ -19,7 +22,7 @@ jobs:
1922
- name: Set up uv
2023
uses: astral-sh/setup-uv@v5
2124
with:
22-
python-version: '3.13'
25+
python-version: ${{ env.PYTHON_VERSION }}
2326

2427
- name: Build
2528
run: uv build

.github/workflows/tests.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
schedule:
77
- cron: '41 16 * * *' # Every day at 16:41 UTC (to avoid high load at exact hour values).
88

9+
env:
10+
UV_NO_SYNC: 1
11+
PYTHON_VERSION: 3.13
12+
913
jobs:
1014
tests-full-install:
1115
name: Run tests with full install
@@ -23,7 +27,7 @@ jobs:
2327
with:
2428
python-version: ${{ matrix.python-version }}
2529
- name: Install default (with full options) and test dependencies
26-
run: uv pip install '.[full]' --group test
30+
run: uv pip install --python-version=${{ matrix.python-version }} '.[full]' --group test
2731
- name: Run unit and doc tests with coverage report
2832
run: uv run pytest -W error tests/unit tests/doc --cov=src --cov-report=xml
2933
- name: Upload results to Codecov
@@ -39,9 +43,9 @@ jobs:
3943
- name: Set up uv
4044
uses: astral-sh/setup-uv@v5
4145
with:
42-
python-version: '3.13'
46+
python-version: ${{ env.PYTHON_VERSION }}
4347
- name: Install default (without any option) and test dependencies
44-
run: uv pip install . --group test
48+
run: uv pip install --python-version=${{ env.PYTHON_VERSION }} . --group test
4549
- name: Run unit and doc tests with coverage report
4650
run: |
4751
uv run pytest -W error tests/unit tests/doc \
@@ -64,10 +68,10 @@ jobs:
6468
- name: Set up uv
6569
uses: astral-sh/setup-uv@v5
6670
with:
67-
python-version: '3.13'
71+
python-version: ${{ env.PYTHON_VERSION }}
6872

6973
- name: Install dependencies (default with full options & doc)
70-
run: uv pip install '.[full]' --group doc
74+
run: uv pip install --python-version=${{ env.PYTHON_VERSION }} '.[full]' --group doc
7175

7276
- name: Build Documentation
7377
working-directory: docs
@@ -83,10 +87,10 @@ jobs:
8387
- name: Set up uv
8488
uses: astral-sh/setup-uv@v5
8589
with:
86-
python-version: '3.13'
90+
python-version: ${{ env.PYTHON_VERSION }}
8791

8892
- name: Install dependencies (default with full options & check)
89-
run: uv pip install '.[full]' --group check
93+
run: uv pip install --python-version=${{ env.PYTHON_VERSION }} '.[full]' --group check
9094

9195
- name: Run mypy
9296
run: uv run mypy src/torchjd

CONTRIBUTING.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,21 @@ mandatory, we only provide installation steps with this tool. You can install it
1919
2) Create a virtual environment and install the project in it. From the root of `torchjd`, run:
2020
```bash
2121
uv venv
22-
CC=gcc uv pip install -e '.[full]' --group check --group doc --group test --group plot
22+
CC=gcc uv pip install --python-version=3.13.3 -e '.[full]' --group check --group doc --group test --group plot
23+
```
24+
We also advise using `UV_NO_SYNC=1` to prevent `uv` from syncing all the time. This is because by
25+
default, it tries to resolve libraries compatible with the whole range of Python versions
26+
supported by TorchJD, but in reality, we just need an installation compatible with the currently
27+
used Python version. That's also why we specify `--python-version=3.14` when running
28+
`uv pip install`. To follow that recommendation, add the following line to your `.bashrc`:
29+
```bash
30+
export UV_NO_SYNC=1
31+
```
32+
and start a new terminal. The alternative is to use the `--no-sync` flag whenever you run a pip
33+
command that would normally sync (like `uv run`).
34+
35+
3) Install pre-commit:
36+
```bash
2337
uv run pre-commit install
2438
```
2539

@@ -46,7 +60,7 @@ from the root of `torchjd`:
4660
rm -rf .venv
4761
rm uv.lock
4862
uv venv
49-
CC=gcc uv pip install -e '.[full]' --group check --group doc --group test --group plot
63+
CC=gcc uv pip install --python-version=3.13.3 -e '.[full]' --group check --group doc --group test --group plot
5064
uv run pre-commit install
5165
```
5266

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ check = [
7171

7272
doc = [
7373
"sphinx>=6.0, !=7.2.0, !=7.2.1, !=7.2.3, !=7.2.4, !=7.2.5", # Versions in [7.2.0, 7.2.5] have a bug with an internal torch import from _C
74-
"furo>=2023.0, <2024.04.27", # Force it to be recent so that the theme looks better, 2024.04.27 seems to have bugged link colors
74+
"furo>=2023.0", # Force it to be recent so that the theme looks better
7575
"tomli>=1.1", # The load function doesn't work similarly before 1.1
76-
"sphinx-autodoc-typehints>=1.16.0", # Some problems with TypeVars before 1.16
76+
"sphinx-autodoc-typehints>=3.5.0", # Bugged Union on Python 3.14 before 3.5.0
7777
"myst-parser>=3.0.1", # Never tested lower versions
7878
"sphinx-design>=0.6.0", # Never tested lower versions
7979
]

0 commit comments

Comments
 (0)