Skip to content

Commit 8c7500c

Browse files
authored
Adopt nox-uv (#286)
1 parent 54c5580 commit 8c7500c

File tree

7 files changed

+209
-181
lines changed

7 files changed

+209
-181
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on: [push, pull_request]
44

55
env:
6-
UV_VERSION: "0.7.5"
6+
UV_VERSION: "0.7.12"
77

88
jobs:
99
test:

.github/workflows/pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
branches: [main]
99

1010
env:
11-
UV_VERSION: "0.7.5"
11+
UV_VERSION: "0.7.12"
1212

1313
jobs:
1414
deploy:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
FROM python:3.12-slim-bookworm AS python_builder
1212

1313
# Pin uv to a specific version to make container builds reproducible.
14-
ENV UV_VERSION=0.7.5
14+
ENV UV_VERSION=0.7.12
1515
ENV UV_PYTHON_DOWNLOADS=never
1616

1717
# Set ENV variables that make Python more friendly to running inside a container.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ uv publish
9696
9797
# Enforcing Code Quality
9898

99-
Automated code quality checks are performed using [Nox](https://nox.thea.codes/en/stable/). Nox
100-
will automatically create virtual environments and run commands based on
101-
[`noxfile.py`](./noxfile.py) for unit testing, PEP 8 style guide checking, type checking and
102-
documentation generation.
99+
Automated code quality checks are performed using [Nox](https://nox.thea.codes/en/stable/) and
100+
[`nox-uv`](https://github.com/dantebben/nox-uv). Nox will automatically create virtual environments
101+
and run commands based on [`noxfile.py`](./noxfile.py) for unit testing, PEP 8 style guide checking, type
102+
checking and documentation generation.
103103

104104
> [!NOTE]
105105
> `nox` is installed into the virtual environment automatically by the `uv sync` command

noxfile.py

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
from nox import Session, options, param, parametrize, session
1+
from nox import Session, options, param, parametrize
2+
from nox_uv import session
23

34
options.error_on_external_run = True
45
options.default_venv_backend = "uv"
56
options.sessions = ["lint", "type_check", "test", "docs"]
67

78

8-
@session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
9+
@session(
10+
python=["3.9", "3.10", "3.11", "3.12", "3.13"],
11+
uv_groups=["test"],
12+
)
913
def test(s: Session) -> None:
10-
s.run_install(
11-
"uv",
12-
"sync",
13-
"--locked",
14-
"--no-default-groups",
15-
"--group=test",
16-
f"--python={s.virtualenv.location}",
17-
env={"UV_PROJECT_ENVIRONMENT": s.virtualenv.location},
18-
)
1914
s.run(
2015
"pytest",
2116
"--cov=fact",
@@ -27,8 +22,9 @@ def test(s: Session) -> None:
2722
)
2823

2924

30-
# For some sessions, set venv_backend="none" to simply execute scripts within the existing
31-
# uv-generated virtual environment, rather than have nox create a new one for each session.
25+
# For some sessions, set venv_backend="none" to simply execute scripts within the existing outer
26+
# uv-generated virtual environment, rather than have nox create a new one for each session. This
27+
# makes commonly repeated sessions execute faster.
3228
@session(venv_backend="none")
3329
@parametrize(
3430
"command",
@@ -107,17 +103,7 @@ def docs_github_pages(s: Session) -> None:
107103
s.run("mkdocs", "gh-deploy", "--force", env=doc_env)
108104

109105

110-
@session
106+
# Install only main dependencies for the license report.
107+
@session(uv_groups=["licenses"])
111108
def licenses(s: Session) -> None:
112-
# Install only main dependencies for license report.
113-
s.run_install(
114-
"uv",
115-
"sync",
116-
"--locked",
117-
"--no-default-groups",
118-
"--no-install-project",
119-
"--group=licenses",
120-
f"--python={s.virtualenv.location}",
121-
env={"UV_PROJECT_ENVIRONMENT": s.virtualenv.location},
122-
)
123109
s.run("pip-licenses", *s.posargs)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fact = "fact.cli:app"
3939

4040
[dependency-groups]
4141
nox = [
42-
"nox",
42+
"nox-uv",
4343
]
4444
test = [
4545
"pytest",

uv.lock

Lines changed: 190 additions & 148 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)