From df53ce7bc4107557666df11dab72992ff3131c7d Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Wed, 2 Dec 2026 21:43:23 +0100 Subject: [PATCH] Pin `MAIN_PYTHON` in the "init-project" session Otherwise, `uv` creates ".venv" with the newest installed Python. --- noxfile.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/noxfile.py b/noxfile.py index fcc6f6c..eae5e76 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,7 +17,7 @@ Further sessions run on demand with `uv run nox -s `: - "deps-lock": Lock dependencies after manual changes in pyproject.toml - "deps-upgrade": Upgrade dependencies within their allowed ranges - "deps-upgrade-check": Show newer versions and the age of all pinned releases -- "init-project": Install the `pre-commit` hooks and configure `git blame` +- "init-project": Set up a freshly cloned project - "clean-cwd": Run approx. `git clean -X` with minor exceptions - "verify-db-objects": Compare a live database with the ORM models @@ -540,7 +540,16 @@ def check_dependency_upgrades(session: nox.Session) -> None: @nox.session(name="init-project", python=MAIN_PYTHON, venv_backend="none") def initialize_project(session: nox.Session) -> None: - """Install the `pre-commit` hooks and configure `git blame`.""" + """Set up a freshly cloned project. + + This does the following: + - Pin the `MAIN_PYTHON` for `uv` + - Install the `pre-commit` hooks + - Configure `git blame` + """ + # Without a ".python-version" file, `uv` picks the newest installed Python + session.run("uv", "python", "pin", MAIN_PYTHON) + # .pre-commit-config.yaml sets the hook types via "default_install_hook_types" session.run("uv", "run", "pre-commit", "install") @@ -559,7 +568,7 @@ def clean_cwd(session: nox.Session) -> None: """Remove (almost) all glob patterns listed in git's ignore file. Compared to `git clean -X`, never remove local environment variables - in the ".env" and ".envrc" files, pyenv's ".python-version" file, + in the ".env" and ".envrc" files, the ".python-version" file, and the local develop environment in ".venv". An existing ".cache/" folder is always deleted first.