Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use uv instead of pip to manage nox virtualenvs
Upgrade Nox to (at least) 2024.03.02 (which is the first version with support for managing virtualenvs with uv. Add uv as an indirect dependency by depending on "nox[uv]" instead of "nox" (exception: inside the "lint" dependency group, we only depend on "nox" in order for Mypy to access Nox' type annotations, uv is not needed here). Also we cannot use/depend on uv when using Python 3.7, since uv requires Python >=v3.8. I'm not actually sure _why_ uv requires >=v3.8, as it is apparently able to create venvs for Python v3.7 (see e.g. https://github.com/astral-sh/uv?tab=readme-ov-file#python-discovery), still astral-sh/uv#1239 prevents uv from being installed on <=v3.7). Finally, in noxfile.py, use uv as our default venv_backend instead of the default (pip), but only when it is in fact available. A final complication on Nix(OS) happens when we install requirements for the current session; we do this in two steps, and then we make sure that whatever we installed was patched appropriately: session.install("-r", str(requirments_txt)) if include_self: session.install("-e", ".") if not session.virtualenv._reused: # noqa: SLF001 patch_binaries_if_needed(session, session.virtualenv.location) However, with uv in the mix, we have to consider that session.install() itself _runs_ uv at the same time as the first session.install() may also _install_ uv itself into the virtualenv. The second session.install() can then end up _running_ a uv that was _installed_ by the first session.install(), and this will break on Nix(OS) unless the uv binary has been patched in the meantime. We therefore need to insert a call to patch_binaries_if_needed() _between_ the two session.install() calls. Since the second session.install() only installs FawltyDeps itself (which does not introduce any binaries to be patched), we can get away with simply reordering the second session.install() and the call to patch_binaries_if_needed(): session.install("-r", str(requirments_txt)) if not session.virtualenv._reused: # noqa: SLF001 patch_binaries_if_needed(session, session.virtualenv.location) if include_self: session.install("-e", ".")
- Loading branch information