Skip to content

Use nox virtual-environments in sessions#235

Merged
Preocts merged 1 commit intomainfrom
noxfile-update
May 3, 2026
Merged

Use nox virtual-environments in sessions#235
Preocts merged 1 commit intomainfrom
noxfile-update

Conversation

@Preocts
Copy link
Copy Markdown
Owner

@Preocts Preocts commented May 3, 2026

The prior implementation used python=False for all session decorators which disabled the creation of virtual environments. While this made things simple, there were trade-offs with maintaining the state of the developer's environment and venv.

Instead, determine the desired version of Python from two sources. The .python-version file and the UV_PYTHON environment variable. Use the environment variable if it exists, otherwise use the file. Pass this into the session decorator and allow nox to manage its virtual environments for the following sessions:

  • test
  • combine
  • lint
  • format

The result is using more of the features nox provides while keep the dev's environment as-is during nox sessions that run uv sync. The test, lint, format, and combine sessions all trigger a sync to ensure their dependencies are met. Prior, this would leave the dev's environment in an altered state.

Example: If the the dev had installed nox with uv pip install nox for developement on the sessions, once any of the listed sessions were run the .venv was rebuilt.

@Preocts Preocts self-assigned this May 3, 2026
The prior implementation used `python=False` for all session decorators
which disabled the creation of virtual environments. While this made
things simple, there were trade-offs with maintaining the state of the
developer's environment and venv.

Instead, determine the desired version of Python from two sources. The
`.python-version` file and the `UV_PYTHON` environment variable. Use the
environment variable if it exists, otherwise use the file. Pass this
into the session decorator and allow nox to manage its virtual
environments for the following sessions:

- test
- combine
- lint
- format

The result is using more of the features nox provides while keep the
dev's environment as-is during nox sessions that run `uv sync`. The
test, lint, format, and combine sessions all trigger a sync to ensure
their dependencies are met. Prior, this would leave the dev's
environment in an altered state.

Example: If the the dev had installed nox with `uv pip install nox` for
developement on the sessions, once any of the listed sessions were run
the `.venv` was rebuilt.
@Preocts Preocts merged commit 8b258e7 into main May 3, 2026
8 checks passed
@Preocts Preocts deleted the noxfile-update branch May 3, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant