2022-02-15 22:48:33 +00:00
|
|
|
import os
|
|
|
|
|
2021-07-12 21:45:40 +00:00
|
|
|
import nox
|
|
|
|
|
2022-03-01 17:42:52 +00:00
|
|
|
nox.needs_version = ">=2022.1.7"
|
2021-07-12 21:45:40 +00:00
|
|
|
nox.options.sessions = ["lint", "tests", "tests_packaging"]
|
|
|
|
|
2022-07-16 02:43:27 +00:00
|
|
|
PYTHON_VERSIONS = [
|
|
|
|
"3.6",
|
|
|
|
"3.7",
|
|
|
|
"3.8",
|
|
|
|
"3.9",
|
|
|
|
"3.10",
|
|
|
|
"3.11",
|
|
|
|
"pypy3.7",
|
|
|
|
"pypy3.8",
|
|
|
|
"pypy3.9",
|
|
|
|
]
|
2022-02-15 22:48:33 +00:00
|
|
|
|
|
|
|
if os.environ.get("CI", None):
|
|
|
|
nox.options.error_on_missing_interpreters = True
|
2021-08-23 22:05:54 +00:00
|
|
|
|
2021-07-12 21:45:40 +00:00
|
|
|
|
|
|
|
@nox.session(reuse_venv=True)
|
|
|
|
def lint(session: nox.Session) -> None:
|
|
|
|
"""
|
|
|
|
Lint the codebase (except for clang-format/tidy).
|
|
|
|
"""
|
|
|
|
session.install("pre-commit")
|
2022-08-09 04:02:45 +00:00
|
|
|
session.run("pre-commit", "run", "-a", *session.posargs)
|
2021-07-12 21:45:40 +00:00
|
|
|
|
|
|
|
|
2022-07-16 02:03:51 +00:00
|
|
|
@nox.session(python=PYTHON_VERSIONS)
|
2021-07-12 21:45:40 +00:00
|
|
|
def tests(session: nox.Session) -> None:
|
|
|
|
"""
|
|
|
|
Run the tests (requires a compiler).
|
|
|
|
"""
|
|
|
|
tmpdir = session.create_tmp()
|
2021-10-26 18:50:34 +00:00
|
|
|
session.install("cmake")
|
|
|
|
session.install("-r", "tests/requirements.txt")
|
2021-07-12 21:45:40 +00:00
|
|
|
session.run(
|
|
|
|
"cmake",
|
2022-03-01 17:42:52 +00:00
|
|
|
"-S.",
|
|
|
|
f"-B{tmpdir}",
|
2021-07-12 21:45:40 +00:00
|
|
|
"-DPYBIND11_WERROR=ON",
|
|
|
|
"-DDOWNLOAD_CATCH=ON",
|
|
|
|
"-DDOWNLOAD_EIGEN=ON",
|
2022-03-01 17:42:52 +00:00
|
|
|
*session.posargs,
|
2021-07-12 21:45:40 +00:00
|
|
|
)
|
|
|
|
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")
|
2022-08-09 04:02:45 +00:00
|
|
|
session.run("pytest", "tests/extra_python_package", *session.posargs)
|
2021-07-12 21:45:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
@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")
|
2021-07-15 20:54:40 +00:00
|
|
|
|
|
|
|
if "pdf" in session.posargs:
|
2022-07-13 15:13:35 +00:00
|
|
|
session.run("sphinx-build", "-M", "latexpdf", ".", "_build")
|
2021-07-15 20:54:40 +00:00
|
|
|
return
|
|
|
|
|
2022-07-13 15:13:35 +00:00
|
|
|
session.run("sphinx-build", "-M", "html", ".", "_build")
|
2021-07-12 21:45:40 +00:00
|
|
|
|
2021-07-15 20:54:40 +00:00
|
|
|
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")
|
2021-07-12 21:45:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
@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")
|
2021-11-06 02:48:27 +00:00
|
|
|
session.log("Building normal files")
|
2021-11-10 17:13:10 +00:00
|
|
|
session.run("python", "-m", "build", *session.posargs)
|
2021-11-06 02:48:27 +00:00
|
|
|
session.log("Building pybind11-global files (PYBIND11_GLOBAL_SDIST=1)")
|
2021-11-10 17:13:10 +00:00
|
|
|
session.run(
|
|
|
|
"python", "-m", "build", *session.posargs, env={"PYBIND11_GLOBAL_SDIST": "1"}
|
|
|
|
)
|