11"""Noxfile for the cookiecutter-robust-python template."""
2- from pathlib import Path
2+
33import shutil
44import tempfile
5+ from pathlib import Path
56
67import nox
78import platformdirs
4142 * ("--demo-name" , DEFAULT_DEMO_NAME ),
4243)
4344
44- TEMPLATE_PYTHON_LOCATIONS : tuple [Path , ...] = (
45- Path ("noxfile.py" ),
46- Path ("scripts/*" ),
47- Path ("hooks/*" )
48- )
45+ TEMPLATE_PYTHON_LOCATIONS : tuple [Path , ...] = (Path ("noxfile.py" ), Path ("scripts" ), Path ("hooks" ))
4946
5047TEMPLATE_CONFIG_AND_DOCS : tuple [Path , ...] = (
5148 Path ("pyproject.toml" ),
5956 Path ("LICENSE" ),
6057 Path ("CODE_OF_CONDUCT.md" ),
6158 Path ("CHANGELOG.md" ),
62- Path ("docs/" )
59+ Path ("docs/" ),
6360)
6461
6562
@@ -84,6 +81,7 @@ def sync_uv_with_demo(session: Session) -> None:
8481 external = True ,
8582 )
8683
84+
8785@nox .session (name = "uv-in-demo" , python = DEFAULT_TEMPLATE_PYTHON_VERSION )
8886def uv_in_demo (session : Session ) -> None :
8987 session .install ("cookiecutter" , "platformdirs" , "loguru" , "typer" )
@@ -134,21 +132,20 @@ def clear_cache(session: Session) -> None:
134132def lint (session : Session ):
135133 """Lint the template's own Python files and configurations."""
136134 session .log ("Installing linting dependencies for the template source..." )
137- session .run ( "uv " , "sync " , "--locked" , "-- group" , "dev" , "--group" , "lint" , external = True )
135+ session .install ( "-e " , ". " , "--group" , "dev" , "--group" , "lint" )
138136
139- locations : list [str ] = [str (loc ) for loc in TEMPLATE_PYTHON_LOCATIONS + TEMPLATE_CONFIG_AND_DOCS ]
140137 session .log (f"Running Ruff formatter check on template files with py{ session .python } ." )
141- session .run ("uv" , "run" , " ruff" , "format" , * locations , "--check" , external = True )
138+ session .run ("ruff" , "format" )
142139
143140 session .log (f"Running Ruff check on template files with py{ session .python } ." )
144- session .run ("uv" , "run" , " ruff" , "check" , * locations , "--verbose" , external = True )
141+ session .run ("ruff" , "check" , "--verbose" , "--fix" )
145142
146143
147144@nox .session (python = DEFAULT_TEMPLATE_PYTHON_VERSION )
148145def docs (session : Session ):
149146 """Build the template documentation website."""
150147 session .log ("Installing documentation dependencies for the template docs..." )
151- session .run ( "uv " , "sync " , "--locked" , "-- group" , "dev" , "--group" , "docs" , external = True )
148+ session .install ( "-e " , ". " , "--group" , "dev" , "--group" , "docs" )
152149
153150 session .log (f"Building template documentation with py{ session .python } ." )
154151 # Set path to allow Sphinx to import from template root if needed (e.g., __version__.py)
@@ -178,7 +175,7 @@ def test(session: Session) -> None:
178175 session .log ("Running template tests..." )
179176 session .log ("Installing template testing dependencies..." )
180177 # Sync deps from template's own pyproject.toml, e.g., 'dev' group that includes 'pytest', 'cookiecutter'
181- session .run ( "uv " , "sync " , "--locked" , "-- group" , "dev" , "--group" , "test" , external = True )
178+ session .install ( "-e " , ". " , "--group" , "dev" , "--group" , "test" )
182179
183180 # Create a temporary directory for the generated project
184181 temp_dir : Path = Path (tempfile .mkdtemp ())
@@ -188,19 +185,18 @@ def test(session: Session) -> None:
188185 # Need to find cookiecutter executable - it's in the template dev env installed by uv sync.
189186 cookiecutter_command : list [str ] = ["uv" , "run" , "cookiecutter" , "--no-input" , "--output-dir" , str (temp_dir ), "." ]
190187
191-
192188 session .run (* cookiecutter_command , external = True )
193189
194190 # Navigate into the generated project directory
195- generated_project_dir = temp_dir / "test_project" # Use the slug defined in --extra-context
191+ generated_project_dir = temp_dir / "test_project" # Use the slug defined in --extra-context
196192 if not generated_project_dir .exists ():
197193 session .error (f"Generated project directory not found: { generated_project_dir } " )
198194
199195 session .log (f"Changing to generated project directory: { generated_project_dir } " )
200196 session .cd (generated_project_dir )
201197
202198 session .log ("Installing generated project dependencies using uv sync..." )
203- session .run ( "uv " , "sync" , "--locked " , external = True )
199+ session .install ( "-e " , ". " , external = True )
204200
205201 session .log ("Running generated project's default checks..." )
206202 session .run ("uv" , "run" , "nox" , external = True )
@@ -236,12 +232,11 @@ def release_template(session: Session):
236232 cz_bump_args = ["uvx" , "cz" , "bump" , "--changelog" ]
237233
238234 if increment :
239- cz_bump_args .append (f"--increment={ increment } " )
235+ cz_bump_args .append (f"--increment={ increment } " )
240236
241237 session .log ("Running cz bump with args: %s" , cz_bump_args )
242238 # success_codes=[0, 1] -> Allows code 1 which means 'nothing to bump' if no conventional commits since last release
243239 session .run (* cz_bump_args , success_codes = [0 , 1 ], external = True )
244240
245241 session .log ("Template version bumped and tag created locally via Commitizen/uvx." )
246242 session .log ("IMPORTANT: Push commits and tags to remote (`git push --follow-tags`) to trigger CD for the TEMPLATE." )
247-
0 commit comments