noxfile.py 2.51 KB
Newer Older
1
2
import nox

Henry Schreiner's avatar
Henry Schreiner committed
3
nox.needs_version = ">=2022.1.7"
4
5
nox.options.sessions = ["lint", "tests", "tests_packaging"]

Chris Ohk's avatar
Chris Ohk committed
6
PYTHON_VERSIONS = ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
7

8
9
10
11
12
13
14
15
16
17

@nox.session(reuse_venv=True)
def lint(session: nox.Session) -> None:
    """
    Lint the codebase (except for clang-format/tidy).
    """
    session.install("pre-commit")
    session.run("pre-commit", "run", "-a")


Chris Ohk's avatar
Chris Ohk committed
18
@nox.session(python=PYTHON_VERSIONS)
19
20
21
22
23
def tests(session: nox.Session) -> None:
    """
    Run the tests (requires a compiler).
    """
    tmpdir = session.create_tmp()
24
25
    session.install("cmake")
    session.install("-r", "tests/requirements.txt")
26
27
    session.run(
        "cmake",
Henry Schreiner's avatar
Henry Schreiner committed
28
29
        "-S.",
        f"-B{tmpdir}",
30
31
32
        "-DPYBIND11_WERROR=ON",
        "-DDOWNLOAD_CATCH=ON",
        "-DDOWNLOAD_EIGEN=ON",
Henry Schreiner's avatar
Henry Schreiner committed
33
        *session.posargs,
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    )
    session.run("cmake", "--build", tmpdir)
    session.run("cmake", "--build", tmpdir, "--config=Release", "--target", "check")


@nox.session
def tests_packaging(session: nox.Session) -> None:
    """
    Run the packaging tests.
    """

    session.install("-r", "tests/requirements.txt", "--prefer-binary")
    session.run("pytest", "tests/extra_python_package")


@nox.session(reuse_venv=True)
def docs(session: nox.Session) -> None:
    """
    Build the docs. Pass "serve" to serve.
    """

    session.install("-r", "docs/requirements.txt")
    session.chdir("docs")
57
58

    if "pdf" in session.posargs:
59
        session.run("sphinx-build", "-b", "latexpdf", ".", "_build")
60
61
        return

62
    session.run("sphinx-build", "-b", "html", ".", "_build")
63

64
65
66
67
68
    if "serve" in session.posargs:
        session.log("Launching docs at http://localhost:8000/ - use Ctrl-C to quit")
        session.run("python", "-m", "http.server", "8000", "-d", "_build/html")
    elif session.posargs:
        session.error("Unsupported argument to docs")
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86


@nox.session(reuse_venv=True)
def make_changelog(session: nox.Session) -> None:
    """
    Inspect the closed issues and make entries for a changelog.
    """
    session.install("ghapi", "rich")
    session.run("python", "tools/make_changelog.py")


@nox.session(reuse_venv=True)
def build(session: nox.Session) -> None:
    """
    Build SDists and wheels.
    """

    session.install("build")
87
    session.log("Building normal files")
88
    session.run("python", "-m", "build", *session.posargs)
89
    session.log("Building pybind11-global files (PYBIND11_GLOBAL_SDIST=1)")
90
91
92
    session.run(
        "python", "-m", "build", *session.posargs, env={"PYBIND11_GLOBAL_SDIST": "1"}
    )