|
| 1 | +import nox |
| 2 | + |
| 3 | + |
| 4 | +nox.options.sessions = ["lint", "tests", "tests_packaging"] |
| 5 | + |
| 6 | + |
| 7 | +@nox.session(reuse_venv=True) |
| 8 | +def lint(session: nox.Session) -> None: |
| 9 | + """ |
| 10 | + Lint the codebase (except for clang-format/tidy). |
| 11 | + """ |
| 12 | + session.install("pre-commit") |
| 13 | + session.run("pre-commit", "run", "-a") |
| 14 | + |
| 15 | + |
| 16 | +@nox.session |
| 17 | +def tests(session: nox.Session) -> None: |
| 18 | + """ |
| 19 | + Run the tests (requires a compiler). |
| 20 | + """ |
| 21 | + tmpdir = session.create_tmp() |
| 22 | + session.install("pytest", "cmake") |
| 23 | + session.run( |
| 24 | + "cmake", |
| 25 | + "-S", |
| 26 | + ".", |
| 27 | + "-B", |
| 28 | + tmpdir, |
| 29 | + "-DPYBIND11_WERROR=ON", |
| 30 | + "-DDOWNLOAD_CATCH=ON", |
| 31 | + "-DDOWNLOAD_EIGEN=ON", |
| 32 | + *session.posargs |
| 33 | + ) |
| 34 | + session.run("cmake", "--build", tmpdir) |
| 35 | + session.run("cmake", "--build", tmpdir, "--config=Release", "--target", "check") |
| 36 | + |
| 37 | + |
| 38 | +@nox.session |
| 39 | +def tests_packaging(session: nox.Session) -> None: |
| 40 | + """ |
| 41 | + Run the packaging tests. |
| 42 | + """ |
| 43 | + |
| 44 | + session.install("-r", "tests/requirements.txt", "--prefer-binary") |
| 45 | + session.run("pytest", "tests/extra_python_package") |
| 46 | + |
| 47 | + |
| 48 | +@nox.session(reuse_venv=True) |
| 49 | +def docs(session: nox.Session) -> None: |
| 50 | + """ |
| 51 | + Build the docs. Pass "serve" to serve. |
| 52 | + """ |
| 53 | + |
| 54 | + session.install("-r", "docs/requirements.txt") |
| 55 | + session.chdir("docs") |
| 56 | + session.run("sphinx-build", "-M", "html", ".", "_build") |
| 57 | + |
| 58 | + if session.posargs: |
| 59 | + if "serve" in session.posargs: |
| 60 | + print("Launching docs at http://localhost:8000/ - use Ctrl-C to quit") |
| 61 | + session.run("python", "-m", "http.server", "8000", "-d", "_build/html") |
| 62 | + else: |
| 63 | + print("Unsupported argument to docs") |
| 64 | + |
| 65 | + |
| 66 | +@nox.session(reuse_venv=True) |
| 67 | +def make_changelog(session: nox.Session) -> None: |
| 68 | + """ |
| 69 | + Inspect the closed issues and make entries for a changelog. |
| 70 | + """ |
| 71 | + session.install("ghapi", "rich") |
| 72 | + session.run("python", "tools/make_changelog.py") |
| 73 | + |
| 74 | + |
| 75 | +@nox.session(reuse_venv=True) |
| 76 | +def build(session: nox.Session) -> None: |
| 77 | + """ |
| 78 | + Build SDists and wheels. |
| 79 | + """ |
| 80 | + |
| 81 | + session.install("build") |
| 82 | + session.run("python", "-m", "build") |
| 83 | + session.run("python", "-m", "build", env={"PYBIND11_GLOBAL_SDIST": "1"}) |
0 commit comments