Skip to content

using nox and uv only to test multiple python versions #6579

@bartdorlandt

Description

@bartdorlandt

Hi,
I'm struggling to use a pure uv only environment that can use nox for multiple python versions...

Dockerfile

FROM ubuntu:24.04

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/GMT
ENV PATH="$PATH:/root/.local/bin"
ENV NOX_DEFAULT_VENV_BACKEND=uv
ARG VERSIONS="3.12 3.11 3.10 3.9"
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv

RUN uv python install ${VERSIONS} && \
    uv tool install nox[uv]

RUN apt-get update -qy && apt-get upgrade -qy && \
    apt-get install -qy --no-install-recommends \
        ca-certificates curl gnupg2 git openssh-client

noxfile.py

"""noxfile."""
from nox import session

py_versions = ["3.12", "3.11"]

@session(python=py_versions)
def tests(session):
    session.install(".")
    session.install("pytest", "pytest-cov")
    session.run("pytest")

the uv python install 3.x doesn't create any shims (like you would have with pyenv), so they are not known to the shell with python3.11 ...
I can call nox from uv per python versions, which works, but kind of beats the point of nox.

uv run --python 3.11 nox -s tests
uv run --python 3.12 nox -s tests

For each of the command the other environment would be skipped. Example:

nox > Running session tests-3.11
nox > Missing interpreters will error by default on CI systems.
nox > Session tests-3.11 skipped: Python interpreter 3.11 not found.

(therefore not specifying the different python versions in the noxfile.)
Has anyone else played with this already? (and got it to work?)
My goal is to use versions installed by uv only and preferably have it run automatically against all desired python versions.

uv version: 0.3.3

Metadata

Metadata

Assignees

Labels

questionAsking for clarification or support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions