Skip to main content

Facilitate nox integration with uv for Python projects

Project description

Intro

GitHub Actions PyPI version Python versions uv Nox Ruff Type checked with mypy

nox-uv is a simple drop-in replacement for nox's @nox.session that installs dependencies constrained by uv's lockfile.

Usage

Add nox-uv as a development dependency. The following example adds it into a nox dependency-group.

uv add --group nox nox-uv

Using the following configuration within pyproject.toml as an example:

[dependency-groups]
nox = [
    "nox-uv",
]
test = [
    "pytest",
    "pytest-cov",
]
type_check = [
    "mypy",
]
lint = [
    "ruff",
]

Within, your noxfile.py:

  1. Import session from nox_uv.
  2. Set venv_backend to "uv". This can be done globally using options.default_venv_backend = "uv".
  3. Use the new uv_* parameters to session to control which dependencies are synced into the session's virtual environment in addition to the project's main dependencies.
    • uv sync is used to install dependencies so that their versions are constrained by uv.lock.
    • By default (configurable with the uv_sync_locked parameter), uv.lock is also validated to be up to date.
from nox import Session, options
from nox_uv import session

options.default_venv_backend = "uv"


@session(
    python=["3.10", "3.11", "3.12", "3.13", "3.14"],
    uv_groups=["test"],
)
def test(s: Session) -> None:
    s.run("python", "-m", "pytest")


@session(uv_groups=["type_check"])
def type_check(s: Session) -> None:
    s.run("mypy", "src")


@session(uv_only_groups=["lint"])
def lint(s: Session) -> None:
    s.run("ruff", "check", ".")
    s.run("ruff", "format", "--check", ".")

[!NOTE] All @session(...) parameters are keywords only, no positional parameters are allowed.

[!NOTE] The default_groups defined in pyproject.toml are not installed by default. The user must explicitly list the desired groups in the uv_groups parameter.

Added parameters

  • uv_groups: list of uv dependency-groups
  • uv_extras: list of uv optional-dependencies
  • uv_only_groups: list of uv only-groups to include. Prevents installation of project dependencies
  • uv_all_extras: boolean to install all optional-dependencies from pyproject.toml
  • uv_no_extras: list of extras to exclude during install of uv_all_extras
  • uv_all_groups: boolean to install all dependency-groups
  • uv_no_groups: list of groups to exclude during install of uv_all_groups
  • uv_no_install_project: boolean to not install the current project
  • uv_sync_locked: boolean to validate that uv.lock is up to date
  • uv_quiet: boolean to silence uv sync command

Inspiration

This is heavily influenced by, but much more limited than, nox-poetry.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nox_uv-0.7.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nox_uv-0.7.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file nox_uv-0.7.1.tar.gz.

File metadata

  • Download URL: nox_uv-0.7.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.2","id":"zara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nox_uv-0.7.1.tar.gz
Algorithm Hash digest
SHA256 f075d610b4648732fd17cbc9fa48be7d2c23df7b188fed3e4e6dde7bd1f14f20
MD5 6301da38f8b4bbfcbb49d4ae359aa652
BLAKE2b-256 04e8670919c513c22f4bf1656d84dd99a9ad1a5eaaeadf2457bab3efeeac14e0

See more details on using hashes here.

File details

Details for the file nox_uv-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: nox_uv-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.2","id":"zara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nox_uv-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91361cc282a0a764de1b94ad002b67d5b43de4adc3f56e16d1b79928c8ec0433
MD5 850def5413f503021fbb1b96c81d7712
BLAKE2b-256 4f0aa6798a215366c9b034e92a9992d9013da5f544a488216fc54204ccf3c134

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page