Nox-Poetry Integration

1.2.0 · active · verified Thu Apr 16

nox-poetry is a plugin for Nox, a flexible test automation tool, that simplifies testing and building Python projects managed with Poetry. It integrates Poetry's dependency management and build processes directly into Nox sessions, providing features like installing project dependencies, building packages, and exporting requirements. The current version is 1.2.0, with regular updates that often include support for newer Python and Poetry versions, alongside bug fixes and minor feature enhancements.

Common errors

Warnings

Install

Imports

Quickstart

This `noxfile.py` demonstrates how to use `nox-poetry` to manage dependencies and run tests for a Poetry-managed project across multiple Python versions, and how to build the project.

# noxfile.py
import nox

@nox.session(python=["3.9", "3.10", "3.11", "3.12"])
def tests(session):
    # Install project dependencies, including dev dependencies.
    # This respects the poetry.lock file.
    session.poetry.install(extras=["all"], groups=["dev"])

    # Run tests
    session.run("pytest", *session.posargs)

@nox.session(python="3.12")
def build(session):
    # Build the package (sdist and wheel)
    session.poetry.build()
    # You can then use the built package, e.g., check its contents
    session.run("ls", "dist", external=True)

view raw JSON →