Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:58

0001 import os
0002 
0003 import nox
0004 
0005 nox.needs_version = ">=2022.1.7"
0006 nox.options.sessions = ["lint", "tests", "tests_packaging"]
0007 
0008 PYTHON_VERSIONS = [
0009     "3.6",
0010     "3.7",
0011     "3.8",
0012     "3.9",
0013     "3.10",
0014     "3.11",
0015     "pypy3.7",
0016     "pypy3.8",
0017     "pypy3.9",
0018 ]
0019 
0020 if os.environ.get("CI", None):
0021     nox.options.error_on_missing_interpreters = True
0022 
0023 
0024 @nox.session(reuse_venv=True)
0025 def lint(session: nox.Session) -> None:
0026     """
0027     Lint the codebase (except for clang-format/tidy).
0028     """
0029     session.install("pre-commit")
0030     session.run("pre-commit", "run", "-a", *session.posargs)
0031 
0032 
0033 @nox.session(python=PYTHON_VERSIONS)
0034 def tests(session: nox.Session) -> None:
0035     """
0036     Run the tests (requires a compiler).
0037     """
0038     tmpdir = session.create_tmp()
0039     session.install("cmake")
0040     session.install("-r", "tests/requirements.txt")
0041     session.run(
0042         "cmake",
0043         "-S.",
0044         f"-B{tmpdir}",
0045         "-DPYBIND11_WERROR=ON",
0046         "-DDOWNLOAD_CATCH=ON",
0047         "-DDOWNLOAD_EIGEN=ON",
0048         *session.posargs,
0049     )
0050     session.run("cmake", "--build", tmpdir)
0051     session.run("cmake", "--build", tmpdir, "--config=Release", "--target", "check")
0052 
0053 
0054 @nox.session
0055 def tests_packaging(session: nox.Session) -> None:
0056     """
0057     Run the packaging tests.
0058     """
0059 
0060     session.install("-r", "tests/requirements.txt", "--prefer-binary")
0061     session.run("pytest", "tests/extra_python_package", *session.posargs)
0062 
0063 
0064 @nox.session(reuse_venv=True)
0065 def docs(session: nox.Session) -> None:
0066     """
0067     Build the docs. Pass "serve" to serve.
0068     """
0069 
0070     session.install("-r", "docs/requirements.txt")
0071     session.chdir("docs")
0072 
0073     if "pdf" in session.posargs:
0074         session.run("sphinx-build", "-M", "latexpdf", ".", "_build")
0075         return
0076 
0077     session.run("sphinx-build", "-M", "html", ".", "_build")
0078 
0079     if "serve" in session.posargs:
0080         session.log("Launching docs at http://localhost:8000/ - use Ctrl-C to quit")
0081         session.run("python", "-m", "http.server", "8000", "-d", "_build/html")
0082     elif session.posargs:
0083         session.error("Unsupported argument to docs")
0084 
0085 
0086 @nox.session(reuse_venv=True)
0087 def make_changelog(session: nox.Session) -> None:
0088     """
0089     Inspect the closed issues and make entries for a changelog.
0090     """
0091     session.install("ghapi", "rich")
0092     session.run("python", "tools/make_changelog.py")
0093 
0094 
0095 @nox.session(reuse_venv=True)
0096 def build(session: nox.Session) -> None:
0097     """
0098     Build SDists and wheels.
0099     """
0100 
0101     session.install("build")
0102     session.log("Building normal files")
0103     session.run("python", "-m", "build", *session.posargs)
0104     session.log("Building pybind11-global files (PYBIND11_GLOBAL_SDIST=1)")
0105     session.run(
0106         "python", "-m", "build", *session.posargs, env={"PYBIND11_GLOBAL_SDIST": "1"}
0107     )