Skip to content

Commit d335917

Browse files
committed
feat: convert all manual uv executions in nox to just implicitly use it through the venv
1 parent 6efa88d commit d335917

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

noxfile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ def docs(session: Session):
155155

156156
session.log(f"Cleaning template docs build directory: {docs_build_dir}")
157157
docs_build_dir.parent.mkdir(parents=True, exist_ok=True)
158-
session.run("uv", "run", "sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-E", external=True)
158+
session.run("sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-E")
159159

160160
session.log("Building template documentation.")
161-
session.run("uv", "run", "sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-W", external=True)
161+
session.run("sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-W")
162162

163163
session.log(f"Template documentation built in {docs_build_dir.resolve()}.")
164164

@@ -199,7 +199,7 @@ def test(session: Session) -> None:
199199
session.install("-e", ".", external=True)
200200

201201
session.log("Running generated project's default checks...")
202-
session.run("uv", "run", "nox", external=True)
202+
session.run("nox")
203203

204204
session.log(f"Cleaning up temporary directory: {temp_dir}")
205205
shutil.rmtree(temp_dir)
@@ -221,7 +221,7 @@ def release_template(session: Session):
221221
session.skip("Git not available.")
222222

223223
session.log("Checking Commitizen availability via uvx.")
224-
session.run("uvx", "cz", "--version", successcodes=[0], external=True)
224+
session.run("cz", "--version", successcodes=[0])
225225

