Skip to content

Commit 4eb108f

Browse files
authored
chore: use uv and dependency-groups (#585)
* chore: use uv and dependency-groups Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * fix: use proper license field Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent e3c281a commit 4eb108f

3 files changed

Lines changed: 42 additions & 32 deletions

File tree

.github/workflows/reusable-rr-tests.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ jobs:
2828
python-version: ${{ matrix.python-version }}
2929
allow-prereleases: true
3030

31-
- name: Install package
32-
run: python -m pip install .[test,cli]
31+
- uses: astral-sh/setup-uv@v6
3332

3433
- name: Test package
35-
run: python -m pytest -ra
34+
run: uv run pytest -ra
3635
env:
3736
PYTHONWARNDEFAULTENCODING: 1
3837

@@ -57,11 +56,13 @@ jobs:
5756

5857
- uses: actions/setup-python@v5
5958
with:
60-
python-version: "3.12"
59+
python-version: "3.13"
60+
61+
- uses: astral-sh/setup-uv@v6
6162

6263
- name: Rerender README
6364
run: |
64-
pipx run nox -s readme
65+
uvx nox -s readme
6566
git diff --exit-code
6667
6768
pylint:
@@ -72,5 +73,11 @@ jobs:
7273
with:
7374
fetch-depth: 0
7475

76+
- uses: actions/setup-python@v5
77+
with:
78+
python-version: "3.13"
79+
80+
- uses: astral-sh/setup-uv@v6
81+
7582
- name: Run pylint
76-
run: pipx run nox[uv] -s rr_pylint -- --output-format=github
83+
run: uvx nox -s rr_pylint -- --output-format=github

noxfile.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424

2525
import nox
2626

27-
nox.needs_version = ">=2024.3.2"
27+
nox.needs_version = ">=2025.2.9"
2828
nox.options.sessions = ["rr_lint", "rr_tests", "rr_pylint", "readme"]
2929
nox.options.default_venv_backend = "uv|virtualenv"
3030

31+
3132
DIR = Path(__file__).parent.resolve()
3233
with DIR.joinpath("cookiecutter.json").open() as f:
3334
BACKENDS = json.load(f)["backend"]
@@ -178,7 +179,7 @@ def diff_files(p1: Path, p2: Path) -> bool:
178179
return same
179180

180181

181-
@nox.session()
182+
@nox.session(default=False)
182183
@nox.parametrize("vcs", [False, True], ids=["novcs", "vcs"])
183184
@nox.parametrize("backend", BACKENDS, ids=BACKENDS)
184185
def lint(session: nox.Session, backend: str, vcs: bool) -> None:
@@ -198,7 +199,7 @@ def lint(session: nox.Session, backend: str, vcs: bool) -> None:
198199
)
199200

200201

201-
@nox.session
202+
@nox.session(default=False)
202203
@nox.parametrize("backend", BACKENDS, ids=BACKENDS)
203204
def autoupdate(session: nox.Session, backend: str) -> None:
204205
session.install("cookiecutter", "pre-commit")
@@ -212,7 +213,7 @@ def autoupdate(session: nox.Session, backend: str) -> None:
212213
session.run("git", "diff", "--exit-code", external=True)
213214

214215

215-
@nox.session()
216+
@nox.session(default=False)
216217
@nox.parametrize("vcs", [False, True], ids=["novcs", "vcs"])
217218
@nox.parametrize("backend", BACKENDS, ids=BACKENDS)
218219
def tests(session: nox.Session, backend: str, vcs: bool) -> None:
@@ -236,7 +237,7 @@ def tests(session: nox.Session, backend: str, vcs: bool) -> None:
236237
assert version == expected_version, f"{version=} != {expected_version=}"
237238

238239

239-
@nox.session()
240+
@nox.session(default=False)
240241
@nox.parametrize("vcs", [False, True], ids=["novcs", "vcs"])
241242
@nox.parametrize("backend", ("poetry", "pdm", "hatch"), ids=("poetry", "pdm", "hatch"))
242243
def native(session: nox.Session, backend: str, vcs: bool) -> None:
@@ -257,7 +258,7 @@ def native(session: nox.Session, backend: str, vcs: bool) -> None:
257258
session.run(backend, "run", "pytest")
258259

259260

260-
@nox.session()
261+
@nox.session(default=False)
261262
@nox.parametrize("vcs", [False, True], ids=["novcs", "vcs"])
262263
@nox.parametrize("backend", BACKENDS, ids=BACKENDS)
263264
def dist(session: nox.Session, backend: str, vcs: bool) -> None:
@@ -305,7 +306,7 @@ def dist(session: nox.Session, backend: str, vcs: bool) -> None:
305306
wheel.rename(dist / wheel.stem)
306307

