noxfile.py
Go to the documentation of this file.
1 from __future__ import annotations
2 
3 import argparse
4 
5 import nox
6 
7 nox.needs_version = ">=2024.3.2"
8 nox.options.sessions = ["lint", "tests", "tests_packaging"]
9 nox.options.default_venv_backend = "uv|virtualenv"
10 
11 
12 @nox.session(reuse_venv=True)
13 def lint(session: nox.Session) -> None:
14  """
15  Lint the codebase (except for clang-format/tidy).
16  """
17  session.install("pre-commit")
18  session.run("pre-commit", "run", "-a", *session.posargs)
19 
20 
21 @nox.session
22 def tests(session: nox.Session) -> None:
23  """
24  Run the tests (requires a compiler).
25  """
26  tmpdir = session.create_tmp()
27  session.install("cmake")
28  session.install("-r", "tests/requirements.txt")
29  session.run(
30  "cmake",
31  "-S.",
32  f"-B{tmpdir}",
33  "-DPYBIND11_WERROR=ON",
34  "-DDOWNLOAD_CATCH=ON",
35  "-DDOWNLOAD_EIGEN=ON",
36  *session.posargs,
37  )
38  session.run("cmake", "--build", tmpdir)
39  session.run("cmake", "--build", tmpdir, "--config=Release", "--target", "check")
40 
41 
42 @nox.session
43 def tests_packaging(session: nox.Session) -> None:
44  """
45  Run the packaging tests.
46  """
47 
48  session.install("-r", "tests/requirements.txt", "pip")
49  session.run("pytest", "tests/extra_python_package", *session.posargs)
50 
51 
52 @nox.session(reuse_venv=True)
53 def docs(session: nox.Session) -> None:
54  """
55  Build the docs. Pass --non-interactive to avoid serving.
56  """
57 
58  parser = argparse.ArgumentParser()
59  parser.add_argument(
60  "-b", dest="builder", default="html", help="Build target (default: html)"
61  )
62  args, posargs = parser.parse_known_args(session.posargs)
63  serve = args.builder == "html" and session.interactive
64 
65  extra_installs = ["sphinx-autobuild"] if serve else []
66  session.install("-r", "docs/requirements.txt", *extra_installs)
67  session.chdir("docs")
68 
69  shared_args = (
70  "-n", # nitpicky mode
71  "-T", # full tracebacks
72  f"-b={args.builder}",
73  ".",
74  f"_build/{args.builder}",
75  *posargs,
76  )
77 
78  if serve:
79  session.run(
80  "sphinx-autobuild", "--open-browser", "--ignore=.build", *shared_args
81  )
82  else:
83  session.run("sphinx-build", "--keep-going", *shared_args)
84 
85 
86 @nox.session(reuse_venv=True)
87 def make_changelog(session: nox.Session) -> None:
88  """
89  Inspect the closed issues and make entries for a changelog.
90  """
91  session.install("ghapi", "rich")
92  session.run("python", "tools/make_changelog.py")
93 
94 
95 @nox.session(reuse_venv=True)
96 def build(session: nox.Session) -> None:
97  """
98  Build SDists and wheels.
99  """
100 
101  session.install("build")
102  session.log("Building normal files")
103  session.run("python", "-m", "build", *session.posargs)
104  session.log("Building pybind11-global files (PYBIND11_GLOBAL_SDIST=1)")
105  session.run(
106  "python", "-m", "build", *session.posargs, env={"PYBIND11_GLOBAL_SDIST": "1"}
107  )
noxfile.tests_packaging
None tests_packaging(nox.Session session)
Definition: noxfile.py:43
noxfile.build
None build(nox.Session session)
Definition: noxfile.py:96
noxfile.tests
None tests(nox.Session session)
Definition: noxfile.py:22
noxfile.docs
None docs(nox.Session session)
Definition: noxfile.py:53
noxfile.make_changelog
None make_changelog(nox.Session session)
Definition: noxfile.py:87
noxfile.lint
None lint(nox.Session session)
Definition: noxfile.py:13


gtsam
Author(s):
autogenerated on Thu Jul 4 2024 03:02:15