226226
increment = session.posargs[0] if session.posargs else None
227227
session.log(

{{cookiecutter.project_name}}/noxfile.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,51 +34,51 @@ def pre_commit(session: Session) -> None:
3434
def format_python(session: Session) -> None:
3535
"""Run Python code formatter (Ruff format)."""
3636
session.log("Installing formatting dependencies...")
37-
session.run("uv", "sync", "--locked", "--group", "dev", "--group", "lint", external=True)
37+
session.install("-e", ".", "--group", "dev", "--group", "lint")
3838

3939
session.log(f"Running Ruff formatter check with py{session.python}.")
4040
# Use --check, not fix. Fixing is done by pre-commit or manual run.
41-
session.run("uv", "run", "ruff", "format", *session.posargs, external=True)
41+
session.run("ruff", "format", *session.posargs)
4242

4343

4444
@nox.session(python=DEFAULT_PYTHON_VERSION, name="lint-python")
4545
def lint_python(session: Session) -> None:
4646
"""Run Python code linters (Ruff check, Pydocstyle rules)."""
4747
session.log("Installing linting dependencies...")
48-
session.run("uv", "sync", "--locked", "--group", "dev", "--group", "lint", external=True)
48+
session.install("-e", ".", "--group", "dev", "--group", "lint")
4949

5050
session.log(f"Running Ruff check with py{session.python}.")
51-
session.run("uv", "run", "ruff", "check", "--verbose", external=True)
51+
session.run("ruff", "check", "--verbose")
5252

5353

5454
@nox.session(python=PYTHON_VERSIONS)
5555
def typecheck(session: Session) -> None:
5656
"""Run static type checking (Pyright) on Python code."""
5757
session.log("Installing type checking dependencies...")
58-
session.run("uv", "sync", "--locked", "--group", "dev", "--group", "typecheck", external=True)
58+
session.install("-e", ".", "--group", "dev", "--group", "typecheck")
5959

6060
session.log(f"Running Pyright check with py{session.python}.")
61-
session.run("uv", "run", "pyright", external=True)
61+
session.run("pyright")
6262

6363

6464
@nox.session(python=DEFAULT_PYTHON_VERSION, name="security-python")
6565
def security_python(session: Session) -> None:
6666
"""Run code security checks (Bandit) on Python code."""
6767
session.log("Installing security dependencies...")
68-
session.run("uv", "sync", "--locked", "--group", "dev", "--group", "security", external=True)
68+
session.install("-e", ".", "--group", "dev", "--group", "security")
6969

7070
session.log(f"Running Bandit static security analysis with py{session.python}.")
71-
session.run("uv", "run", "bandit", "-r", PACKAGE_NAME, "-c", ".bandit", "-ll", "-s", external=True)
71+
session.run("bandit", "-r", PACKAGE_NAME, "-c", ".bandit", "-ll", "-s")
7272

7373
session.log(f"Running pip-audit dependency security check with py{session.python}.")
74-
session.run("uv", "run", "pip-audit", "--python", str(Path(session.python)), external=True)
74+
session.run("pip-audit", "--python", str(Path(session.python)))
7575

7676

7777
@nox.session(python=PYTHON_VERSIONS, name="tests-python")
7878
def tests_python(session: Session) -> None:
7979
"""Run the Python test suite (pytest with coverage)."""
8080
session.log("Installing test dependencies...")
81-
session.run("uv", "sync", "--locked", "--group", "dev", "--group", "test", external=True)
81+
session.install("-e", ".", "--group", "dev", "--group", "test")
8282

8383
session.log(f"Running test suite with py{session.python}.")
8484
test_results_dir = Path("test-results")
@@ -107,16 +107,16 @@ def tests_rust(session: Session) -> None:
107107
def docs_build(session: Session) -> None:
108108
"""Build the project documentation (Sphinx)."""
109109
session.log("Installing documentation dependencies...")
110-
session.run("uv", "sync", "--locked", "--group", "dev", "--group", "docs", external=True)
110+
session.install("-e", ".", "--group", "dev", "--group", "docs")
111111

112112
session.log(f"Building documentation with py{session.python}.")
113113
docs_build_dir = Path("docs") / "_build" / "html"
114114

115115
session.log(f"Cleaning build directory: {docs_build_dir}")
116-
session.run("uv", "run", "sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-E", external=True)
116+
session.run("sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-E")
117117

118118
session.log("Building documentation.")
119-
session.run("uv", "run", "sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-W", external=True)
119+
session.run("sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-W")
120120

121121

122122
@nox.session(python=DEFAULT_PYTHON_VERSION, name="build-python")
@@ -130,7 +130,7 @@ def build_python(session: Session) -> None:
130130
{% if cookiecutter.add_rust_extension == 'y' -%}
131131
session.run("uv", "build", "--sdist", "--wheel", "--outdir", "dist/", external=True)
132132
{% else -%}
133-
session.run("uvx", "maturin", "develop", "--uv", external=True)
133+
session.run("maturin", "develop", "--uv")
134134
{% endif -%}
135135

136136
session.log("Built packages in ./dist directory:")
@@ -179,7 +179,7 @@ def publish_python(session: Session) -> None:
179179
session.run("uv", "sync", "--locked", "--group", "dev", external=True)
180180

181181
session.log("Checking built packages with Twine.")
182-
session.run("uvx", "twine", "check", "dist/*", external=True)
182+
session.run("twine", "check", "dist/*")
183183

184184
session.log("Publishing packages to PyPI.")
185185
session.run("uv", "publish", "dist/*", external=True)
@@ -211,7 +211,7 @@ def release(session: Session) -> None:
211211
session.skip("Git not available.")
212212

213213
session.log("Checking Commitizen availability via uvx.")
214-
session.run("uvx", "cz", "--version", success_codes=[0], external=True)
214+
session.run("cz", "--version", success_codes=[0])
215215

216216
increment = session.posargs[0] if session.posargs else None
217217
session.log(
@@ -254,9 +254,9 @@ def tox(session: Session) -> None:
254254
session.skip("tox.ini not present.")
255255

256256
session.log("Checking Tox availability via uvx.")
257-
session.run("uvx", "tox", "--version", success_codes=[0], external=True)
257+
session.run("tox", "--version", success_codes=[0])
258258

259-
session.run("uvx", "tox", *session.posargs, external=True)
259+
session.run("tox", *session.posargs)
260260

261261

262262
# --- COMBINED/ORCHESTRATION SESSIONS ---
@@ -312,13 +312,13 @@ def coverage(session: Session) -> None:
312312
session.log("Note: Ensure 'nox -s test-python' was run across all desired Python versions first to generate coverage data.")
313313

314314
session.log("Installing dependencies for coverage report session...")
315-
session.run("uv", "sync", "--locked", "--group", "dev", "--group", "test", external=True)
315+
session.install("-e", ".", "--group", "dev", "--group", "test")
316316

317317
coverage_combined_file: Path = Path.cwd() / ".coverage"
318318

319319
session.log("Combining coverage data.")
320320
try:
321-
session.run("uv", "run", "coverage", "combine", external=True)
321+
session.run("coverage", "combine")
322322
session.log(f"Combined coverage data into {coverage_combined_file.resolve()}")
323323
except CommandFailed as e:
324324
if e.returncode == 1:
@@ -329,9 +329,9 @@ def coverage(session: Session) -> None:
329329

330330
session.log("Generating HTML coverage report.")
331331
coverage_html_dir = Path("coverage-html")
332-
session.run("uv", "run", "coverage", "html", "--directory", str(coverage_html_dir), external=True)
332+
session.run("coverage", "html", "--directory", str(coverage_html_dir))
333333

334334
session.log("Running terminal coverage report.")
335-
session.run("uv", "run", "coverage", "report", external=True)
335+
session.run("coverage", "report")
336336

337337
session.log(f"Coverage reports generated in ./{coverage_html_dir} and terminal.")

0 commit comments

Comments
 (0)