Skip to content

Commit f3f07b3

Browse files
committed
feat: convert most low importance nox sessions to use uvx in place of a nox venv
1 parent e90de25 commit f3f07b3

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

{{cookiecutter.project_name}}/noxfile.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,11 @@ def precommit(session: Session) -> None:
7171
activate_virtualenv_in_precommit_hooks(session)
7272

7373

74-
@nox.session(python=DEFAULT_PYTHON_VERSION, name="format-python", tags=[FORMAT, PYTHON])
74+
@nox.session(python=None, name="format-python", tags=[FORMAT, PYTHON])
7575
def format_python(session: Session) -> None:
7676
"""Run Python code formatter (Ruff format)."""
77-
session.log("Installing formatting dependencies...")
78-
session.install("ruff")
79-
8077
session.log(f"Running Ruff formatter check with py{session.python}.")
81-
session.run("ruff", "format", *session.posargs)
78+
session.run("uvx", "ruff", "format", *session.posargs)
8279

8380

8481
{% if cookiecutter.add_rust_extension == "y" -%}
@@ -92,14 +89,11 @@ def format_rust(session: Session) -> None:
9289

9390

9491
{% endif -%}
95-
@nox.session(python=DEFAULT_PYTHON_VERSION, name="lint-python", tags=[LINT, PYTHON])
92+
@nox.session(python=None, name="lint-python", tags=[LINT, PYTHON])
9693
def lint_python(session: Session) -> None:
9794
"""Run Python code linters (Ruff check, Pydocstyle rules)."""
98-
session.log("Installing linting dependencies...")
99-
session.install("ruff")
100-
10195
session.log(f"Running Ruff check with py{session.python}.")
102-
session.run("ruff", "check", "--fix", "--verbose")
96+
session.run("uvx", "ruff", "check", "--fix", "--verbose")
10397

10498

10599
{% if cookiecutter.add_rust_extension == "y" -%}
@@ -123,17 +117,14 @@ def typecheck(session: Session) -> None:
123117
session.run("pyright")
124118

125119

126-
@nox.session(python=DEFAULT_PYTHON_VERSION, name="security-python", tags=[SECURITY, PYTHON, CI])
120+
@nox.session(python=None, name="security-python", tags=[SECURITY, PYTHON, CI])
127121
def security_python(session: Session) -> None:
128122
"""Run code security checks (Bandit) on Python code."""
129-
session.log("Installing security dependencies...")
130-
session.install("bandit", "pip-audit")
131-
132123
session.log(f"Running Bandit static security analysis with py{session.python}.")
133-
session.run("bandit", "-r", PACKAGE_NAME, "-c", "bandit.yml", "-ll")
124+
session.run("uvx", "bandit", "-r", PACKAGE_NAME, "-c", "bandit.yml", "-ll")
134125

135126
session.log(f"Running pip-audit dependency security check with py{session.python}.")
136-
session.run("pip-audit")
127+
session.run("uvx", "pip-audit")
137128

138129

139130
{% if cookiecutter.add_rust_extension == 'y' -%}
@@ -249,17 +240,15 @@ def build_container(session: Session) -> None:
249240
session.log(f"Container image {project_image_name}:latest built locally.")
250241

251242

252-
@nox.session(python=DEFAULT_PYTHON_VERSION, name="publish-python", tags=[RELEASE])
243+
@nox.session(python=None, name="publish-python", tags=[RELEASE])
253244
def publish_python(session: Session) -> None:
254245
"""Publish sdist and wheel packages to PyPI via uv publish.
255246
256247
Requires packages to be built first (`nox -s build-python` or `nox -s build`).
257248
Requires TWINE_USERNAME/TWINE_PASSWORD or TWINE_API_KEY environment variables set (usually in CI).
258249
"""
259-
session.install("twine")
260-
261250
session.log("Checking built packages with Twine.")
262-
session.run("twine", "check", "dist/*")
251+
session.run("uvx", "twine", "check", "dist/*")
263252

264253
session.log("Publishing packages to PyPI.")
265254
session.run("uv", "publish", "dist/*", external=True)
@@ -276,7 +265,7 @@ def publish_rust(session: Session) -> None:
276265

277266

278267
{% endif -%}
279-
@nox.session(venv_backend="none", tags=[RELEASE])
268+
@nox.session(python=None, tags=[RELEASE])
280269
def release(session: Session) -> None:
281270
"""Run the release process using Commitizen.
282271
@@ -291,15 +280,15 @@ def release(session: Session) -> None:
291280
session.skip("Git not available.")
292281

293282
session.log("Checking Commitizen availability via uvx.")
294-
session.run("cz", "--version", success_codes=[0])
283+
session.run("uvx", "--from=commitizen", "cz", "version", success_codes=[0])
295284

296285
increment = session.posargs[0] if session.posargs else None
297286
session.log(
298287
"Bumping version and tagging release (increment: %s).",
299288
increment if increment else "default",
300289
)
301290

302-
cz_bump_args = ["uvx", "cz", "bump", "--changelog"]
291+
cz_bump_args = ["uvx", "--from=commitizen", "cz", "bump", "--changelog"]
303292

304293
if increment:
305294
cz_bump_args.append(f"--increment={increment}")
@@ -311,7 +300,7 @@ def release(session: Session) -> None:
311300
session.log("IMPORTANT: Push commits and tags to remote (`git push --follow-tags`) to trigger CD pipeline.")
312301

313302

314-
@nox.session(venv_backend="none")
303+
@nox.session(python=None)
315304
def tox(session: Session) -> None:
316305
"""Run the 'tox' test matrix.
317306

0 commit comments

Comments
 (0)