Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions examples/word-count/noxfile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import argparse

import nox
import nox_uv

nox.options.sessions = ["test"]


@nox.session
@nox_uv.session(venv_backend="uv", uv_extras=["dev"], uv_no_install_project=True)
def test(session: nox.Session):
parser = argparse.ArgumentParser()
parser.add_argument("--features")
Expand All @@ -14,17 +15,17 @@ def test(session: nox.Session):
session.env["MATURIN_PEP517_ARGS"] = "--profile=dev"
if args.features:
session.env["MATURIN_PEP517_ARGS"] += f" --features={args.features}"
session.install(".[dev]")
session.install(".")
session.run("pytest")


@nox.session
@nox_uv.session(venv_backend="uv", uv_extras=["dev"], uv_no_install_project=True)
def bench(session: nox.Session):
parser = argparse.ArgumentParser()
parser.add_argument("--features")
args = parser.parse_args(session.posargs)

if args.features:
session.env["MATURIN_PEP517_ARGS"] = f" --features={args.features}"
session.install(".[dev]")
session.install(".")
session.run("pytest", "--benchmark-enable")
21 changes: 16 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from urllib.request import urlopen

import nox.command
import nox_uv

try:
import tomllib as toml
Expand Down Expand Up @@ -351,15 +352,20 @@ def bench(session: nox.Session) -> bool:
_run_cargo(session, "bench", _BENCHES, *session.posargs)


@nox.session()
@nox_uv.session(
venv_backend="uv",
uv_packages=["pyo3_pytests"],
uv_extras=["dev", "codspeed"],
uv_no_install_project=True,
)
def codspeed(session: nox.Session) -> bool:
# rust benchmarks
os.chdir(PYO3_DIR / "pyo3-benches")
_run_cargo(session, "codspeed", "build")
_run_cargo(session, "codspeed", "run")
# python benchmarks
os.chdir(PYO3_DIR / "pytests")
session.install(".[dev]", "pytest-codspeed")
session.install(".")
_run(session, "pytest", "--codspeed", external=True)


Expand Down Expand Up @@ -1771,13 +1777,18 @@ def update_ui_tests(session: nox.Session):
)


@nox.session(name="test-introspection")
# `pytest-benchmark` backs the `--benchmark-disable` in `pytests/pyproject.toml`
@nox_uv.session(
name="test-introspection",
venv_backend="uv",
uv_packages=["pyo3_pytests"],
uv_extras=["dev"],
uv_no_install_project=True,
)
def test_introspection(session: nox.Session):
with tempfile.TemporaryDirectory() as stub_dir:
session.install("maturin")
session.install("ruff")
# `pytest-benchmark` backs the `--benchmark-disable` in `pytests/pyproject.toml`
session.install("pytest", "pytest-benchmark")
options = []
target = os.environ.get("CARGO_BUILD_TARGET")
if target is not None:
Expand Down
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,22 @@ style = "fenced"

[tool.uv]
package = false
constraint-dependencies = [
# pytest-benchmark does not support pytest 9.2.0 yet
# https://github.com/ionelmc/pytest-benchmark/issues/321
"pytest<9.2",
]

[tool.uv.workspace]
members = ["pytests", "examples/word-count"]

[tool.uv.dependency-groups]
codecov = { requires-python = ">=3.14" }
dev = { requires-python = ">=3.14" }

[dependency-groups]
codecov = ["codecov-cli==11.3.1"]
nox = ["nox"]
nox = ["nox", "nox-uv"]
dev = [
"ruff",
"rumdl",
Expand Down
9 changes: 5 additions & 4 deletions pytests/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
from pathlib import Path

import nox
import nox_uv
from nox.command import CommandFailed

nox.options.sessions = ["test"]


@nox.session
@nox_uv.session(venv_backend="uv", uv_extras=["dev"], uv_no_install_project=True)
def test(session: nox.Session):
parser = argparse.ArgumentParser()
parser.add_argument("--features")
Expand All @@ -19,7 +20,7 @@ def test(session: nox.Session):
session.env["MATURIN_PEP517_ARGS"] = "--profile=dev"
if args.features:
session.env["MATURIN_PEP517_ARGS"] += f" --features={args.features}"
session.install("-v", ".[dev]")
session.install("-v", ".")

def try_install_binary(package: str, constraint: str):
try:
Expand Down Expand Up @@ -50,9 +51,9 @@ def try_install_binary(package: str, constraint: str):
session.run("pytest", *extra_args, *ignore_args, *unhandled_posargs)


@nox.session
@nox_uv.session(venv_backend="uv", uv_extras=["dev"], uv_no_install_project=True)
def bench(session: nox.Session):
session.install(".[dev]")
session.install(".")
session.run("pytest", "--benchmark-enable", "--benchmark-only", *session.posargs)


Expand Down
3 changes: 2 additions & 1 deletion pytests/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ requires-python = ">=3.9"
]

[project.optional-dependencies]
codspeed = ["pytest-codspeed"]
dev = [
# mypy doesn't build on GraalPy when installed via uv
"mypy~=1.0; platform_python_implementation != 'GraalVM'",
Expand All @@ -41,5 +42,5 @@ dev = [
"pytest-benchmark>=3.4",
"pytest>=7",
# 4.2 for `assert_type`
"typing_extensions>=4.2.0"
"typing_extensions>=4.2.0",
]
Loading
Loading