307308

308-
@nox.session(name="nox")
309+
@nox.session(name="nox", default=False)
309310
@nox.parametrize("vcs", [False, True], ids=["novcs", "vcs"])
310311
@nox.parametrize("backend", BACKENDS, ids=BACKENDS)
311312
def nox_session(session: nox.Session, backend: str, vcs: bool) -> None:
@@ -322,7 +323,7 @@ def nox_session(session: nox.Session, backend: str, vcs: bool) -> None:
322323
session.run("nox")
323324

324325

325-
@nox.session()
326+
@nox.session(default=False)
326327
def compare_copier(session):
327328
# Copier 9.5.0 broke `--data`
328329
# Copier 9.7.0/9.7.1 broke everything
@@ -342,7 +343,7 @@ def compare_copier(session):
342343
session.error(f"{backend} {vcs=} files are not the same!")
343344

344345

345-
@nox.session()
346+
@nox.session(default=False)
346347
def compare_cruft(session):
347348
session.install("cookiecutter", "cruft")
348349

@@ -375,7 +376,7 @@ def compare_cruft(session):
375376
GHA_VERS = re.compile(r"[\s\-]+uses: (.*?)@([^\s]+)")
376377

377378

378-
@nox.session(reuse_venv=True)
379+
@nox.session(reuse_venv=True, default=False)
379380
def pc_bump(session: nox.Session) -> None:
380381
"""
381382
Bump the pre-commit versions.
@@ -439,7 +440,7 @@ def get_latest_version_tag(repo: str, old_version: str) -> dict[str, Any] | None
439440
return None
440441

441442

442-
@nox.session(venv_backend="none")
443+
@nox.session(venv_backend="none", default=False)
443444
def gha_bump(session: nox.Session) -> None:
444445
"""
445446
Bump the GitHub Actions.
@@ -484,7 +485,7 @@ def readme(session: nox.Session) -> None:
484485
session.run("cog", "-P", *args, "README.md")
485486

486487

487-
@nox.session(reuse_venv=True)
488+
@nox.session(reuse_venv=True, default=False)
488489
def rr_run(session: nox.Session) -> None:
489490
"""
490491
Run sp-repo-review.
@@ -519,19 +520,18 @@ def rr_tests(session: nox.Session) -> None:
519520
"""
520521
Run the unit and regular tests for sp-repo-review.
521522
"""
522-
session.install("-e.[test,cli]")
523+
pyproject = nox.project.load_toml()
524+
test_deps = nox.project.dependency_groups(pyproject, "test")
525+
526+
session.install("-e.[cli]", *test_deps)
523527
session.run("pytest", *session.posargs, env={"PYTHONWARNDEFAULTENCODING": "1"})
524528

525529

526-
@nox.session(reuse_venv=True)
530+
@nox.session(reuse_venv=True, default=False)
527531
def rr_build(session: nox.Session) -> None:
528532
"""
529533
Build an SDist and wheel for sp-repo-review.
530534
"""
531535

532-
build_p = DIR.joinpath("build")
533-
if build_p.exists():
534-
shutil.rmtree(build_p)
535-
536536
session.install("build")
537537
session.run("python", "-m", "build")

pyproject.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors = [
1010
]
1111
description = "Review repos for compliance to the Scientific-Python development guidelines"
1212
requires-python = ">=3.10"
13-
license-expression = 'BSD-3-Clause'
13+
license = 'BSD-3-Clause'
1414
classifiers = [
1515
"Development Status :: 4 - Beta",
1616
"Environment :: Console",
@@ -40,13 +40,6 @@ dependencies = [
4040
cli = [
4141
"repo-review[cli]",
4242
]
43-
test = [
44-
"pytest >=7",
45-
"repo-review >=0.10.6",
46-
]
47-
dev = [
48-
"pytest >=7",
49-
]
5043
pyproject = [
5144
"validate-pyproject-schema-store[all]",
5245
]
@@ -82,6 +75,16 @@ setupcfg = "sp_repo_review.checks.setupcfg:setupcfg"
8275
[project.entry-points."repo_review.families"]
8376
scikit-hep = "sp_repo_review.families:get_families"
8477

78+
[dependency-groups]
79+
dev = [
80+
{ include-group = "test" },
81+
"repo-review[cli]",
82+
"validate-pyproject-schema-store[all]",
83+
]
84+
test = [
85+
"pytest >=7",
86+
"repo-review >=0.10.6",
87+
]
8588

8689
[tool.hatch]
8790
version.source = "vcs"

0 commit comments

Comments
 (0)