Skip to content

Commit

Permalink
chore: use dependency-groups (#873)
Browse files Browse the repository at this point in the history
* chore: use dependency-groups

Signed-off-by: Henry Schreiner <[email protected]>

* Update noxfile.py

---------

Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Oct 28, 2024
1 parent 5e02a64 commit 7dd02a8
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 59 deletions.
15 changes: 7 additions & 8 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
version: 2
build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3.10"

python:
install:
- requirements: requirements-test.txt
- method: pip
path: .
python: "3.12"
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- uv run --group docs sphinx-build -T -b html -d docs/_build/doctrees -D language=en docs $READTHEDOCS_OUTPUT/html
62 changes: 26 additions & 36 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,24 @@

ON_WINDOWS_CI = "CI" in os.environ and platform.system() == "Windows"

nox.needs_version = ">=2024.3.2"
nox.needs_version = ">=2024.4.15"
nox.options.default_venv_backend = "uv|virtualenv"

# Skip 'conda_tests' if user doesn't have conda installed
nox.options.sessions = ["tests", "cover", "lint", "docs"]
if shutil.which("conda"):
nox.options.sessions.append("conda_tests")
if shutil.which("mamba"):
nox.options.sessions.append("mamba_tests")
if shutil.which("micromamba"):
nox.options.sessions.append("micromamba_tests")
PYPROJECT = nox.project.load_toml("pyproject.toml")

ALL_PYTHONS = [
c.split()[-1]
for c in PYPROJECT["project"]["classifiers"]
if c.startswith("Programming Language :: Python :: 3.")
]


@nox.session
@nox.parametrize(
"python, tox_version",
[
(python, tox_version)
for python in ("3.8", "3.9", "3.10", "3.11", "3.12", "3.13")
for python in ALL_PYTHONS
for tox_version in ("latest", "<4")
],
)
Expand All @@ -57,7 +56,7 @@ def tests(session: nox.Session, tox_version: str) -> None:
)

session.create_tmp() # Fixes permission errors on Windows
session.install("-r", "requirements-test.txt")
session.install(*PYPROJECT["dependency-groups"]["test"], "uv")
session.install("-e.[tox_to_nox]")
if tox_version != "latest":
session.install(f"tox{tox_version}")
Expand All @@ -79,37 +78,37 @@ def tests(session: nox.Session, tox_version: str) -> None:
con.execute("DELETE FROM file WHERE SUBSTR(path, 2, 1) == ':'")


@nox.session(venv_backend="conda")
@nox.session(venv_backend="conda", default=shutil.which("conda"))
def conda_tests(session: nox.Session) -> None:
"""Run test suite set up with conda."""
session.conda_install(
"--file", "requirements-conda-test.txt", channel="conda-forge"
)
session.install("-e", ".", "--no-deps")
session.install("-e.", "--no-deps")
session.run("pytest", *session.posargs)


@nox.session(venv_backend="mamba")
@nox.session(venv_backend="mamba", default=shutil.which("mamba"))
def mamba_tests(session: nox.Session) -> None:
"""Run test suite set up with mamba."""
session.conda_install(
"--file", "requirements-conda-test.txt", channel="conda-forge"
)
session.install("-e", ".", "--no-deps")
session.install("-e.", "--no-deps")
session.run("pytest", *session.posargs)


@nox.session(venv_backend="micromamba")
@nox.session(venv_backend="micromamba", default=shutil.which("micromamba"))
def micromamba_tests(session: nox.Session) -> None:
"""Run test suite set up with micromamba."""
session.conda_install(
"--file", "requirements-conda-test.txt", channel="conda-forge"
)
session.install("-e", ".", "--no-deps")
session.install("-e.", "--no-deps")
session.run("pytest", *session.posargs)


@nox.session
@nox.session(default=False)
def cover(session: nox.Session) -> None:
"""Coverage analysis."""
if ON_WINDOWS_CI:
Expand All @@ -135,16 +134,16 @@ def lint(session: nox.Session) -> None:
)


@nox.session
@nox.session(default=False)
def docs(session: nox.Session) -> None:
"""Build the documentation."""
output_dir = os.path.join(session.create_tmp(), "output")
doctrees, html = map(
functools.partial(os.path.join, output_dir), ["doctrees", "html"]
)
shutil.rmtree(output_dir, ignore_errors=True)
session.install("-r", "requirements-test.txt")
session.install(".")
session.install(*PYPROJECT["dependency-groups"]["docs"])
session.install("-e.")
session.cd("docs")
sphinx_args = ["-b", "html", "-W", "-d", doctrees, ".", html]

Expand Down Expand Up @@ -181,15 +180,10 @@ def _check_python_version(session: nox.Session) -> None:

@nox.session(
python=[
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
"3.13",
"pypy3.9",
*ALL_PYTHONS,
"pypy3.10",
]
],
default=False,
)
def github_actions_default_tests(session: nox.Session) -> None:
"""Check default versions installed by the nox GHA Action"""
Expand All @@ -199,16 +193,12 @@ def github_actions_default_tests(session: nox.Session) -> None:

@nox.session(
python=[
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
"3.13",
*ALL_PYTHONS,
"pypy3.8",
"pypy3.9",
"pypy3.10",
]
],
default=False,
)
def github_actions_all_tests(session: nox.Session) -> None:
"""Check all versions installed by the nox GHA Action"""
Expand Down
21 changes: 19 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ keywords = [
]
license = { text = "Apache-2.0" }
authors = [
{ name = "Alethea Katherine Flowers" },
{ email = "[email protected]" },
{ name = "Alethea Katherine Flowers", email = "[email protected]" },
]
requires-python = ">=3.8"
classifiers = [
Expand Down Expand Up @@ -116,3 +115,21 @@ enable_error_code = [ "ignore-without-code", "redundant-expr", "truthy-bool" ]
[[tool.mypy.overrides]]
module = [ "argcomplete", "colorlog.*", "py", "tox.*" ]
ignore_missing_imports = true

[dependency-groups]
test = [
"coverage[toml]>=7.2",
"pytest>=6.0",
"pytest-cov",
]
docs = [
"myst-parser",
"sphinx>=3.0",
"sphinx-autobuild",
"sphinx-tabs",
"witchhazel",
]
dev = [
{ include-group = "docs" },
{ include-group = "test" },
]
3 changes: 0 additions & 3 deletions requirements-dev.txt

This file was deleted.

10 changes: 0 additions & 10 deletions requirements-test.txt

This file was deleted.

0 comments on commit 7dd02a8

Please sign in to comment.