Skip to content

Commit 5167fe0

Browse files
authored
Use uv as Nox backend and several related improvements (#476)
1 parent 022a257 commit 5167fe0

File tree

7 files changed

+52
-49
lines changed

7 files changed

+52
-49
lines changed

.github/workflows/coverage.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
- name: Set up Python ${{ matrix.python-version }}
1212
uses: actions/setup-python@v5
1313
with:
14-
python-version: 3.11
15-
- name: Install dependencies
16-
run: pip install nox
14+
python-version: 3.13
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v6
1717
- name: Test with nox
18-
run: nox -e coverage
18+
run: uv run --group nox nox -e coverage
1919
- name: Upload coverage to Codecov
2020
uses: codecov/codecov-action@v4

.github/workflows/matchers/pytest.json

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

.github/workflows/nox.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
platform: [ubuntu-latest, macos-latest, windows-latest]
15-
python-version: ["3.9", "3.10", "3.11", "3.12"]
15+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1616

1717
steps:
1818
- uses: actions/checkout@v4
1919
- name: Set up Python ${{ matrix.python-version }}
2020
uses: actions/setup-python@v5
2121
with:
2222
python-version: ${{ matrix.python-version }}
23-
- name: Register Python problem matcher
24-
run: echo "::add-matcher::.github/workflows/matchers/pytest.json"
25-
- name: Install dependencies
26-
run: pip install nox pytest-github-actions-annotate-failures
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v6
2725
- name: Test with nox using minimal dependencies
28-
run: nox -e "pytest-${{ matrix.python-version }}(all_deps=False)"
26+
run: uv run --group nox nox -e "pytest_min_deps-${{ matrix.python-version }}"
2927
- name: Test with nox with all dependencies
30-
run: nox -e "pytest-${{ matrix.python-version }}(all_deps=True)"
28+
run: uv run --group nox nox -e "pytest_all_deps-${{ matrix.python-version }}"

.github/workflows/typeguard.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
- name: Set up Python ${{ matrix.python-version }}
1313
uses: actions/setup-python@v5
1414
with:
15-
python-version: "3.11"
16-
- name: Install dependencies
17-
run: pip install nox
15+
python-version: "3.13"
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v6
1818
- name: Test with nox
19-
run: nox -e pytest_typeguard
19+
run: uv run --group nox nox -e pytest_typeguard

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ jupyter labextension install @pyviz/jupyterlab_pyviz
160160

161161
## :wrench: Development
162162

163-
Clone the repository and run `pip install -e ".[notebook,testing,other]"` to add a link to the cloned repo into your Python path:
163+
Clone the repository and run `pip install -e ".[notebook,test,other]"` to add a link to the cloned repo into your Python path:
164164

165165
```bash
166166
git clone git@github.com:python-adaptive/adaptive.git
167167
cd adaptive
168-
pip install -e ".[notebook,testing,other]"
168+
pip install -e ".[notebook,test,other]"
169169
```
170170

171171
We recommend using a Conda environment or a virtualenv for package management during Adaptive development.

noxfile.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,45 @@
11
"""Nox configuration file."""
22

3+
import os
4+
35
import nox
46

7+
nox.options.default_venv_backend = "uv"
8+
9+
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
10+
num_cpus = os.cpu_count() or 1
11+
xdist = ("-n", "auto") if num_cpus > 2 else ()
12+
13+
14+
@nox.session(python=python)
15+
def pytest_min_deps(session: nox.Session) -> None:
16+
"""Run pytest with no optional dependencies."""
17+
session.install(".[test]")
18+
session.run("coverage", "erase")
19+
session.run("pytest", *xdist)
20+
521

6-
@nox.session(python=["3.9", "3.10", "3.11", "3.12"])
7-
@nox.parametrize("all_deps", [True, False])
8-
def pytest(session: nox.Session, all_deps: bool) -> None:
9-
"""Run pytest with optional dependencies."""
10-
session.install(".[testing,other]" if all_deps else ".[testing]")
22+
@nox.session(python=python)
23+
def pytest_all_deps(session: nox.Session) -> None:
24+
"""Run pytest with "other" optional dependencies."""
25+
session.install(".[test,other]")
1126
session.run("coverage", "erase")
12-
session.run("pytest")
27+
session.run("pytest", *xdist)
1328

1429

15-
@nox.session(python="3.11")
30+
@nox.session(python="3.13")
1631
def pytest_typeguard(session: nox.Session) -> None:
1732
"""Run pytest with typeguard."""
18-
session.install(".[testing,other]")
33+
session.install(".[test,other]")
1934
session.run("coverage", "erase")
20-
session.run("pytest", "--typeguard-packages=adaptive")
35+
session.run("pytest", "--typeguard-packages=adaptive", *xdist)
2136

2237

23-
@nox.session(python="3.11")
38+
@nox.session(python="3.13")
2439
def coverage(session: nox.Session) -> None:
2540
"""Generate coverage report."""
26-
session.install("coverage")
27-
session.install(".[testing,other]")
28-
session.run("pytest")
41+
session.install(".[test,other]")
42+
session.run("pytest", *xdist)
2943

3044
session.run("coverage", "report")
3145
session.run("coverage", "xml")

pyproject.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ notebook = [
4747
"matplotlib",
4848
"plotly",
4949
]
50-
testing = [
50+
test = [
5151
"flaky",
5252
"pytest",
5353
"pytest-cov",
5454
"pytest-randomly",
5555
"pytest-timeout",
56+
"pytest-xdist",
5657
"pre_commit",
5758
"typeguard",
59+
"coverage",
5860
]
61+
dev = ["adaptive[test,nox,notebook,other]"]
5962

6063
[project.urls]
6164
homepage = "https://adaptive.readthedocs.io/"
@@ -66,6 +69,12 @@ repository = "https://github.com/python-adaptive/adaptive"
6669
content-type = "text/markdown"
6770
file = "README.md"
6871

72+
[dependency-groups]
73+
nox = [
74+
"nox",
75+
"pytest-github-actions-annotate-failures",
76+
]
77+
6978
[tool.setuptools.packages.find]
7079
include = ["adaptive.*", "adaptive"]
7180

0 commit comments

Comments
 (0)